mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-24 01:51:02 +01:00
JsonPartialMatcher - support Regex (#771)
* JsonPartialMatcher - support Regex * . * . * more tests * . * .
This commit is contained in:
@@ -47,6 +47,7 @@ internal class MatcherMapper
|
||||
bool ignoreCase = matcher.IgnoreCase == true;
|
||||
bool throwExceptionWhenMatcherFails = _settings.ThrowExceptionWhenMatcherFails == true;
|
||||
bool useRegexExtended = _settings.UseRegexExtended == true;
|
||||
bool useRegex = matcher.Regex == true;
|
||||
|
||||
switch (matcherName)
|
||||
{
|
||||
@@ -79,11 +80,11 @@ internal class MatcherMapper
|
||||
|
||||
case nameof(JsonPartialMatcher):
|
||||
var valueForJsonPartialMatcher = matcher.Pattern ?? matcher.Patterns;
|
||||
return new JsonPartialMatcher(matchBehaviour, valueForJsonPartialMatcher!, ignoreCase, throwExceptionWhenMatcherFails);
|
||||
return new JsonPartialMatcher(matchBehaviour, valueForJsonPartialMatcher!, ignoreCase, throwExceptionWhenMatcherFails, useRegex);
|
||||
|
||||
case nameof(JsonPartialWildcardMatcher):
|
||||
var valueForJsonPartialWildcardMatcher = matcher.Pattern ?? matcher.Patterns;
|
||||
return new JsonPartialWildcardMatcher(matchBehaviour, valueForJsonPartialWildcardMatcher!, ignoreCase, throwExceptionWhenMatcherFails);
|
||||
return new JsonPartialWildcardMatcher(matchBehaviour, valueForJsonPartialWildcardMatcher!, ignoreCase, throwExceptionWhenMatcherFails, useRegex);
|
||||
|
||||
case nameof(JsonPathMatcher):
|
||||
return new JsonPathMatcher(matchBehaviour, throwExceptionWhenMatcherFails, matchOperator, stringPatterns);
|
||||
@@ -146,6 +147,17 @@ internal class MatcherMapper
|
||||
Name = matcher.Name
|
||||
};
|
||||
|
||||
switch (matcher)
|
||||
{
|
||||
case JsonPartialMatcher jsonPartialMatcher:
|
||||
model.Regex = jsonPartialMatcher.Regex;
|
||||
break;
|
||||
|
||||
case JsonPartialWildcardMatcher jsonPartialWildcardMatcher:
|
||||
model.Regex = jsonPartialWildcardMatcher.Regex;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (matcher)
|
||||
{
|
||||
// If the matcher is a IStringMatcher, get the operator & patterns.
|
||||
|
||||
Reference in New Issue
Block a user