mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 01:06:30 +08:00
Create TestHelpers.EnableLogging() and DisableLogging() to turn logging on and off within tests.
This makes *.Tests.dll.config files no longer needed, hence deleted.
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
@@ -68,11 +69,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
Vector3 position = new Vector3(200,200,21);
|
||||
|
||||
foreach (Border b in testborders)
|
||||
{
|
||||
Assert.That(!b.TestCross(position));
|
||||
|
||||
}
|
||||
|
||||
position = new Vector3(200,280,21);
|
||||
Assert.That(NorthBorder.TestCross(position));
|
||||
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
@@ -44,6 +46,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
public void TestDuplicateObject()
|
||||
{
|
||||
TestHelpers.InMethod();
|
||||
// TestHelpers.EnableLogging();
|
||||
|
||||
Scene scene = new SceneHelpers().SetupScene();
|
||||
|
||||
UUID ownerId = new UUID("00000000-0000-0000-0000-000000000010");
|
||||
@@ -82,6 +86,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
Assert.That(dupePart1.PhysActor, Is.Not.Null);
|
||||
Assert.That(dupePart2.PhysActor, Is.Not.Null);
|
||||
*/
|
||||
|
||||
// TestHelpers.DisableLogging();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,8 @@ using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
|
||||
using OpenSim.Tests.Common;
|
||||
using OpenSim.Tests.Common.Mock;
|
||||
using System.Threading;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.Framework.Scenes.Tests
|
||||
{
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
|
||||
@@ -34,6 +36,37 @@ namespace OpenSim.Tests.Common
|
||||
{
|
||||
public class TestHelpers
|
||||
{
|
||||
private static Stream EnableLoggingConfigStream
|
||||
= new MemoryStream(
|
||||
Encoding.UTF8.GetBytes(
|
||||
@"<log4net>
|
||||
<!-- A1 is set to be a ConsoleAppender -->
|
||||
<appender name=""A1"" type=""log4net.Appender.ConsoleAppender"">
|
||||
|
||||
<!-- A1 uses PatternLayout -->
|
||||
<layout type=""log4net.Layout.PatternLayout"">
|
||||
<!-- Print the date in ISO 8601 format -->
|
||||
<conversionPattern value=""%date [%thread] %-5level %logger %ndc - %message%newline"" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- Set root logger level to DEBUG and its only appender to A1 -->
|
||||
<root>
|
||||
<level value=""DEBUG"" />
|
||||
<appender-ref ref=""A1"" />
|
||||
</root>
|
||||
</log4net>"));
|
||||
|
||||
private static Stream DisableLoggingConfigStream
|
||||
= new MemoryStream(
|
||||
Encoding.UTF8.GetBytes(
|
||||
// "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/><appender-ref ref=\"A1\"/></root></log4net></configuration>")));
|
||||
//"<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")));
|
||||
//"<configuration><log4net><root><level value=\"OFF\"/></root></log4net></configuration>")));
|
||||
//"<configuration><log4net><root></root></log4net></configuration>")));
|
||||
//"<configuration><log4net><root/></log4net></configuration>")));
|
||||
"<log4net><root/></log4net>"));
|
||||
|
||||
public static bool AssertThisDelegateCausesArgumentException(TestDelegate d)
|
||||
{
|
||||
try
|
||||
@@ -58,6 +91,19 @@ namespace OpenSim.Tests.Common
|
||||
Console.WriteLine("===> In Test Method : {0} <===", stackTrace.GetFrame(1).GetMethod().Name);
|
||||
}
|
||||
|
||||
public static void EnableLogging()
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure(EnableLoggingConfigStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable logging whilst running the tests.
|
||||
/// </summary>
|
||||
public static void DisableLogging()
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure(DisableLoggingConfigStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse tail section into full UUID.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user