/// <summary> /// This will assert that the log levels work /// </summary> private static void AssertLogLevels(LogSource logSource, ILogger loggerUnderTest) { var initialLevel = loggerUnderTest.LogLevel; try { // Assert the log levels loggerUnderTest.LogLevel = LogLevels.None; Assert.False(logSource.IsVerboseEnabled()); Assert.False(logSource.IsDebugEnabled()); Assert.False(logSource.IsInfoEnabled()); Assert.False(logSource.IsWarnEnabled()); Assert.False(logSource.IsErrorEnabled()); Assert.False(logSource.IsFatalEnabled()); loggerUnderTest.LogLevel = LogLevels.Verbose; Assert.True(logSource.IsVerboseEnabled()); Assert.True(logSource.IsDebugEnabled()); Assert.True(logSource.IsInfoEnabled()); Assert.True(logSource.IsWarnEnabled()); Assert.True(logSource.IsErrorEnabled()); Assert.True(logSource.IsFatalEnabled()); loggerUnderTest.LogLevel = LogLevels.Debug; Assert.False(logSource.IsVerboseEnabled()); Assert.True(logSource.IsDebugEnabled()); Assert.True(logSource.IsInfoEnabled()); Assert.True(logSource.IsWarnEnabled()); Assert.True(logSource.IsErrorEnabled()); Assert.True(logSource.IsFatalEnabled()); loggerUnderTest.LogLevel = LogLevels.Info; Assert.False(logSource.IsVerboseEnabled()); Assert.False(logSource.IsDebugEnabled()); Assert.True(logSource.IsInfoEnabled()); Assert.True(logSource.IsWarnEnabled()); Assert.True(logSource.IsErrorEnabled()); Assert.True(logSource.IsFatalEnabled()); loggerUnderTest.LogLevel = LogLevels.Warn; Assert.False(logSource.IsVerboseEnabled()); Assert.False(logSource.IsDebugEnabled()); Assert.False(logSource.IsInfoEnabled()); Assert.True(logSource.IsWarnEnabled()); Assert.True(logSource.IsErrorEnabled()); Assert.True(logSource.IsFatalEnabled()); loggerUnderTest.LogLevel = LogLevels.Error; Assert.False(logSource.IsVerboseEnabled()); Assert.False(logSource.IsDebugEnabled()); Assert.False(logSource.IsInfoEnabled()); Assert.False(logSource.IsWarnEnabled()); Assert.True(logSource.IsErrorEnabled()); Assert.True(logSource.IsFatalEnabled()); loggerUnderTest.LogLevel = LogLevels.Fatal; Assert.False(logSource.IsVerboseEnabled()); Assert.False(logSource.IsDebugEnabled()); Assert.False(logSource.IsInfoEnabled()); Assert.False(logSource.IsWarnEnabled()); Assert.False(logSource.IsErrorEnabled()); Assert.True(logSource.IsFatalEnabled()); } finally { loggerUnderTest.LogLevel = initialLevel; } }
public void IsLevelEnabled() { _logSource.IsFatalEnabled(); }