-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove unnecessary null coalescing in settings.MergeArrayHandling (#1…
- Loading branch information
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
test/OrchardCore.Tests/Abstractions/Json/Nodes/JArrayTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Text.Json.Nodes; | ||
using System.Text.Json.Settings; | ||
|
||
namespace OrchardCore.Json.Nodes.Test; | ||
|
||
public class JArrayTests | ||
{ | ||
public static IEnumerable<object[]> MergeArrayEntries => [ | ||
["[1, 2, 3, 4]", "[4, 5, 6]", null, "[1,2,3,4,4,5,6]"], | ||
["[1, 2, 3, 4]", "[4, 5, 6]", new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Concat }, "[1,2,3,4,4,5,6]"], | ||
["[1, 2, 3, 4]", "[4, 5, 6]", new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Union }, "[1,2,3,4,5,6]"], | ||
["[1, 2, 3, 4]", "[4, 5, 6]", new JsonMergeSettings() { MergeArrayHandling = MergeArrayHandling.Replace }, "[4,5,6]"] | ||
]; | ||
|
||
[Theory] | ||
[MemberData(nameof(MergeArrayEntries))] | ||
public void MergeArrayShouldRespectJsonMergeSettings(string jsonArrayContent1, string jsonArrayContent2, JsonMergeSettings mergeSettings, string expectedJsonString) | ||
{ | ||
// Arrange | ||
var array = JsonNode.Parse(jsonArrayContent1) as JsonArray; | ||
var content = JsonNode.Parse(jsonArrayContent2); | ||
|
||
// Act | ||
var result = array.Merge(content, mergeSettings); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.Equal(expectedJsonString, result.ToJsonString()); | ||
} | ||
} |