Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }