From e7fd4c25ba932b035e03793f41d6c8bc833be58e Mon Sep 17 00:00:00 2001 From: Rolf Kristensen Date: Sat, 25 Sep 2021 23:18:53 +0200 Subject: [PATCH] Replaced SingleAsArray with OutputFormat = JsonArray + JsonDictionary --- .../Enums/AspNetRequestLayoutOutputFormat.cs | 15 ++- .../AspNetLayoutMultiValueRendererBase.cs | 101 ++++++++---------- .../AspNetRequestCookieLayoutRenderer.cs | 9 +- .../AspNetRequestHeadersLayoutRenderer.cs | 7 +- .../AspNetRequestQueryStringLayoutRenderer.cs | 3 +- .../AspNetCookieLayoutRendererTests.cs | 71 ++++++------ .../AspNetQueryStringLayoutRendererTests.cs | 14 ++- ...AspNetRequestHeadersLayoutRendererTests.cs | 45 ++++---- 8 files changed, 132 insertions(+), 133 deletions(-) diff --git a/src/Shared/Enums/AspNetRequestLayoutOutputFormat.cs b/src/Shared/Enums/AspNetRequestLayoutOutputFormat.cs index a27c71f2..1ef9fb7d 100644 --- a/src/Shared/Enums/AspNetRequestLayoutOutputFormat.cs +++ b/src/Shared/Enums/AspNetRequestLayoutOutputFormat.cs @@ -1,3 +1,5 @@ +using System; + namespace NLog.Web.Enums { /// @@ -10,9 +12,20 @@ public enum AspNetRequestLayoutOutputFormat /// Flat = 0, + /// + /// Use this format for rendering the output value as a json-array + /// + JsonArray = 1, + /// /// Use this format for rendering the output value as a json formatted string. /// - Json = 1 + [Obsolete("Replaced by JsonArray. Marked obsolete with NLog 5.0")] + Json = 1, + + /// + /// Use this format for rendering the output value as a json-dictionary + /// + JsonDictionary = 2, } } \ No newline at end of file diff --git a/src/Shared/LayoutRenderers/AspNetLayoutMultiValueRendererBase.cs b/src/Shared/LayoutRenderers/AspNetLayoutMultiValueRendererBase.cs index 95ba4a61..4acb99b8 100644 --- a/src/Shared/LayoutRenderers/AspNetLayoutMultiValueRendererBase.cs +++ b/src/Shared/LayoutRenderers/AspNetLayoutMultiValueRendererBase.cs @@ -12,45 +12,36 @@ namespace NLog.Web.LayoutRenderers /// public abstract class AspNetLayoutMultiValueRendererBase : AspNetLayoutRendererBase { - private string _itemSeparator = ","; - private Layout _itemSeparatorLayout = ","; - private string _valueSeparator = "="; - private Layout _valueSeparatorLayout = "="; - /// /// Separator between item. Only used for /// /// Render with - public string ItemSeparator - { - get => _itemSeparator; - set - { - _itemSeparator = value; - _itemSeparatorLayout = value; - } - } + public string ItemSeparator { get => _itemSeparatorLayout?.OriginalText; set => _itemSeparatorLayout = new SimpleLayout(value ?? ""); } + private SimpleLayout _itemSeparatorLayout = new SimpleLayout(","); /// /// Separator between value and key. Only used for /// /// Render with - public string ValueSeparator + public string ValueSeparator { get => _valueSeparatorLayout?.OriginalText; set => _valueSeparatorLayout = new SimpleLayout(value ?? ""); } + private SimpleLayout _valueSeparatorLayout = new SimpleLayout("="); + + /// + /// Get or set whether single key/value-pair be rendered as Json-Array. + /// + [Obsolete("Replaced by OutputFormat = JsonArray / JsonDictionary. Marked obsolete with NLog.Web ver. 5.0")] + public bool SingleAsArray { - get => _valueSeparator; + get => OutputFormat != AspNetRequestLayoutOutputFormat.JsonDictionary; set { - _valueSeparator = value; - _valueSeparatorLayout = value; + if (!value) + OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; + else if (OutputFormat == AspNetRequestLayoutOutputFormat.JsonDictionary) + OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; } } - /// - /// Single item in array? Only used for - /// Mutliple items are always in an array. - /// - public bool SingleAsArray { get; set; } = true; - /// /// Determines how the output is rendered. Possible Value: FLAT, JSON. Default is FLAT. /// @@ -61,17 +52,6 @@ public string ValueSeparator /// public bool ValuesOnly { get; set; } - /// - /// Serialize multiple key/value pairs - /// - /// The key/value pairs. - /// Add to this builder. - [Obsolete("use SerializePairs with logEvent to support Layouts for Separator. This overload will be removed in NLog.Web(aspNetCore) 5")] - protected void SerializePairs(IEnumerable> pairs, StringBuilder builder) - { - SerializePairs(pairs, builder, null); - } - /// /// Serialize multiple key/value pairs /// @@ -85,7 +65,8 @@ protected void SerializePairs(IEnumerable> pairs, S case AspNetRequestLayoutOutputFormat.Flat: SerializePairsFlat(pairs, builder, logEvent); break; - case AspNetRequestLayoutOutputFormat.Json: + case AspNetRequestLayoutOutputFormat.JsonArray: + case AspNetRequestLayoutOutputFormat.JsonDictionary: SerializePairsJson(pairs, builder); break; } @@ -94,35 +75,40 @@ protected void SerializePairs(IEnumerable> pairs, S private void SerializePairsJson(IEnumerable> pairs, StringBuilder builder) { var firstItem = true; - var pairsList = pairs.ToList(); - - if (pairsList.Count == 0) - { - return; - } - - var addArray = pairsList.Count > (SingleAsArray || ValuesOnly ? 0 : 1); - if (addArray) + foreach (var item in pairs) { - builder.Append('['); - } - - foreach (var kpv in pairsList) - { - if (!firstItem) + if (firstItem) + { + if (!ValuesOnly && OutputFormat == AspNetRequestLayoutOutputFormat.JsonDictionary) + { + builder.Append('{'); + } + else + { + builder.Append('['); + } + } + else { builder.Append(','); } - SerializePairJson(builder, kpv); + SerializePairJson(builder, item); firstItem = false; } - if (addArray) + if (!firstItem) { - builder.Append(']'); + if (!ValuesOnly && OutputFormat == AspNetRequestLayoutOutputFormat.JsonDictionary) + { + builder.Append('}'); + } + else + { + builder.Append(']'); + } } } @@ -134,7 +120,10 @@ private void SerializePairJson(StringBuilder builder, KeyValuePairExample usage of ${aspnet-request-cookie} /// /// ${aspnet-request-cookie:OutputFormat=Flat} - /// ${aspnet-request-cookie:OutputFormat=Json} - /// ${aspnet-request-cookie:OutputFormat=Json:CookieNames=username} - /// ${aspnet-request-cookie:OutputFormat=Json:Exclude=access_token} + /// ${aspnet-request-cookie:OutputFormat=JsonArray} + /// ${aspnet-request-cookie:OutputFormat=JsonDictionary} + /// ${aspnet-request-cookie:OutputFormat=JsonDictionary:CookieNames=username} + /// ${aspnet-request-cookie:OutputFormat=JsonDictionary:Exclude=access_token} /// /// [LayoutRenderer("aspnet-request-cookie")] @@ -93,7 +94,7 @@ private IEnumerable> GetCookieValues(HttpCookieColl continue; } - if (OutputFormat == AspNetRequestLayoutOutputFormat.Json) + if (OutputFormat != AspNetRequestLayoutOutputFormat.Flat) { // Split multi-valued cookie, as allowed for in the HttpCookie API for backwards compatibility with classic ASP var isFirst = true; diff --git a/src/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRenderer.cs b/src/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRenderer.cs index 50f757bb..fbb7ff3c 100644 --- a/src/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRenderer.cs +++ b/src/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRenderer.cs @@ -20,9 +20,10 @@ namespace NLog.Web.LayoutRenderers /// Example usage of ${aspnet-request-headers} /// /// ${aspnet-request-headers:OutputFormat=Flat} - /// ${aspnet-request-headers:OutputFormat=Json} - /// ${aspnet-request-headers:OutputFormat=Json:HeaderNames=username} - /// ${aspnet-request-headers:OutputFormat=Json:Exclude=access_token} + /// ${aspnet-request-headers:OutputFormat=JsonArray} + /// ${aspnet-request-headers:OutputFormat=JsonDictionary} + /// ${aspnet-request-headers:OutputFormat=JsonDictionary:HeaderNames=username} + /// ${aspnet-request-headers:OutputFormat=JsonDictionary:Exclude=access_token} /// /// [LayoutRenderer("aspnet-request-headers")] diff --git a/src/Shared/LayoutRenderers/AspNetRequestQueryStringLayoutRenderer.cs b/src/Shared/LayoutRenderers/AspNetRequestQueryStringLayoutRenderer.cs index 55c385d2..f054230d 100644 --- a/src/Shared/LayoutRenderers/AspNetRequestQueryStringLayoutRenderer.cs +++ b/src/Shared/LayoutRenderers/AspNetRequestQueryStringLayoutRenderer.cs @@ -22,7 +22,8 @@ namespace NLog.Web.LayoutRenderers /// Example usage of ${aspnet-request-querystring}: /// /// ${aspnet-request-querystring:OutputFormat=Flat} - /// ${aspnet-request-querystring:OutputFormat=Json} + /// ${aspnet-request-querystring:OutputFormat=JsonArray} + /// ${aspnet-request-querystring:OutputFormat=JsonDictionary} /// /// [LayoutRenderer("aspnet-request-querystring")] diff --git a/tests/Shared/LayoutRenderers/AspNetCookieLayoutRendererTests.cs b/tests/Shared/LayoutRenderers/AspNetCookieLayoutRendererTests.cs index 0f9bcb45..302c673e 100644 --- a/tests/Shared/LayoutRenderers/AspNetCookieLayoutRendererTests.cs +++ b/tests/Shared/LayoutRenderers/AspNetCookieLayoutRendererTests.cs @@ -12,8 +12,6 @@ using Microsoft.Extensions.Primitives; #endif - - namespace NLog.Web.Tests.LayoutRenderers { public class AspNetCookieLayoutRendererTests : TestInvolvingAspNetHttpContext @@ -59,7 +57,7 @@ public void KeyNotFoundRendersEmptyString_Flat_Formatting() public void KeyNotFoundRendersEmptyString_Json_Formatting() { var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.CookieNames = new List { "notfound" }; string result = renderer.Render(new LogEventInfo()); @@ -130,7 +128,7 @@ public void KeyFoundRendersValue_Single_Cookie_Json_Formatting() var expectedResult = "[{\"key\":\"TEST\"}]"; var renderer = CreateRenderer(addSecondCookie: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; string result = renderer.Render(new LogEventInfo()); @@ -143,24 +141,33 @@ public void KeyFoundRendersValue_Single_Cookie_Json_Formatting_no_array() var expectedResult = "{\"key\":\"TEST\"}"; var renderer = CreateRenderer(addSecondCookie: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = false; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; string result = renderer.Render(new LogEventInfo()); Assert.Equal(expectedResult, result); } - [Theory] - [InlineData(false)] - [InlineData(true)] - public void KeyFoundRendersValue_Multiple_Cookies_Json_Formatting(bool singleAsArray) + [Fact] + public void KeyFoundRendersValue_Multiple_Cookies_Json_Formatting() { var expectedResult = "[{\"key\":\"TEST\"},{\"Key1\":\"TEST1\"}]"; var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = singleAsArray; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; + + string result = renderer.Render(new LogEventInfo()); + + Assert.Equal(expectedResult, result); + } + + [Fact] + public void KeyFoundRendersValue_Multiple_Cookies_Json_Formatting_no_array() + { + var expectedResult = "{\"key\":\"TEST\",\"Key1\":\"TEST1\"}"; + + var renderer = CreateRenderer(); + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; string result = renderer.Render(new LogEventInfo()); @@ -184,7 +191,7 @@ public void KeyNotFoundRendersEmptyString_Flat_Formatting_ValuesOnly() public void KeyNotFoundRendersEmptyString_Json_Formatting_ValuesOnly() { var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.CookieNames = new List { "notfound" }; renderer.ValuesOnly = true; @@ -234,30 +241,15 @@ public void KeyFoundRendersValue_Single_Item_Flat_Formatting_ValuesOnly() Assert.Equal(expectedResult, result); } - [Fact] - public void KeyFoundRendersValue_Single_Item_Json_Formatting_ValuesOnly() - { - var expectedResult = "[\"TEST\"]"; - - var renderer = CreateRenderer(addSecondCookie: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.ValuesOnly = true; - - string result = renderer.Render(new LogEventInfo()); - - Assert.Equal(expectedResult, result); - } - - [Fact] - public void KeyFoundRendersValue_Single_Item_Json_Formatting_no_array_ValuesOnly() + [Theory] + [InlineData(AspNetRequestLayoutOutputFormat.JsonArray)] + [InlineData(AspNetRequestLayoutOutputFormat.JsonDictionary)] + public void KeyFoundRendersValue_Single_Item_JsonArray_Formatting_ValuesOnly(AspNetRequestLayoutOutputFormat outputFormat) { - // With ValuesOnly enabled, only arrays are valid var expectedResult = "[\"TEST\"]"; var renderer = CreateRenderer(addSecondCookie: false); - - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = false; + renderer.OutputFormat = outputFormat; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo()); @@ -266,16 +258,15 @@ public void KeyFoundRendersValue_Single_Item_Json_Formatting_no_array_ValuesOnly } [Theory] - [InlineData(false)] - [InlineData(true)] - public void KeyFoundRendersValue_Cookie_Multiple_Items_Json_Formatting_ValuesOnly(bool singleAsArray) + [InlineData(AspNetRequestLayoutOutputFormat.JsonArray)] + [InlineData(AspNetRequestLayoutOutputFormat.JsonDictionary)] + public void KeyFoundRendersValue_Multiple_Items_Json_Formatting_ValuesOnly(AspNetRequestLayoutOutputFormat outputFormat) { var expectedResult = "[\"TEST\",\"TEST1\"]"; var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = singleAsArray; + renderer.OutputFormat = outputFormat; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo()); @@ -304,7 +295,7 @@ public void KeyFoundRendersValue_Multiple_Cookies_And_Cookie_Values_Json_Formatt { var expectedResult = "[{\"key\":\"TEST\"},{\"Key1\":\"TEST1\"},{\"key2\":\"Test\"},{\"key3\":\"Test456\"}]"; var renderer = CreateRenderer(addSecondCookie: true, addMultiValueCookieKey: true); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; string result = renderer.Render(new LogEventInfo()); @@ -347,7 +338,7 @@ public void CommaSeperatedCookieNamesTest_Multiple_Cookie_Values_Json_Formatting var layoutRender = new AspNetRequestCookieLayoutRenderer() { CookieNames = new List { "key", "key1" }, - OutputFormat = AspNetRequestLayoutOutputFormat.Json + OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray }; var httpContextAccessorMock = CreateHttpContextAccessorMockWithCookie(cookie); diff --git a/tests/Shared/LayoutRenderers/AspNetQueryStringLayoutRendererTests.cs b/tests/Shared/LayoutRenderers/AspNetQueryStringLayoutRendererTests.cs index 3b55c7f2..91128e8e 100644 --- a/tests/Shared/LayoutRenderers/AspNetQueryStringLayoutRendererTests.cs +++ b/tests/Shared/LayoutRenderers/AspNetQueryStringLayoutRendererTests.cs @@ -53,7 +53,7 @@ public void KeyNotFoundRendersEmptyString_Json_Formatting() var renderer = CreateAndMockRenderer(CreateTuple("Id", "1")); renderer.QueryStringKeys = new List { "key" }; - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; string result = renderer.Render(new LogEventInfo()); @@ -83,7 +83,7 @@ public void KeyFoundRendersValue_QueryString_Single_Item_Json_Formatting() var renderer = CreateAndMockRenderer(CreateTuple("Id", "1")); renderer.QueryStringKeys = new List { "Id" }; - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; string result = renderer.Render(new LogEventInfo()); @@ -152,14 +152,12 @@ public void MultipleValuesForOneKeyShouldWork() [Fact] public void MultipleValuesJsonQuoted() { - var expectedResult = @"{""Id"":""a'b,\""c\""""}"; var renderer = CreateAndMockRenderer(CreateTuple("Id", "a'b", "\"c\"")); renderer.QueryStringKeys = null; - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = false; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; string result = renderer.Render(new LogEventInfo()); @@ -174,7 +172,7 @@ public void KeyFoundRendersValue_QueryString_Multiple_Item_Json_Formatting() var renderer = CreateAndMockRenderer(CreateTuple("Id", "1"), CreateTuple("Id2", "2")); renderer.QueryStringKeys = new List { "Id", "Id2" }; - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; string result = renderer.Render(new LogEventInfo()); @@ -205,7 +203,7 @@ public void KeyFoundRendersValue_QueryString_Single_Item_Json_Formatting_ValuesO var renderer = CreateAndMockRenderer(CreateTuple("Id", "1")); renderer.QueryStringKeys = new List { "Id" }; - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo()); @@ -237,7 +235,7 @@ public void KeyFoundRendersValue_QueryString_Multiple_Item_Json_Formatting_Value var renderer = CreateAndMockRenderer(CreateTuple("Id", "1"), CreateTuple("Id2", "2")); renderer.QueryStringKeys = new List { "Id", "Id2" }; - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo()); diff --git a/tests/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRendererTests.cs b/tests/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRendererTests.cs index 9fce3dfc..6aa5aa52 100644 --- a/tests/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRendererTests.cs +++ b/tests/Shared/LayoutRenderers/AspNetRequestHeadersLayoutRendererTests.cs @@ -57,7 +57,7 @@ public void KeyNotFoundRendersEmptyString_Flat_Formatting() public void KeyNotFoundRendersEmptyString_Json_Formatting() { var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.HeaderNames = new List { "notfound" }; string result = renderer.Render(new LogEventInfo()); @@ -128,7 +128,7 @@ public void KeyFoundRendersValue_Single_Header_Json_Formatting() var expectedResult = "[{\"key\":\"TEST\"}]"; var renderer = CreateRenderer(addSecondHeader: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; string result = renderer.Render(new LogEventInfo()); @@ -141,24 +141,33 @@ public void KeyFoundRendersValue_Single_Header_Json_Formatting_no_array() var expectedResult = "{\"key\":\"TEST\"}"; var renderer = CreateRenderer(addSecondHeader: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = false; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; string result = renderer.Render(new LogEventInfo()); Assert.Equal(expectedResult, result); } - [Theory] - [InlineData(false)] - [InlineData(true)] - public void KeyFoundRendersValue_Multiple_Headers_Json_Formatting(bool singleAsArray) + [Fact] + public void KeyFoundRendersValue_Multiple_Headers_Json_Formatting() { var expectedResult = "[{\"key\":\"TEST\"},{\"Key1\":\"TEST1\"}]"; var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = singleAsArray; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; + + string result = renderer.Render(new LogEventInfo()); + + Assert.Equal(expectedResult, result); + } + + [Fact] + public void KeyFoundRendersValue_Multiple_Headers_Json_Formatting_no_array() + { + var expectedResult = "{\"key\":\"TEST\",\"Key1\":\"TEST1\"}"; + + var renderer = CreateRenderer(); + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; string result = renderer.Render(new LogEventInfo()); @@ -182,7 +191,7 @@ public void KeyNotFoundRendersEmptyString_Flat_Formatting_ValuesOnly() public void KeyNotFoundRendersEmptyString_Json_Formatting_ValuesOnly() { var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.HeaderNames = new List { "notfound" }; renderer.ValuesOnly = true; @@ -238,7 +247,7 @@ public void KeyFoundRendersValue_Single_Item_Json_Formatting_ValuesOnly() var expectedResult = "[\"TEST\"]"; var renderer = CreateRenderer(addSecondHeader: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonArray; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo()); @@ -254,8 +263,7 @@ public void KeyFoundRendersValue_Single_Item_Json_Formatting_no_array_ValuesOnly var renderer = CreateRenderer(addSecondHeader: false); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = false; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo()); @@ -263,17 +271,14 @@ public void KeyFoundRendersValue_Single_Item_Json_Formatting_no_array_ValuesOnly Assert.Equal(expectedResult, result); } - [Theory] - [InlineData(false)] - [InlineData(true)] - public void KeyFoundRendersValue_Header_Multiple_Items_Json_Formatting_ValuesOnly(bool singleAsArray) + [Fact] + public void KeyFoundRendersValue_Header_Multiple_Items_Json_Formatting_ValuesOnly() { var expectedResult = "[\"TEST\",\"TEST1\"]"; var renderer = CreateRenderer(); - renderer.OutputFormat = AspNetRequestLayoutOutputFormat.Json; - renderer.SingleAsArray = singleAsArray; + renderer.OutputFormat = AspNetRequestLayoutOutputFormat.JsonDictionary; renderer.ValuesOnly = true; string result = renderer.Render(new LogEventInfo());