예제 #1
0
        public void TestClearContextClearsOnlyPropertyKeysProperties()
        {
            var logContext = new LogContext();
            var logger = new Logger();

            foreach (var propertyKeyField in LogContext.PropertyKey.Fields)
            {
                var propertyKey = propertyKeyField.GetValue(logContext) as string;
                logContext.Properties[propertyKey] = propertyKey;
            }

            logger.SetContext(logContext);
            logger.SetProperty("k1", "v1");
            logger.ClearContext();

            Assert.Equal(1, logger.Properties.Count);
            Assert.Equal("v1", logger.GetProperty("k1"));
        }