# Summary

Class: | WireMock.Matchers.Request.RequestMessageCookieMatcher
Assembly: | WireMock.Net
File(s): | C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessageCookieMatcher.cs
Covered lines: | 24
Uncovered lines: | 16
Coverable lines: | 40
Total lines: | 105
Line coverage: | 60%
Branch coverage: | 50%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
.ctor(...) | 1 | 0 | 100 | 100
.ctor(...) | 1 | 0 | 0 | 0
.ctor(...) | 1 | 0 | 0 | 0
GetMatchingScore(...) | 1 | 0 | 100 | 100
IsMatch(...) | 5 | 16 | 66.67 | 55.56

# File(s)

## C:\Users\Stef\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessageCookieMatcher.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Collections.Generic;`
|  | `3` |  | `using System.Linq;`
|  | `4` |  | `using JetBrains.Annotations;`
|  | `5` |  | `using WireMock.Validation;`
|  | `6` |  | ``
|  | `7` |  | `namespace WireMock.Matchers.Request`
|  | `8` |  | `{`
|  | `9` |  | `/// <summary>`
|  | `10` |  | `/// The request cookie matcher.`
|  | `11` |  | `/// </summary>`
|  | `12` |  | `public class RequestMessageCookieMatcher : IRequestMatcher`
|  | `13` |  | `{`
|  | `14` |  | `/// <value>`
|  | `15` |  | `/// The funcs.`
|  | `16` |  | `/// </value>`
| 1 | `17` |  | `public Func<IDictionary<string, string>, bool>[] Funcs { get; }`
|  | `18` |  | ``
|  | `19` |  | `/// <summary>`
|  | `20` |  | `/// The name`
|  | `21` |  | `/// </summary>`
| 2 | `22` |  | `public string Name { get; }`
|  | `23` |  | ``
|  | `24` |  | `/// <value>`
|  | `25` |  | `/// The matchers.`
|  | `26` |  | `/// </value>`
| 2 | `27` |  | `public IMatcher[] Matchers { get; }`
|  | `28` |  | ``
|  | `29` |  | `/// <summary>`
|  | `30` |  | `/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.`
|  | `31` |  | `/// </summary>`
|  | `32` |  | `/// <param name="name">The name.</param>`
|  | `33` |  | `/// <param name="pattern">The pattern.</param>`
|  | `34` |  | `/// <param name="ignoreCase">The ignoreCase.</param>`
| 1 | `35` |  | `public RequestMessageCookieMatcher([NotNull] string name, [NotNull] string pattern, bool ignoreCase = true)`
| 1 | `36` |  | `{`
| 1 | `37` |  | `Check.NotNull(name, nameof(name));`
| 1 | `38` |  | `Check.NotNull(pattern, nameof(pattern));`
|  | `39` |  | ``
| 1 | `40` |  | `Name = name;`
| 1 | `41` |  | `Matchers = new IMatcher[] { new WildcardMatcher(pattern, ignoreCase) };`
| 1 | `42` |  | `}`
|  | `43` |  | ``
|  | `44` |  | `/// <summary>`
|  | `45` |  | `/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.`
|  | `46` |  | `/// </summary>`
|  | `47` |  | `/// <param name="name">The name.</param>`
|  | `48` |  | `/// <param name="matchers">The matchers.</param>`
| 0 | `49` |  | `public RequestMessageCookieMatcher([NotNull] string name, [NotNull] params IMatcher[] matchers)`
| 0 | `50` |  | `{`
| 0 | `51` |  | `Check.NotNull(name, nameof(name));`
| 0 | `52` |  | `Check.NotNull(matchers, nameof(matchers));`
|  | `53` |  | ``
| 0 | `54` |  | `Name = name;`
| 0 | `55` |  | `Matchers = matchers;`
| 0 | `56` |  | `}`
|  | `57` |  | ``
|  | `58` |  | `/// <summary>`
|  | `59` |  | `/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.`
|  | `60` |  | `/// </summary>`
|  | `61` |  | `/// <param name="funcs">The funcs.</param>`
| 0 | `62` |  | `public RequestMessageCookieMatcher([NotNull] params Func<IDictionary<string, string>, bool>[] funcs)`
| 0 | `63` |  | `{`
| 0 | `64` |  | `Check.NotNull(funcs, nameof(funcs));`
|  | `65` |  | ``
| 0 | `66` |  | `Funcs = funcs;`
| 0 | `67` |  | `}`
|  | `68` |  | ``
|  | `69` |  | `/// <summary>`
|  | `70` |  | `/// Determines whether the specified RequestMessage is match.`
|  | `71` |  | `/// </summary>`
|  | `72` |  | `/// <param name="requestMessage">The RequestMessage.</param>`
|  | `73` |  | `/// <param name="requestMatchResult">The RequestMatchResult.</param>`
|  | `74` |  | `/// <returns>`
|  | `75` |  | `/// A value between 0.0 - 1.0 of the similarity.`
|  | `76` |  | `/// </returns>`
|  | `77` |  | `public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult)`
| 1 | `78` |  | `{`
| 1 | `79` |  | `double score = IsMatch(requestMessage);`
| 1 | `80` |  | `requestMatchResult.TotalScore += score;`
|  | `81` |  | ``
| 1 | `82` |  | `requestMatchResult.TotalNumber++;`
|  | `83` |  | ``
| 1 | `84` |  | `return score;`
| 1 | `85` |  | `}`
|  | `86` |  | ``
|  | `87` |  | `private double IsMatch(RequestMessage requestMessage)`
| 1 | `88` |  | `{`
| 1 | `89` |  | `if (requestMessage.Cookies == null)`
| 0 | `90` |  | `return MatchScores.Mismatch;`
|  | `91` |  | ``
| 1 | `92` |  | `if (Funcs != null)`
| 0 | `93` |  | `return MatchScores.ToScore(Funcs.Any(f => f(requestMessage.Cookies)));`
|  | `94` |  | ``
| 1 | `95` |  | `if (Matchers == null)`
| 0 | `96` |  | `return MatchScores.Mismatch;`
|  | `97` |  | ``
| 1 | `98` |  | `if (!requestMessage.Cookies.ContainsKey(Name))`
| 0 | `99` |  | `return MatchScores.Mismatch;`
|  | `100` |  | ``
| 1 | `101` |  | `string value = requestMessage.Cookies[Name];`
| 2 | `102` |  | `return Matchers.Max(m => m.IsMatch(value));`
| 1 | `103` |  | `}`
|  | `104` |  | `}`
|  | `105` |  | `}`

# Methods/Properties

Funcs()
Name()
Matchers()
.ctor(System.String,System.String,System.Boolean)
.ctor(System.String,WireMock.Matchers.IMatcher[])
.ctor(System.Func`2<System.Collections.Generic.IDictionary`2<System.String,System.String>,System.Boolean>[])
GetMatchingScore(WireMock.RequestMessage,WireMock.Matchers.Request.RequestMatchResult)
IsMatch(WireMock.RequestMessage)