Пример #1
0
        public void LogSomething_Should_Log_Expected_Messages()
        {
            // Arrange
            var loggerMock           = new Mock <ILogger <LoggingController> >();
            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.Now).Returns(new DateTime(2020, 10, 13, 10, 0, 0));
            var sut = new LoggingController(loggerMock.Object, dateTimeProviderMock.Object);

            // Act
            sut.LogSomething();

            // Assert
            loggerMock.VerifyLogging("Something", LogLevel.Information)
            .VerifyLogging("Log something called in 10/13/2020 10:00:00", LogLevel.Warning);
        }