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); }
public void NoProperties() { var renderer = new AllEventPropertiesLayoutRenderer(); var ev = new LogEventInfo(); var result = renderer.Render(ev); Assert.Equal("", result); }
public void AllParametersAreSetToDefault() { var renderer = new AllEventPropertiesLayoutRenderer(); var ev = BuildLogEventWithProperties(); var result = renderer.Render(ev); Assert.Equal("a=1, hello=world, 17=100", result); }
public void NoProperties() { var sb = new StringBuilder(); var renderer = new AllEventPropertiesLayoutRenderer(); var ev = new LogEventInfo(); renderer.Render(sb, ev); Assert.Equal("", sb.ToString()); }
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()); }
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); }
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); }
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()); }
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()); }
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); }
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); }
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); }