Stef negate matcher (#134)

* RejectOnMatch (wip)

* RejectOnMatch (wip)

* RejectOnMatch (wip)

* RejectOnMatch (wip)

* docs: improve sample app matcher to show use of reject on match

* Reworked code review comments
This commit is contained in:
Alastair Crabtree
2018-05-12 11:51:56 +01:00
committed by Stef Heyenrath
parent 7cf283ec13
commit a8ddd31c9c
53 changed files with 1076 additions and 394 deletions

View File

@@ -11,6 +11,8 @@ namespace WireMock.Matchers.Request
/// </summary>
public class RequestMessageCookieMatcher : IRequestMatcher
{
private readonly MatchBehaviour _matchBehaviour;
/// <value>
/// The funcs.
/// </value>
@@ -29,16 +31,18 @@ namespace WireMock.Matchers.Request
/// <summary>
/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.
/// </summary>
/// <param name="matchBehaviour">The match behaviour.</param>
/// <param name="name">The name.</param>
/// <param name="pattern">The pattern.</param>
/// <param name="ignoreCase">The ignoreCase.</param>
public RequestMessageCookieMatcher([NotNull] string name, [NotNull] string pattern, bool ignoreCase = true)
public RequestMessageCookieMatcher(MatchBehaviour matchBehaviour, [NotNull] string name, [NotNull] string pattern, bool ignoreCase = true)
{
Check.NotNull(name, nameof(name));
Check.NotNull(pattern, nameof(pattern));
_matchBehaviour = matchBehaviour;
Name = name;
Matchers = new IStringMatcher[] { new WildcardMatcher(pattern, ignoreCase) };
Matchers = new IStringMatcher[] { new WildcardMatcher(matchBehaviour, pattern, ignoreCase) };
}
/// <summary>
@@ -77,7 +81,7 @@ namespace WireMock.Matchers.Request
{
if (requestMessage.Cookies == null)
{
return MatchScores.Mismatch;
return MatchBehaviourHelper.Convert(_matchBehaviour, MatchScores.Mismatch);
}
if (Funcs != null)
@@ -92,7 +96,7 @@ namespace WireMock.Matchers.Request
if (!requestMessage.Cookies.ContainsKey(Name))
{
return MatchScores.Mismatch;
return MatchBehaviourHelper.Convert(_matchBehaviour, MatchScores.Mismatch);
}
string value = requestMessage.Cookies[Name];