public void LogErrorTest() { var source = "source"; var message = "message"; var writer = new Mock <IOutputWriter>(); var logger = new ConsoleLoggingService(writer.Object); logger.LogError(source, message); var expectedLog1 = "Error from " + source + ": " + message; writer.Verify(w => w.WriteLine(It.Is <string>(s => s == expectedLog1)), Times.Once); }
public void LogErrorWithExceptionTest() { var source = "source"; var message = "message"; var exception = new Exception("exception"); var writer = new Mock <IOutputWriter>(); var logger = new ConsoleLoggingService(writer.Object); logger.LogError(source, message, exception); var expectedLog1 = "Error 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); }