2011-10-24 08:54:09 +03:00
|
|
|
using NLog;
|
|
|
|
using NLog.Config;
|
2011-11-13 10:27:16 +03:00
|
|
|
using NUnit.Framework;
|
2011-10-24 08:54:09 +03:00
|
|
|
using NzbDrone.Common;
|
|
|
|
|
|
|
|
namespace NzbDrone.Test.Common
|
|
|
|
{
|
2011-11-03 08:04:14 +03:00
|
|
|
public abstract class LoggingTest
|
2011-10-24 08:54:09 +03:00
|
|
|
{
|
2011-11-03 08:04:14 +03:00
|
|
|
protected static void InitLogging()
|
2011-10-24 08:54:09 +03:00
|
|
|
{
|
2011-11-08 10:01:52 +03:00
|
|
|
if (LogManager.Configuration == null || LogManager.Configuration is XmlLoggingConfiguration)
|
|
|
|
{
|
|
|
|
LogManager.Configuration = new LoggingConfiguration();
|
|
|
|
LogConfiguration.RegisterConsoleLogger(LogLevel.Trace);
|
|
|
|
LogConfiguration.RegisterUdpLogger();
|
2011-10-24 08:54:09 +03:00
|
|
|
|
2011-11-08 10:01:52 +03:00
|
|
|
RegisterExceptionVerification();
|
2011-11-13 10:27:16 +03:00
|
|
|
LogConfiguration.Reload();
|
2011-11-08 10:01:52 +03:00
|
|
|
}
|
2011-10-24 08:54:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void RegisterExceptionVerification()
|
|
|
|
{
|
|
|
|
var exceptionVerification = new ExceptionVerification();
|
|
|
|
LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, exceptionVerification));
|
2011-11-13 10:27:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void LoggingTestSetup()
|
|
|
|
{
|
|
|
|
InitLogging();
|
|
|
|
ExceptionVerification.Reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
public void LoggingDownBase()
|
|
|
|
{
|
|
|
|
ExceptionVerification.AssertNoUnexcpectedLogs();
|
2011-10-24 08:54:09 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|