Author: rgrabowski Date: Mon Feb 20 22:16:37 2006 New Revision: 379366 URL: http://svn.apache.org/viewcvs?rev=379366&view=rev Log: Private helper method from previous checkin was not checking all values correctly.
Modified: logging/log4net/trunk/tests/src/Core/FixingTest.cs Modified: logging/log4net/trunk/tests/src/Core/FixingTest.cs URL: http://svn.apache.org/viewcvs/logging/log4net/trunk/tests/src/Core/FixingTest.cs?rev=379366&r1=379365&r2=379366&view=diff ============================================================================== --- logging/log4net/trunk/tests/src/Core/FixingTest.cs (original) +++ logging/log4net/trunk/tests/src/Core/FixingTest.cs Mon Feb 20 22:16:37 2006 @@ -39,25 +39,11 @@ } } - private LoggingEventData buildStandardEventData() - { - LoggingEventData loggingEventData = new LoggingEventData(); - loggingEventData.LoggerName = typeof(FixingTest).FullName; - loggingEventData.Level = Level.Warn; - loggingEventData.Message = "Logging event works"; - loggingEventData.Domain = "ReallySimpleApp"; - loggingEventData.LocationInfo = new LocationInfo(typeof(FixingTest).Name,"Main","Class1.cs","29"); //Completely arbitary - loggingEventData.ThreadName = Thread.CurrentThread.Name; - loggingEventData.TimeStamp = DateTime.Today; - loggingEventData.ExceptionString = "Exception occured here"; - loggingEventData.UserName = "TestUser"; - return loggingEventData; - } - [Test] public void TestUnfixedValues() { LoggingEventData loggingEventData = buildStandardEventData(); + // LoggingEvents occur at distinct points in time LoggingEvent loggingEvent = new LoggingEvent( loggingEventData.LocationInfo.GetType(), LogManager.GetRepository("Test Repository"), @@ -66,7 +52,7 @@ loggingEventData.Message, new Exception("This is the exception")); - assertStandardEventData(loggingEvent); + assertExpectedLoggingEvent(loggingEvent, loggingEventData); Assert.AreEqual(FixFlags.None,loggingEvent.Fix,"Fixed Fields is incorrect"); } @@ -75,6 +61,7 @@ { LoggingEventData loggingEventData = buildStandardEventData(); + // LoggingEvents occur at distinct points in time LoggingEvent loggingEvent = new LoggingEvent( loggingEventData.LocationInfo.GetType(), LogManager.GetRepository("Test Repository"), @@ -83,7 +70,7 @@ loggingEventData.Message, new Exception("This is the exception")); - assertStandardEventData(loggingEvent); + assertExpectedLoggingEvent(loggingEvent, loggingEventData); loggingEvent.Fix = FixFlags.All; @@ -94,6 +81,7 @@ { LoggingEventData loggingEventData = buildStandardEventData(); + // LoggingEvents occur at distinct points in time LoggingEvent loggingEvent = new LoggingEvent( loggingEventData.LocationInfo.GetType(), LogManager.GetRepository("Test Repository"), @@ -102,25 +90,40 @@ loggingEventData.Message, new Exception("This is the exception")); - assertStandardEventData(loggingEvent); + assertExpectedLoggingEvent(loggingEvent, loggingEventData); loggingEvent.Fix = FixFlags.None; Assert.AreEqual(FixFlags.None,loggingEvent.Fix,"Fixed Fields is incorrect"); } - private void assertStandardEventData(LoggingEvent loggingEvent) + private LoggingEventData buildStandardEventData() + { + LoggingEventData loggingEventData = new LoggingEventData(); + loggingEventData.LoggerName = typeof(FixingTest).FullName; + loggingEventData.Level = Level.Warn; + loggingEventData.Message = "Logging event works"; + loggingEventData.Domain = "ReallySimpleApp"; + loggingEventData.LocationInfo = new LocationInfo(typeof(FixingTest).Name,"Main","Class1.cs","29"); //Completely arbitary + loggingEventData.ThreadName = Thread.CurrentThread.Name; + loggingEventData.TimeStamp = DateTime.Today; + loggingEventData.ExceptionString = "Exception occured here"; + loggingEventData.UserName = "TestUser"; + return loggingEventData; + } + + private void assertExpectedLoggingEvent(LoggingEvent loggingEvent, LoggingEventData loggingEventData) { - Assert.AreEqual("domain-log4net.Tests.dll",loggingEvent.Domain,"Domain is incorrect"); + Assert.AreEqual("ReallySimpleApp",loggingEventData.Domain,"Domain is incorrect"); Assert.AreEqual("System.Exception: This is the exception",loggingEvent.GetExceptionString(),"Exception is incorrect"); - Assert.AreEqual("",loggingEvent.Identity,"Identity is incorrect"); - Assert.AreEqual(Level.Warn,loggingEvent.Level,"Level is incorrect"); + Assert.AreEqual(null,loggingEventData.Identity,"Identity is incorrect"); + Assert.AreEqual(Level.Warn,loggingEventData.Level,"Level is incorrect"); Assert.AreEqual("get_LocationInformation",loggingEvent.LocationInformation.MethodName,"Location Info is incorrect"); - Assert.AreEqual("log4net.Tests.Core.FixingTest",loggingEvent.LoggerName,"LoggerName is incorrect"); + Assert.AreEqual("log4net.Tests.Core.FixingTest",loggingEventData.LoggerName,"LoggerName is incorrect"); Assert.AreEqual(LogManager.GetRepository("Test Repository"),loggingEvent.Repository,"Repository is incorrect"); - Assert.AreEqual(Thread.CurrentThread.Name,loggingEvent.ThreadName,"ThreadName is incorrect"); - Assert.IsNotNull(loggingEvent.TimeStamp,"TimeStamp is incorrect"); - Assert.AreEqual(System.Security.Principal.WindowsIdentity.GetCurrent().Name ,loggingEvent.UserName,"UserName is incorrect"); + Assert.AreEqual(Thread.CurrentThread.Name,loggingEventData.ThreadName,"ThreadName is incorrect"); + Assert.IsNotNull(loggingEventData.TimeStamp,"TimeStamp is incorrect"); + Assert.AreEqual("TestUser" ,loggingEventData.UserName,"UserName is incorrect"); Assert.AreEqual("Logging event works",loggingEvent.RenderedMessage,"Message is incorrect"); } }