diff --git a/Directory.Packages.props b/Directory.Packages.props index 3d31214..84bec70 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,8 +3,8 @@ true - - + + diff --git a/Source/aweXpect.Json/Helpers/StringExtensions.cs b/Source/aweXpect.Json/Helpers/StringExtensions.cs index db8bfc9..1dbcd68 100644 --- a/Source/aweXpect.Json/Helpers/StringExtensions.cs +++ b/Source/aweXpect.Json/Helpers/StringExtensions.cs @@ -40,7 +40,7 @@ public static string TrimCommonWhiteSpace(this string value) { if (lines[l][i] != commonWhiteSpace[i]) { - commonWhiteSpace = commonWhiteSpace[..i]; + commonWhiteSpace = commonWhiteSpace.Substring(0, i); break; } } @@ -50,7 +50,7 @@ public static string TrimCommonWhiteSpace(this string value) sb.Append(lines[0]); foreach (string? line in lines.Skip(1)) { - sb.Append('\n').Append(line[commonWhiteSpace.Length..]); + sb.Append('\n').Append(line.Substring(commonWhiteSpace.Length)); } return sb.ToString(); diff --git a/Source/aweXpect.Json/Json/ExpectationJsonConverter.cs b/Source/aweXpect.Json/Json/ExpectationJsonConverter.cs index 4d799d3..0c96f9a 100644 --- a/Source/aweXpect.Json/Json/ExpectationJsonConverter.cs +++ b/Source/aweXpect.Json/Json/ExpectationJsonConverter.cs @@ -43,7 +43,7 @@ public bool TryGetExpectation(JsonElement element, { string? value = element.GetString(); if (value?.StartsWith(Prefix) == true && - Guid.TryParse(value[Prefix.Length..], out Guid guid) && + Guid.TryParse(value.Substring(Prefix.Length), out Guid guid) && _expectations.TryGetValue(guid, out Expectation? expectation) && expectation is IOptionsProvider { diff --git a/Source/aweXpect.Json/Json/JsonMatchType.cs b/Source/aweXpect.Json/Json/JsonMatchType.cs index ab33e11..ba7a334 100644 --- a/Source/aweXpect.Json/Json/JsonMatchType.cs +++ b/Source/aweXpect.Json/Json/JsonMatchType.cs @@ -85,7 +85,7 @@ public async Task } /// - public string GetExpectation(string? expected, ExpectationGrammars grammar) + public string GetExpectation(string? expected, ExpectationGrammars grammars) => $"is JSON equivalent to {expected}"; /// diff --git a/Tests/aweXpect.Json.Tests/Json/CustomizeJsonTests.cs b/Tests/aweXpect.Json.Tests/Json/CustomizeJsonTests.cs index 8429fdd..a087252 100644 --- a/Tests/aweXpect.Json.Tests/Json/CustomizeJsonTests.cs +++ b/Tests/aweXpect.Json.Tests/Json/CustomizeJsonTests.cs @@ -28,6 +28,9 @@ Expected that jsonWithTrailingCommas Actual: [1, 2,] + + Expected: + [1, 2] """); } diff --git a/Tests/aweXpect.Json.Tests/ThatJsonString.IsEqualTo.AsJson.Tests.cs b/Tests/aweXpect.Json.Tests/ThatJsonString.IsEqualTo.AsJson.Tests.cs index 9bb4bde..21fec50 100644 --- a/Tests/aweXpect.Json.Tests/ThatJsonString.IsEqualTo.AsJson.Tests.cs +++ b/Tests/aweXpect.Json.Tests/ThatJsonString.IsEqualTo.AsJson.Tests.cs @@ -96,6 +96,9 @@ but it differed as "foo11": null, "foo12": null, } + + Expected: + {} """); } @@ -150,6 +153,9 @@ but it differed as "foo11": null, "foo12": null, } + + Expected: + {} """); } @@ -175,6 +181,9 @@ Expected that subject Actual: {} + + Expected: + {{expected}} """); } @@ -249,6 +258,13 @@ but it differed as Actual: { "foo": 1.1, "bar": "baz", "something": "else" } + + Expected: + { + "foo": 2.1, + "bar": "bart", + "baz": true + } """); } @@ -293,6 +309,11 @@ but it differed as $.bar had unexpected "xyz" Actual: { "foo": 1, "bar" : "xyz" } + + Expected: + { + "foo": 1 + } """); } @@ -319,6 +340,9 @@ but it differed as Actual: [1, 2] + + Expected: + [1,2,3,4] """); } @@ -349,6 +373,9 @@ but it differed as { "foo": [1, 2, 3, 4] } + + Expected: + {"foo":[1,2]} """); } @@ -374,6 +401,9 @@ Expected that subject Actual: {{subject}} + + Expected: + {} """); }