Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="aweXpect" Version="2.27.1"/>
<PackageVersion Include="aweXpect.Core" Version="2.25.1"/>
<PackageVersion Include="aweXpect" Version="2.31.0"/>
<PackageVersion Include="aweXpect.Core" Version="2.28.0"/>
<PackageVersion Include="System.Text.Json" Version="9.0.2"/>
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Source/aweXpect.Json/Helpers/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
{
if (lines[l][i] != commonWhiteSpace[i])
{
commonWhiteSpace = commonWhiteSpace[..i];
commonWhiteSpace = commonWhiteSpace.Substring(0, i);
break;
}
}
Expand All @@ -50,7 +50,7 @@
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));

Check warning on line 53 in Source/aweXpect.Json/Helpers/StringExtensions.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer 'AsSpan' over 'Substring' when span-based overloads are available

See more on https://sonarcloud.io/project/issues?id=Testably_aweXpect.Json&issues=AZ396Gyj71kMwf0-QYbb&open=AZ396Gyj71kMwf0-QYbb&pullRequest=118
}

return sb.ToString();
Expand Down
2 changes: 1 addition & 1 deletion Source/aweXpect.Json/Json/ExpectationJsonConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
{
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) &&

Check warning on line 46 in Source/aweXpect.Json/Json/ExpectationJsonConverter.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer 'AsSpan' over 'Substring' when span-based overloads are available

See more on https://sonarcloud.io/project/issues?id=Testably_aweXpect.Json&issues=AZ396Guq71kMwf0-QYba&open=AZ396Guq71kMwf0-QYba&pullRequest=118
_expectations.TryGetValue(guid, out Expectation? expectation) &&
expectation is IOptionsProvider<ExpectationBuilder>
{
Expand Down
2 changes: 1 addition & 1 deletion Source/aweXpect.Json/Json/JsonMatchType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task<bool>
}

/// <inheritdoc cref="IStringMatchType.GetExpectation(string?, ExpectationGrammars)" />
public string GetExpectation(string? expected, ExpectationGrammars grammar)
public string GetExpectation(string? expected, ExpectationGrammars grammars)
=> $"is JSON equivalent to {expected}";

/// <inheritdoc cref="IStringMatchType.GetTypeString()" />
Expand Down
3 changes: 3 additions & 0 deletions Tests/aweXpect.Json.Tests/Json/CustomizeJsonTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Expected that jsonWithTrailingCommas

Actual:
[1, 2,]

Expected:
[1, 2]
""");
}

Expand Down
30 changes: 30 additions & 0 deletions Tests/aweXpect.Json.Tests/ThatJsonString.IsEqualTo.AsJson.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ but it differed as
"foo11": null,
"foo12": null,
}

Expected:
{}
""");
}

Expand Down Expand Up @@ -150,6 +153,9 @@ but it differed as
"foo11": null,
"foo12": null,
}

Expected:
{}
""");
}

Expand All @@ -175,6 +181,9 @@ Expected that subject

Actual:
{}

Expected:
{{expected}}
""");
}

Expand Down Expand Up @@ -249,6 +258,13 @@ but it differed as

Actual:
{ "foo": 1.1, "bar": "baz", "something": "else" }

Expected:
{
"foo": 2.1,
"bar": "bart",
"baz": true
}
""");
}

Expand Down Expand Up @@ -293,6 +309,11 @@ but it differed as $.bar had unexpected "xyz"

Actual:
{ "foo": 1, "bar" : "xyz" }

Expected:
{
"foo": 1
}
""");
}

Expand All @@ -319,6 +340,9 @@ but it differed as

Actual:
[1, 2]

Expected:
[1,2,3,4]
""");
}

Expand Down Expand Up @@ -349,6 +373,9 @@ but it differed as
{
"foo": [1, 2, 3, 4]
}

Expected:
{"foo":[1,2]}
""");
}

Expand All @@ -374,6 +401,9 @@ Expected that subject

Actual:
{{subject}}

Expected:
{}
""");
}

Expand Down
Loading