Author: gbayon
Date: Sun Dec  4 11:24:29 2005
New Revision: 353897

URL: http://svn.apache.org/viewcvs?rev=353897&view=rev
Log:
- Updated unit test for log

Modified:
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
    
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs?rev=353897&r1=353896&r2=353897&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Logging/LogTest.cs
 Sun Dec  4 11:24:29 2005
@@ -1,3 +1,5 @@
+using System;
+using System.IO;
 using System.Reflection;
 using IBatisNet.Common.Logging;
 using NUnit.Framework;
@@ -12,49 +14,88 @@
        public class LogTest
        {
                private ILog _log = null;
+               private StringWriter outWriter = new StringWriter();
+               private StringWriter errorWriter = new StringWriter();
 
-
+               #region SetUp/TearDown
                [SetUp]
                public void SetUp()
                {
                        _log = LogManager.GetLogger( 
MethodBase.GetCurrentMethod().DeclaringType );
-                       _log.Info( "Starting tests..." );
+
+                       outWriter.GetStringBuilder().Length = 0;
+                       errorWriter.GetStringBuilder().Length = 0;
+
+                       Console.SetOut(outWriter);
+                       Console.SetError(errorWriter);
                }
 
                [TearDown]
                public void TearDown()
-               {
-                       _log.Info( "Ending tests..." );
-               }
+               {}
+               #endregion
 
                [Test]
                public void LogDebug()
                {
-                       _log.Debug("test LogDebug");
+                       string expectedLogOutput = "[DEBUG] 
IBatisNet.Common.Test.NUnit.CommonTests.Logging.LogTest - LogDebug";
+                       string actualLogOutput = "";
+
+                       _log.Debug("LogDebug");
+
+                       actualLogOutput = 
outWriter.GetStringBuilder().ToString();
+                       
Assert.IsTrue(actualLogOutput.IndexOf(expectedLogOutput)>0);
                }
 
                [Test]
                public void LogInfo()
                {
-                       _log.Info("test LogInfo");
+                       string expectedLogOutput = "[INFO]  
IBatisNet.Common.Test.NUnit.CommonTests.Logging.LogTest - LogInfo";
+                       string actualLogOutput = "";
+
+                       _log.Info("LogInfo");
+
+                       actualLogOutput = 
outWriter.GetStringBuilder().ToString();
+                       
Assert.IsTrue(actualLogOutput.IndexOf(expectedLogOutput)>0);
                }
 
                [Test]
                public void LogError()
                {
-                       _log.Error("test LogError");
+                       string expectedLogOutput = "[ERROR] 
IBatisNet.Common.Test.NUnit.CommonTests.Logging.LogTest - LogError";
+                       string actualLogOutput = "";
+
+                       _log.Error("LogError");
+
+                       actualLogOutput = 
outWriter.GetStringBuilder().ToString();
+                       
Assert.IsTrue(actualLogOutput.IndexOf(expectedLogOutput)>0);
                }
 
                [Test]
                public void LogFatal()
                {
-                       _log.Fatal("test LogFatal");
+                       string expectedLogOutput = "[FATAL] 
IBatisNet.Common.Test.NUnit.CommonTests.Logging.LogTest - LogFatal";
+                       string actualLogOutput = "";
+
+                       _log.Fatal("LogFatal");
+
+                       actualLogOutput = 
outWriter.GetStringBuilder().ToString();
+                       
Assert.IsTrue(actualLogOutput.IndexOf(expectedLogOutput)>0);
                }
 
+
                [Test]
                public void LogWarn()
                {
-                       _log.Warn("test LogWarn");
+                       string expectedLogOutput = "[WARN]  
IBatisNet.Common.Test.NUnit.CommonTests.Logging.LogTest - LogWarn";
+                       string actualLogOutput = "";
+
+                       _log.Warn("LogWarn");
+
+                       actualLogOutput = 
outWriter.GetStringBuilder().ToString();
+                       int i = actualLogOutput.IndexOf(expectedLogOutput);
+                       
Assert.IsTrue(actualLogOutput.IndexOf(expectedLogOutput)>0);
                }
+
        }
 }

Modified: 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
URL: 
http://svn.apache.org/viewcvs/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config?rev=353897&r1=353896&r2=353897&view=diff
==============================================================================
--- 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
 (original)
+++ 
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/bin/Debug/IBatisNet.Common.Test.dll.config
 Sun Dec  4 11:24:29 2005
@@ -27,8 +27,8 @@
                <logging>
                        <logFactoryAdapter 
type="IBatisNet.Common.Logging.Impl.ConsoleOutLoggerFA, IBatisNet.Common">
                                <arg key="showLogName" value="true" />
-                               <arg key="showDataTime" value="true" />
-                               <arg key="level" value="ALL" />
+                               <arg key="showDateTime" value="true" />
+                               <arg key="level" value="All" />
                                <arg key="dateTimeFormat" value="yyyy/MM/dd 
HH:mm:ss:SSS" />
                        </logFactoryAdapter>            
                        


Reply via email to