コード例 #1
0
        public void TestLogException()
        {
            // arrange
            var loggerMock = LoggerUtils.LoggerMock <MyHandler>();
            var handler    = new MyHandler(loggerMock.Object);
            var expected   = "Hello exception";

            // act
            var exception = Assert.Throws <Exception>(() => handler.LogException(expected));

            // assert
            loggerMock.VerifyLog(LogLevel.Error, expected);
        }
コード例 #2
0
        public void TestLogWarning()
        {
            // arrange
            var loggerMock = LoggerUtils.LoggerMock <MyHandler>();
            var handler    = new MyHandler(loggerMock.Object);
            var expected   = "Hello warning";

            // act
            handler.LogWarning(expected);

            // assert
            loggerMock.VerifyLog(LogLevel.Warning, expected);
        }
コード例 #3
0
        public void TestLogError()
        {
            // arrange
            var loggerMock = LoggerUtils.LoggerMock <MyHandler>();
            var handler    = new MyHandler(loggerMock.Object);
            var expected   = "Hello error";

            // act
            handler.LogError(expected);

            // assert
            loggerMock.VerifyLog(LogLevel.Error, expected);
        }
コード例 #4
0
        public void TestLogInformation()
        {
            // arrange
            var loggerMock = LoggerUtils.LoggerMock <MyHandler>();
            var handler    = new MyHandler(loggerMock.Object);
            var expected   = "Hello information";

            // act
            handler.LogInformation(expected);

            // assert
            loggerMock.VerifyLog(LogLevel.Information, expected);
        }