mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-08 05:51:47 -07:00
Moved source code under src folder - massive change
This commit is contained in:
parent
2fc8123d6b
commit
5bf0e197ec
1499 changed files with 1054 additions and 1444 deletions
57
src/NzbDrone.Test.Common/LoggingTest.cs
Normal file
57
src/NzbDrone.Test.Common/LoggingTest.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Common.EnvironmentInfo;
|
||||
|
||||
namespace NzbDrone.Test.Common
|
||||
{
|
||||
public abstract class LoggingTest
|
||||
{
|
||||
protected static Logger TestLogger;
|
||||
|
||||
protected static void InitLogging()
|
||||
{
|
||||
new StartupArguments();
|
||||
|
||||
TestLogger = LogManager.GetLogger("TestLogger");
|
||||
|
||||
if (LogManager.Configuration == null || LogManager.Configuration is XmlLoggingConfiguration)
|
||||
{
|
||||
LogManager.Configuration = new LoggingConfiguration();
|
||||
var consoleTarget = new ConsoleTarget { Layout = "${level}: ${message} ${exception}" };
|
||||
LogManager.Configuration.AddTarget(consoleTarget.GetType().Name, consoleTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Info, consoleTarget));
|
||||
|
||||
RegisterExceptionVerification();
|
||||
}
|
||||
}
|
||||
|
||||
private static void RegisterExceptionVerification()
|
||||
{
|
||||
var exceptionVerification = new ExceptionVerification();
|
||||
LogManager.Configuration.AddTarget("ExceptionVerification", exceptionVerification);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Warn, exceptionVerification));
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void LoggingTestSetup()
|
||||
{
|
||||
InitLogging();
|
||||
ExceptionVerification.Reset();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void LoggingDownBase()
|
||||
{
|
||||
|
||||
|
||||
//can't use because of a bug in mono with 2.6.2,
|
||||
//https://bugs.launchpad.net/nunitv2/+bug/1076932
|
||||
if (BuildInfo.IsDebug && TestContext.CurrentContext.Result.State == TestState.Success)
|
||||
{
|
||||
ExceptionVerification.AssertNoUnexcpectedLogs();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue