# Summary

Class: | WireMock.Matchers.XPathMatcher
Assembly: | WireMock.Net
File(s): | C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\XPathMatcher.cs
Covered lines: | 17
Uncovered lines: | 5
Coverable lines: | 22
Total lines: | 66
Line coverage: | 77.2%
Branch coverage: | 50%

# Metrics

Method | Cyclomatic complexity | NPath complexity | Sequence coverage | Branch coverage
--- | --- | --- | --- | ---
.ctor(...) | 1 | 0 | 100 | 100
IsMatch(...) | 2 | 2 | 54.55 | 66.67
GetPatterns() | 1 | 0 | 100 | 100
GetName() | 1 | 0 | 100 | 100

# File(s)

## C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\XPathMatcher.cs

| # | Line |  | Line coverage
--- | --- | --- | --- | ---
|  | `1` |  | `using System;`
|  | `2` |  | `using System.Linq;`
|  | `3` |  | `using System.Xml;`
|  | `4` |  | `using JetBrains.Annotations;`
|  | `5` |  | `using WireMock.Validation;`
|  | `6` |  | `#if !NETSTANDARD1_3`
|  | `7` |  | `using Wmhelp.XPath2;`
|  | `8` |  | `#endif`
|  | `9` |  | ``
|  | `10` |  | `namespace WireMock.Matchers`
|  | `11` |  | `{`
|  | `12` |  | `/// <summary>`
|  | `13` |  | `/// XPath2Matcher`
|  | `14` |  | `/// </summary>`
|  | `15` |  | `/// <seealso cref="IStringMatcher" />`
|  | `16` |  | `public class XPathMatcher : IStringMatcher`
|  | `17` |  | `{`
|  | `18` |  | `private readonly string[] _patterns;`
|  | `19` |  | ``
|  | `20` |  | `/// <summary>`
|  | `21` |  | `/// Initializes a new instance of the <see cref="XPathMatcher"/> class.`
|  | `22` |  | `/// </summary>`
|  | `23` |  | `/// <param name="patterns">The patterns.</param>`
| 4 | `24` |  | `public XPathMatcher([NotNull] params string[] patterns)`
| 4 | `25` |  | `{`
| 4 | `26` |  | `Check.NotNull(patterns, nameof(patterns));`
|  | `27` |  | ``
| 4 | `28` |  | `_patterns = patterns;`
| 4 | `29` |  | `}`
|  | `30` |  | ``
|  | `31` |  | `/// <inheritdoc cref="IStringMatcher.IsMatch"/>`
|  | `32` |  | `public double IsMatch(string input)`
| 2 | `33` |  | `{`
| 2 | `34` |  | `if (input == null)`
| 0 | `35` |  | `{`
| 0 | `36` |  | `return MatchScores.Mismatch;`
|  | `37` |  | `}`
|  | `38` |  | ``
|  | `39` |  | `try`
| 2 | `40` |  | `{`
| 2 | `41` |  | `var nav = new XmlDocument { InnerXml = input }.CreateNavigator();`
|  | `42` |  | `#if NETSTANDARD1_3`
|  | `43` |  | `return MatchScores.ToScore(_patterns.Select(p => true.Equals(nav.Evaluate($"boolean({p})"))));`
|  | `44` |  | `#else`
| 6 | `45` |  | `return MatchScores.ToScore(_patterns.Select(p => true.Equals(nav.XPath2Evaluate($"boolean({p})"))));`
|  | `46` |  | `#endif`
|  | `47` |  | `}`
| 0 | `48` |  | `catch (Exception)`
| 0 | `49` |  | `{`
| 0 | `50` |  | `return MatchScores.Mismatch;`
|  | `51` |  | `}`
| 2 | `52` |  | `}`
|  | `53` |  | ``
|  | `54` |  | `/// <inheritdoc cref="IStringMatcher.GetPatterns"/>`
|  | `55` |  | `public string[] GetPatterns()`
| 1 | `56` |  | `{`
| 1 | `57` |  | `return _patterns;`
| 1 | `58` |  | `}`
|  | `59` |  | ``
|  | `60` |  | `/// <inheritdoc cref="IMatcher.GetName"/>`
|  | `61` |  | `public string GetName()`
| 1 | `62` |  | `{`
| 1 | `63` |  | `return "XPathMatcher";`
| 1 | `64` |  | `}`
|  | `65` |  | `}`
|  | `66` |  | `}`

# Methods/Properties

.ctor(System.String[])
IsMatch(System.String)
GetPatterns()
GetName()