示例#1
0
        public void TestInvalidCustomFormatWithoutKeyPlaceholder()
        {
            var renderer = new AllEventPropertiesLayoutRenderer();
            var ex       = Assert.Throws <ArgumentException>(() => renderer.Format = "[key is [value]");

            Assert.Equal("Invalid format: [key] placeholder is missing.", ex.Message);
        }
示例#2
0
        public void NoProperties()
        {
            var renderer = new AllEventPropertiesLayoutRenderer();
            var ev       = new LogEventInfo();

            var result = renderer.Render(ev);

            Assert.Equal("", result);
        }
示例#3
0
        public void AllParametersAreSetToDefault()
        {
            var renderer = new AllEventPropertiesLayoutRenderer();
            var ev       = BuildLogEventWithProperties();

            var result = renderer.Render(ev);

            Assert.Equal("a=1, hello=world, 17=100", result);
        }
示例#4
0
        public void NoProperties()
        {
            var sb       = new StringBuilder();
            var renderer = new AllEventPropertiesLayoutRenderer();
            var ev       = new LogEventInfo();

            renderer.Render(sb, ev);

            Assert.Equal("", sb.ToString());
        }
示例#5
0
        public void AllParametersAreSetToDefault()
        {
            var sb       = new StringBuilder();
            var renderer = new AllEventPropertiesLayoutRenderer();
            var ev       = BuildLogEventWithProperties();

            renderer.Render(sb, ev);

            Assert.Equal("a=1, hello=world, 17=100", sb.ToString());
        }
示例#6
0
        public void CustomFormat()
        {
            var renderer = new AllEventPropertiesLayoutRenderer();

            renderer.Format = "[key] is [value]";
            var ev = BuildLogEventWithProperties();

            var result = renderer.Render(ev);

            Assert.Equal("a is 1, hello is world, 17 is 100", result);
        }
示例#7
0
        public void CustomSeparator()
        {
            var renderer = new AllEventPropertiesLayoutRenderer();

            renderer.Separator = " | ";
            var ev = BuildLogEventWithProperties();

            var result = renderer.Render(ev);

            Assert.Equal("a=1 | hello=world | 17=100", result);
        }
示例#8
0
        public void CustomFormat()
        {
            var sb       = new StringBuilder();
            var renderer = new AllEventPropertiesLayoutRenderer();

            renderer.Format = "[key] is [value]";
            var ev = BuildLogEventWithProperties();

            renderer.Render(sb, ev);

            Assert.Equal("a is 1, hello is world, 17 is 100", sb.ToString());
        }
示例#9
0
        public void CustomSeparator()
        {
            var sb       = new StringBuilder();
            var renderer = new AllEventPropertiesLayoutRenderer();

            renderer.Separator = " | ";
            var ev = BuildLogEventWithProperties();

            renderer.Render(sb, ev);

            Assert.Equal("a=1 | hello=world | 17=100", sb.ToString());
        }
示例#10
0
        public void IncludeCallerInformationEnableTest()
        {
            // Arrange
            var renderer = new AllEventPropertiesLayoutRenderer();

            Assert.False(renderer.IncludeCallerInformation);
            Assert.Equal(3, renderer.Exclude.Count);

            // Act
            renderer.IncludeCallerInformation = true;

            // Assert
            Assert.Empty(renderer.Exclude);
        }
        public void AllEventPropRendererCultureTest()
        {
            string cultureName = "de-DE";
            string expected    = "ADouble=1,23"; // with decimal comma

            var logEventInfo = CreateLogEventInfo(cultureName);

            logEventInfo.Properties["ADouble"] = 1.23;

            var    renderer = new AllEventPropertiesLayoutRenderer();
            string output   = renderer.Render(logEventInfo);

            Assert.Equal(expected, output);
        }
示例#12
0
        public void IncludeCallerInformationDisableTest()
        {
            // Arrange
            var renderer = new AllEventPropertiesLayoutRenderer()
            {
                IncludeCallerInformation = true
            };

            renderer.Exclude.Add("Test");
            Assert.Single(renderer.Exclude);

            // Act
            renderer.IncludeCallerInformation = false;

            // Assert
            Assert.Equal(4, renderer.Exclude.Count);
        }
示例#13
0
        public void IncludeEmptyValuesTest(bool?includeEmptyValues, string expected)
        {
            // Arrange
            var renderer = new AllEventPropertiesLayoutRenderer();

            if (includeEmptyValues != null)
            {
                renderer.IncludeEmptyValues = includeEmptyValues.Value;
            }

            var ev = BuildLogEventWithProperties();

            ev.Properties["empty1"]   = null;
            ev.Properties["empty2"]   = "";
            ev.Properties["notempty"] = 0;

            // Act
            var result = renderer.Render(ev);

            // Assert
            Assert.Equal(expected, result);
        }