aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common/TestHelpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common/TestHelpers.cs')
-rw-r--r--OpenSim/Tests/Common/TestHelpers.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/OpenSim/Tests/Common/TestHelpers.cs b/OpenSim/Tests/Common/TestHelpers.cs
index ced06de..30121fe 100644
--- a/OpenSim/Tests/Common/TestHelpers.cs
+++ b/OpenSim/Tests/Common/TestHelpers.cs
@@ -27,6 +27,8 @@
27 27
28using System; 28using System;
29using System.Diagnostics; 29using System.Diagnostics;
30using System.IO;
31using System.Text;
30using NUnit.Framework; 32using NUnit.Framework;
31using OpenMetaverse; 33using OpenMetaverse;
32 34
@@ -34,6 +36,38 @@ namespace OpenSim.Tests.Common
34{ 36{
35 public class TestHelpers 37 public class TestHelpers
36 { 38 {
39 private static Stream EnableLoggingConfigStream
40 = new MemoryStream(
41 Encoding.UTF8.GetBytes(
42@"<log4net>
43 <!-- A1 is set to be a ConsoleAppender -->
44 <appender name=""A1"" type=""log4net.Appender.ConsoleAppender"">
45
46 <!-- A1 uses PatternLayout -->
47 <layout type=""log4net.Layout.PatternLayout"">
48 <!-- Print the date in ISO 8601 format -->
49 <!-- <conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" /> -->
50 <conversionPattern value=""%date %message%newline"" />
51 </layout>
52 </appender>
53
54 <!-- Set root logger level to DEBUG and its only appender to A1 -->
55 <root>
56 <level value=""DEBUG"" />
57 <appender-ref ref=""A1"" />
58 </root>
59</log4net>"));
60
61 private static MemoryStream DisableLoggingConfigStream
62 = new MemoryStream(
63 Encoding.UTF8.GetBytes(
64// "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>"));
65 //"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")));
66// "<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>"));
67// "<configuration><log4net><root></root></log4net></configuration>")));
68// "<configuration><log4net><root/></log4net></configuration>"));
69 "<log4net><root/></log4net>"));
70
37 public static bool AssertThisDelegateCausesArgumentException(TestDelegate d) 71 public static bool AssertThisDelegateCausesArgumentException(TestDelegate d)
38 { 72 {
39 try 73 try
@@ -58,6 +92,26 @@ namespace OpenSim.Tests.Common
58 Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name); 92 Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name);
59 } 93 }
60 94
95 public static void EnableLogging()
96 {
97 log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream);
98 }
99
100 /// <summary>
101 /// Disable logging whilst running the tests.
102 /// </summary>
103 /// <remarks>
104 /// Remember, if a regression test throws an exception before completing this will not be invoked if it's at
105 /// the end of the test.
106 /// TODO: Always invoke this after every test - probably need to make all test cases inherit from a common
107 /// TestCase class where this can be done.
108 /// </remarks>
109 public static void DisableLogging()
110 {
111 log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream);
112 DisableLoggingConfigStream.Position = 0;
113 }
114
61 /// <summary> 115 /// <summary>
62 /// Parse tail section into full UUID. 116 /// Parse tail section into full UUID.
63 /// </summary> 117 /// </summary>