public void ErrorLogsAppropriateMessage() { //given var target = new DefaultLogger(LogLevel.DEBUG, writeLineAction); // when target.Error("Error message"); // then Assert.That(logOutputLines.Count, Is.EqualTo(1)); Assert.That(Regex.IsMatch(logOutputLines[0], $"^{LoggerDateTimePattern} ERROR \\[.+?\\] Error 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); }