mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Fix JsonPartialMatcher when using property names with dot (#1216)
Fix JsonPartialMatcher when using property names with dot (#1216)
This commit is contained in:
@@ -82,7 +82,7 @@ public abstract class AbstractJsonPartialMatcher : JsonMatcher
|
||||
case JTokenType.Object:
|
||||
var nestedValues = value.ToObject<Dictionary<string, JToken>>();
|
||||
return nestedValues?.Any() != true ||
|
||||
nestedValues.All(pair => IsMatch(pair.Value, input.SelectToken(pair.Key)));
|
||||
nestedValues.All(pair => IsMatch(pair.Value, input.SelectToken(pair.Key) ?? input[pair.Key])); // First try to select based on JPath expression, else just get the value.
|
||||
|
||||
case JTokenType.Array:
|
||||
var valuesArray = value.ToObject<JToken[]>();
|
||||
|
||||
@@ -293,6 +293,23 @@ public class JsonPartialMatcherTests
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPartialMatcher_IsMatch_JObjectAsStringWithDottedPropertyName()
|
||||
{
|
||||
// Assign
|
||||
var matcher = new JsonPartialMatcher("{ \"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User\" : \"Test\" }");
|
||||
|
||||
// Act
|
||||
var jObject = new JObject
|
||||
{
|
||||
{ "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User", new JValue("Test") }
|
||||
};
|
||||
var match = matcher.IsMatch(jObject).Score;
|
||||
|
||||
// Assert
|
||||
Assert.Equal(1.0, match);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void JsonPartialMatcher_IsMatch_GuidAsString()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user