mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-19 15:01:18 +02:00
* Fixes for JsonPath * More tests * Fixes + added tests
This commit is contained in:
@@ -24,7 +24,7 @@ namespace WireMock.Matchers.Request
|
||||
/// <value>
|
||||
/// The matchers.
|
||||
/// </value>
|
||||
public IMatcher[] Matchers { get; }
|
||||
public IStringMatcher[] Matchers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
|
||||
@@ -38,7 +38,7 @@ namespace WireMock.Matchers.Request
|
||||
Check.NotNull(pattern, nameof(pattern));
|
||||
|
||||
Name = name;
|
||||
Matchers = new IMatcher[] { new WildcardMatcher(pattern, ignoreCase) };
|
||||
Matchers = new IStringMatcher[] { new WildcardMatcher(pattern, ignoreCase) };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -46,7 +46,7 @@ namespace WireMock.Matchers.Request
|
||||
/// </summary>
|
||||
/// <param name="name">The name.</param>
|
||||
/// <param name="matchers">The matchers.</param>
|
||||
public RequestMessageCookieMatcher([NotNull] string name, [NotNull] params IMatcher[] matchers)
|
||||
public RequestMessageCookieMatcher([NotNull] string name, [NotNull] params IStringMatcher[] matchers)
|
||||
{
|
||||
Check.NotNull(name, nameof(name));
|
||||
Check.NotNull(matchers, nameof(matchers));
|
||||
@@ -83,16 +83,24 @@ namespace WireMock.Matchers.Request
|
||||
private double IsMatch(RequestMessage requestMessage)
|
||||
{
|
||||
if (requestMessage.Cookies == null)
|
||||
{
|
||||
return MatchScores.Mismatch;
|
||||
}
|
||||
|
||||
if (Funcs != null)
|
||||
{
|
||||
return MatchScores.ToScore(Funcs.Any(f => f(requestMessage.Cookies)));
|
||||
}
|
||||
|
||||
if (Matchers == null)
|
||||
{
|
||||
return MatchScores.Mismatch;
|
||||
}
|
||||
|
||||
if (!requestMessage.Cookies.ContainsKey(Name))
|
||||
{
|
||||
return MatchScores.Mismatch;
|
||||
}
|
||||
|
||||
string value = requestMessage.Cookies[Name];
|
||||
return Matchers.Max(m => m.IsMatch(value));
|
||||
|
||||
Reference in New Issue
Block a user