Exemplo n.º 1
0
        public void Can_open_mapped_diagnostics_context_not_destructured()
        {
            var context = new MyMappedContext();

            using (_logProvider.OpenMappedContext("key", context, false))
            {
                _sut.Info("m");

                _target.Logs[0].ShouldBe("INFO||World|m|");
            }
        }
        public void Can_open_mapped_diagnostics_context_not_destructured()
        {
            var context = new MyMappedContext();

            using (_logProvider.OpenMappedContext("key", context, false))
            {
                _sut.Info("m");

                _logEvent.Properties.Keys.ShouldContain("key");
                _logEvent.Properties["key"].ToString().ShouldBe("\"World\"");
            }
        }
        public void Can_open_mapped_diagnostics_context_destructured()
        {
            var context = new MyMappedContext();

            using (_logProvider.OpenMappedContext("key", context, true))
            {
                _sut.Info("m");

                _logEvent.Properties.Keys.ShouldContain("key");
                _logEvent.Properties["key"].ToString().ShouldBe("MyMappedContext { ThirtySeven: 37, Name: \"World\", Level: Trace }");
            }
        }
Exemplo n.º 4
0
        public void Can_open_mapped_diagnostics_context_not_destructured()
        {
            var context = new MyMappedContext();

            using (_logProvider.OpenMappedContext("key", context, false))
            {
                _sut.Info("m");
                var loggingEvent = _memoryAppender.GetEvents().Single();

                loggingEvent.Properties.GetKeys().ShouldContain("key");
                loggingEvent.Properties["key"].ShouldBe("World");
            }
        }