public void DefaultLoggerWithoutVerboseOutputWritesDebugLevelMessages() { //given DefaultLogger log = new DefaultLogger(false); //then Assert.That(log.IsDebugEnabled, Is.False); }
public void DefaultLoggerWithVerboseOutputWritesInfoLevelMessages() { //given DefaultLogger log = new DefaultLogger(true); //then Assert.That(log.IsInfoEnabled, Is.True); }
public void InfoDoesNotLogIfLogLevelInfoIsDisabled() { //given var target = new DefaultLogger(LogLevel.WARN, writeLineAction); // when target.Info("Info message"); // then Assert.That(logOutputLines, Is.Empty); }
public void InfoDoesNotLogIfLogLevelDebugIsDisabled() { //given var target = new DefaultLogger(LogLevel.INFO, writeLineAction); // when target.Debug("Debug message"); // then Assert.That(logOutputLines, Is.Empty); }
public void DebugDoesNotLogIfVerboseIsDisabled() { //given var target = new DefaultLogger(false, writeLineAction); // when target.Debug("Debug message"); // then Assert.That(logOutputLines, Is.Empty); }
public void InfoLogsAppropriateMessage() { //given var target = new DefaultLogger(LogLevel.DEBUG, writeLineAction); // when target.Info("Info message"); // then Assert.That(logOutputLines.Count, Is.EqualTo(1)); Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} INFO \\[.+?\\] Info message$"), Is.True); }
public void WarningLogsAppropriateMessage() { //given var target = new DefaultLogger(true, writeLineAction); // when target.Warn("Warning message"); // then Assert.That(logOutputLines.Count, Is.EqualTo(1)); Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} WARN \\[.+?\\] Warning message$"), Is.True); }
public void ErrorWithStacktraceLogsAppropriateMessage() { //given var exception = new Exception("test exception"); var target = new DefaultLogger(LogLevel.DEBUG, writeLineAction); // when target.Error("Error message", exception); // then Assert.That(logOutputLines.Count, Is.EqualTo(1)); Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} ERROR \\[.+?\\] Error message(\n|\r|\r\n){Regex.Escape(exception.ToString())}$", RegexOptions.Singleline), Is.True); }