示例#1
0
        public void TraceLogsMessageWithScope()
        {
            // 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.Trace();

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

            Assert.Equal("This log entry is at trace level", log.Message);
            LoggingAssert.Contains("level", "trace", log.Properties);
            var scope = Assert.Single(log.Scopes);

            LoggingAssert.Contains("foo", "bar", scope.Properties);
        }