Compare commits

..

2 Commits

Author SHA1 Message Date
dependabot[bot] 6912d52faf Bump System.Text.RegularExpressions from 4.3.0 to 4.3.1 (#1466)
---
updated-dependencies:
- dependency-name: System.Text.RegularExpressions
  dependency-version: 4.3.1
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-05-29 20:53:08 +02:00
dependabot[bot] 3685fccfaf Bump System.Net.Http from 4.3.0 to 4.3.4 (#1467)
---
updated-dependencies:
- dependency-name: System.Net.Http
  dependency-version: 4.3.4
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-05-29 20:40:44 +02:00
5 changed files with 13 additions and 272 deletions
@@ -12,6 +12,8 @@
<PackageReference Include="Aspire.Hosting.Testing" Version="13.1.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
</ItemGroup>
@@ -32,11 +32,6 @@ public class JsonMatcher : IJsonMatcher
/// </summary>
public bool Regex { get; }
/// <summary>
/// Ignore array order when comparing
/// </summary>
public bool IgnoreArrayOrder { get; }
private readonly JToken _valueAsJToken;
/// <summary>
@@ -45,8 +40,7 @@ public class JsonMatcher : IJsonMatcher
/// <param name="value">The string value to check for equality.</param>
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
/// <param name="regex">Support Regex.</param>
/// <param name="ignoreArrayOrder">Ignore array element order when comparing.</param>
public JsonMatcher(string value, bool ignoreCase = false, bool regex = false, bool ignoreArrayOrder = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex, ignoreArrayOrder)
public JsonMatcher(string value, bool ignoreCase = false, bool regex = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex)
{
}
@@ -56,8 +50,7 @@ public class JsonMatcher : IJsonMatcher
/// <param name="value">The object value to check for equality.</param>
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
/// <param name="regex">Support Regex.</param>
/// <param name="ignoreArrayOrder">Ignore array element order when comparing.</param>
public JsonMatcher(object value, bool ignoreCase = false, bool regex = false, bool ignoreArrayOrder = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex, ignoreArrayOrder)
public JsonMatcher(object value, bool ignoreCase = false, bool regex = false) : this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex)
{
}
@@ -68,15 +61,13 @@ public class JsonMatcher : IJsonMatcher
/// <param name="value">The value to check for equality.</param>
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
/// <param name="regex">Support Regex.</param>
/// <param name="ignoreArrayOrder">Ignore array element order when comparing.</param>
public JsonMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false, bool ignoreArrayOrder = false)
public JsonMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false)
{
Guard.NotNull(value);
MatchBehaviour = matchBehaviour;
IgnoreCase = ignoreCase;
Regex = regex;
IgnoreArrayOrder = ignoreArrayOrder;
Value = value;
_valueAsJToken = ConvertValueToJToken(value);
@@ -115,8 +106,7 @@ public class JsonMatcher : IJsonMatcher
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreCase)}, " +
$"{CSharpFormatter.ToCSharpBooleanLiteral(Regex)}, " +
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreArrayOrder)}" +
$"{CSharpFormatter.ToCSharpBooleanLiteral(Regex)}" +
$")";
}
@@ -193,13 +183,6 @@ public class JsonMatcher : IJsonMatcher
return false;
}
if (IgnoreArrayOrder)
{
// Sort both arrays by their string representation and compare
valueArray = valueArray.OrderBy(t => t.ToString()).ToArray();
inputArray = inputArray.OrderBy(t => t.ToString()).ToArray();
}
return !valueArray.Where((valueToken, index) => !IsMatch(valueToken, inputArray[index])).Any();
default:
@@ -35,11 +35,6 @@ public class SystemTextJsonMatcher : IJsonMatcher
/// </summary>
public bool Regex { get; }
/// <summary>
/// Ignore array order when comparing
/// </summary>
public bool IgnoreArrayOrder { get; }
private readonly JsonElement _valueAsJsonElement;
/// <summary>
@@ -48,9 +43,8 @@ public class SystemTextJsonMatcher : IJsonMatcher
/// <param name="value">The string value to check for equality.</param>
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
/// <param name="regex">Support Regex.</param>
/// <param name="ignoreArrayOrder">Ignore array element order when comparing.</param>
public SystemTextJsonMatcher(string value, bool ignoreCase = false, bool regex = false, bool ignoreArrayOrder = false)
: this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex, ignoreArrayOrder)
public SystemTextJsonMatcher(string value, bool ignoreCase = false, bool regex = false)
: this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex)
{
}
@@ -60,9 +54,8 @@ public class SystemTextJsonMatcher : IJsonMatcher
/// <param name="value">The object value to check for equality.</param>
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
/// <param name="regex">Support Regex.</param>
/// <param name="ignoreArrayOrder">Ignore array element order when comparing.</param>
public SystemTextJsonMatcher(object value, bool ignoreCase = false, bool regex = false, bool ignoreArrayOrder = false)
: this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex, ignoreArrayOrder)
public SystemTextJsonMatcher(object value, bool ignoreCase = false, bool regex = false)
: this(MatchBehaviour.AcceptOnMatch, value, ignoreCase, regex)
{
}
@@ -73,15 +66,13 @@ public class SystemTextJsonMatcher : IJsonMatcher
/// <param name="value">The value to check for equality.</param>
/// <param name="ignoreCase">Ignore the case from the PropertyName and PropertyValue (string only).</param>
/// <param name="regex">Support Regex.</param>
/// <param name="ignoreArrayOrder">Ignore array element order when comparing.</param>
public SystemTextJsonMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false, bool ignoreArrayOrder = false)
public SystemTextJsonMatcher(MatchBehaviour matchBehaviour, object value, bool ignoreCase = false, bool regex = false)
{
Guard.NotNull(value);
MatchBehaviour = matchBehaviour;
IgnoreCase = ignoreCase;
Regex = regex;
IgnoreArrayOrder = ignoreArrayOrder;
Value = value;
_valueAsJsonElement = ConvertToJsonElement(value);
@@ -120,8 +111,7 @@ public class SystemTextJsonMatcher : IJsonMatcher
$"{MatchBehaviour.GetFullyQualifiedEnumValue()}, " +
$"{CSharpFormatter.ConvertToAnonymousObjectDefinition(Value, 3)}, " +
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreCase)}, " +
$"{CSharpFormatter.ToCSharpBooleanLiteral(Regex)}, " +
$"{CSharpFormatter.ToCSharpBooleanLiteral(IgnoreArrayOrder)}" +
$"{CSharpFormatter.ToCSharpBooleanLiteral(Regex)}" +
$")";
}
@@ -212,13 +202,6 @@ public class SystemTextJsonMatcher : IJsonMatcher
return false;
}
if (IgnoreArrayOrder)
{
// Sort both arrays by their string representation and compare
valueArray = valueArray.OrderBy(e => e.GetRawText()).ToArray();
inputArray = inputArray.OrderBy(e => e.GetRawText()).ToArray();
}
return !valueArray.Where((valueToken, index) => !IsMatch(valueToken, inputArray[index])).Any();
}
@@ -523,134 +523,4 @@ public class JsonMatcherTests
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void JsonMatcher_IsMatch_Array_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new JsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: true);
// Act
var jArray = new JArray
{
"c",
"a",
"b"
};
var score = matcher.IsMatch(jArray).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void JsonMatcher_IsMatch_Array_WithIgnoreArrayOrderFalse_DifferentOrder_ShouldNotMatch()
{
// Assign
var matcher = new JsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: false);
// Act
var jArray = new JArray
{
"c",
"a",
"b"
};
var score = matcher.IsMatch(jArray).Score;
// Assert
Assert.Equal(MatchScores.Mismatch, score);
}
[Fact]
public void JsonMatcher_IsMatch_Array_WithIgnoreArrayOrderTrue_SameOrder_ShouldMatch()
{
// Assign
var matcher = new JsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: true);
// Act
var jArray = new JArray
{
"a",
"b",
"c"
};
var score = matcher.IsMatch(jArray).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void JsonMatcher_IsMatch_Array_WithIgnoreArrayOrderTrue_DifferentLength_ShouldNotMatch()
{
// Assign
var matcher = new JsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: true);
// Act
var jArray = new JArray
{
"a",
"b"
};
var score = matcher.IsMatch(jArray).Score;
// Assert
Assert.Equal(MatchScores.Mismatch, score);
}
[Fact]
public void JsonMatcher_IsMatch_ObjectWithArray_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new JsonMatcher(new { Items = new[] { "x", "y", "z" } }, ignoreArrayOrder: true);
// Act
var jObject = new JObject
{
{ "Items", new JArray("z", "x", "y") }
};
var score = matcher.IsMatch(jObject).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void JsonMatcher_IsMatch_ArrayAsString_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new JsonMatcher("[ \"a\", \"b\", \"c\" ]", ignoreArrayOrder: true);
// Act
var jArray = new JArray
{
"c",
"b",
"a"
};
var score = matcher.IsMatch(jArray).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void JsonMatcher_IsMatch_ArrayOfNumbers_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new JsonMatcher(new[] { 1, 2, 3 }, ignoreArrayOrder: true);
// Act
var jArray = new JArray
{
3,
1,
2
};
var score = matcher.IsMatch(jArray).Score;
// Assert
Assert.Equal(1.0, score);
}
}
@@ -367,101 +367,4 @@ public class SystemTextJsonMatcherTests
// Assert
Assert.Equal(1.0, match);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_Array_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: true);
// Act
var jsonElement = JsonDocument.Parse("[ \"c\", \"a\", \"b\" ]").RootElement;
var score = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_Array_WithIgnoreArrayOrderFalse_DifferentOrder_ShouldNotMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: false);
// Act
var jsonElement = JsonDocument.Parse("[ \"c\", \"a\", \"b\" ]").RootElement;
var score = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(MatchScores.Mismatch, score);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_Array_WithIgnoreArrayOrderTrue_SameOrder_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: true);
// Act
var jsonElement = JsonDocument.Parse("[ \"a\", \"b\", \"c\" ]").RootElement;
var score = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_Array_WithIgnoreArrayOrderTrue_DifferentLength_ShouldNotMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher(new[] { "a", "b", "c" }, ignoreArrayOrder: true);
// Act
var jsonElement = JsonDocument.Parse("[ \"a\", \"b\" ]").RootElement;
var score = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(MatchScores.Mismatch, score);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_ObjectWithArray_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher(new { Items = new[] { "x", "y", "z" } }, ignoreArrayOrder: true);
// Act
var match = matcher.IsMatch("{ \"Items\" : [ \"z\", \"x\", \"y\" ] }").Score;
// Assert
Assert.Equal(1.0, match);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_ArrayAsString_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher("[ \"a\", \"b\", \"c\" ]", ignoreArrayOrder: true);
// Act
var jsonElement = JsonDocument.Parse("[ \"c\", \"b\", \"a\" ]").RootElement;
var score = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(1.0, score);
}
[Fact]
public void SystemTextJsonMatcher_IsMatch_ArrayOfNumbers_WithIgnoreArrayOrderTrue_DifferentOrder_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonMatcher(new[] { 1, 2, 3 }, ignoreArrayOrder: true);
// Act
var jsonElement = JsonDocument.Parse("[ 3, 1, 2 ]").RootElement;
var score = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(1.0, score);
}
}
}