# WireMock.Matchers.Request.RequestMessageCookieMatcher - Coverage Report

# Summary

Class: | WireMock.Matchers.Request.RequestMessageCookieMatcher
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessageCookieMatcher.cs
Covered lines: | 36
Uncovered lines: | 6
Coverable lines: | 42
Total lines: | 102
Line coverage: | 85.7%
Branch coverage: | 62.5%

# Metrics

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

# File(s)

## C:\Users\azureuser\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>`
| 4 | `17` |  | `public Func<IDictionary<string, string>, bool>[] Funcs { get; }`
|  | `18` |  | ``
|  | `19` |  | `/// <summary>`
|  | `20` |  | `/// The name`
|  | `21` |  | `/// </summary>`
| 4 | `22` |  | `public string Name { get; }`
|  | `23` |  | ``
|  | `24` |  | `/// <value>`
|  | `25` |  | `/// The matchers.`
|  | `26` |  | `/// </value>`
| 4 | `27` |  | `public IStringMatcher[] 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 IStringMatcher[] { 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>`
| 1 | `49` |  | `public RequestMessageCookieMatcher([NotNull] string name, [NotNull] params IStringMatcher[] matchers)`
| 1 | `50` |  | `{`
| 1 | `51` |  | `Check.NotNull(name, nameof(name));`
| 1 | `52` |  | `Check.NotNull(matchers, nameof(matchers));`
|  | `53` |  | ``
| 1 | `54` |  | `Name = name;`
| 1 | `55` |  | `Matchers = matchers;`
| 1 | `56` |  | `}`
|  | `57` |  | ``
|  | `58` |  | `/// <summary>`
|  | `59` |  | `/// Initializes a new instance of the <see cref="RequestMessageCookieMatcher"/> class.`
|  | `60` |  | `/// </summary>`
|  | `61` |  | `/// <param name="funcs">The funcs.</param>`
| 1 | `62` |  | `public RequestMessageCookieMatcher([NotNull] params Func<IDictionary<string, string>, bool>[] funcs)`
| 1 | `63` |  | `{`
| 1 | `64` |  | `Check.NotNull(funcs, nameof(funcs));`
|  | `65` |  | ``
| 1 | `66` |  | `Funcs = funcs;`
| 1 | `67` |  | `}`
|  | `68` |  | ``
|  | `69` |  | `/// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/>`
|  | `70` |  | `public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult)`
| 3 | `71` |  | `{`
| 3 | `72` |  | `double score = IsMatch(requestMessage);`
| 3 | `73` |  | `return requestMatchResult.AddScore(GetType(), score);`
| 3 | `74` |  | `}`
|  | `75` |  | ``
|  | `76` |  | `private double IsMatch(RequestMessage requestMessage)`
| 3 | `77` |  | `{`
| 3 | `78` |  | `if (requestMessage.Cookies == null)`
| 0 | `79` |  | `{`
| 0 | `80` |  | `return MatchScores.Mismatch;`
|  | `81` |  | `}`
|  | `82` |  | ``
| 3 | `83` |  | `if (Funcs != null)`
| 1 | `84` |  | `{`
| 2 | `85` |  | `return MatchScores.ToScore(Funcs.Any(f => f(requestMessage.Cookies)));`
|  | `86` |  | `}`
|  | `87` |  | ``
| 2 | `88` |  | `if (Matchers == null)`
| 0 | `89` |  | `{`
| 0 | `90` |  | `return MatchScores.Mismatch;`
|  | `91` |  | `}`
|  | `92` |  | ``
| 2 | `93` |  | `if (!requestMessage.Cookies.ContainsKey(Name))`
| 0 | `94` |  | `{`
| 0 | `95` |  | `return MatchScores.Mismatch;`
|  | `96` |  | `}`
|  | `97` |  | ``
| 2 | `98` |  | `string value = requestMessage.Cookies[Name];`
| 4 | `99` |  | `return Matchers.Max(m => m.IsMatch(value));`
| 3 | `100` |  | `}`
|  | `101` |  | `}`
|  | `102` |  | `}`

# Methods/Properties

Funcs()
Name()
Matchers()
.ctor(System.String,System.String,System.Boolean)
.ctor(System.String,WireMock.Matchers.IStringMatcher[])
.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)