Пример #1
0
        public void DoMoreLogsFormat_NotCheckingNested()
        {
            // Arrange
            var loggerFactory = TestLoggerFactory.Create(options => options.FilterByTypeName <More>());
            var sampleLogger  = loggerFactory.CreateLogger <Sample>();
            var moreLogger    = loggerFactory.CreateLogger <More>();
            var more          = new More(new Sample(sampleLogger), moreLogger);

            // Act
            more.DoMore();

            // Assert
            var log = Assert.Single(loggerFactory.Sink.LogEntries);

            Assert.Equal("More is less.", log.OriginalFormat);
        }
Пример #2
0
        public void DoMoreLogsMessage()
        {
            // Arrange
            var loggerFactory = TestLoggerFactory.Create();
            var sampleLogger  = loggerFactory.CreateLogger <Sample>();
            var moreLogger    = loggerFactory.CreateLogger <More>();
            var more          = new More(new Sample(sampleLogger), moreLogger);

            // Act
            more.DoMore();

            // Assert
            Assert.Collection(loggerFactory.Sink.LogEntries,
                              l => Assert.Equal("More is less.", l.Message),
                              l => Assert.Equal("The answer is 42", l.Message));
        }
Пример #3
0
        public void DoMoreLogsMessage_NotCheckingNested()
        {
            // Arrange
            var loggerFactory = MELTBuilder.CreateLoggerFactory(options => options.FilterByTypeName <More>());
            var sampleLogger  = loggerFactory.CreateLogger <Sample>();
            var moreLogger    = loggerFactory.CreateLogger <More>();
            var more          = new More(new Sample(sampleLogger), moreLogger);

            // Act
            more.DoMore();

            // Assert
            var log = Assert.Single(loggerFactory.LogEntries);

            Assert.Equal("More is less.", log.Message);
        }