public void LogWarningTest() { var source = "source"; var message = "message"; var writer = new Mock <IOutputWriter>(); var logger = new ConsoleLoggingService(writer.Object); logger.LogWarning(source, message); var expectedLog1 = "Warning from " + source + ": " + message; writer.Verify(w => w.WriteLine(It.Is <string>(s => s == expectedLog1)), Times.Once); }
public void LogWarningWithExceptionTest() { var source = "source"; var message = "message"; var exception = new Exception("exception"); var writer = new Mock <IOutputWriter>(); var logger = new ConsoleLoggingService(writer.Object); logger.LogWarning(source, message, exception); var expectedLog1 = "Warning from " + source + ": " + message; var expectedLog2 = "Exception logged: " + exception.Message; writer.Verify(w => w.WriteLine(It.Is <string>(s => s == expectedLog1)), Times.Once); writer.Verify(w => w.WriteLine(It.Is <string>(s => s == expectedLog2)), Times.Once); }