Summary

Class:WireMock.Matchers.Request.RequestMessagePathMatcher
Assembly:WireMock.Net
File(s):C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessagePathMatcher.cs
Covered lines:27
Uncovered lines:1
Coverable lines:28
Total lines:74
Line coverage:96.4%
Branch coverage:75%

Metrics

MethodCyclomatic complexity  NPath complexity  Sequence coverage  Branch coverage  
.ctor(...)20100100
.ctor(...)10100100
.ctor(...)10100100
GetMatchingScore(...)10100100
IsMatch(...)4488.8980

File(s)

C:\Users\azureuser\Documents\Github\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessagePathMatcher.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using JetBrains.Annotations;
 5using WireMock.Validation;
 6
 7namespace WireMock.Matchers.Request
 8{
 9    /// <summary>
 10    /// The request path matcher.
 11    /// </summary>
 12    public class RequestMessagePathMatcher : IRequestMatcher
 13    {
 14        /// <summary>
 15        /// The matcher.
 16        /// </summary>
 33517        public IReadOnlyList<IStringMatcher> Matchers { get; }
 18
 19        /// <summary>
 20        /// The path functions
 21        /// </summary>
 222        public Func<string, bool>[] Funcs { get; }
 23
 24        /// <summary>
 25        /// Initializes a new instance of the <see cref="RequestMessagePathMatcher"/> class.
 26        /// </summary>
 27        /// <param name="paths">The paths.</param>
 19728        public RequestMessagePathMatcher([NotNull] params string[] paths) : this(paths.Select(path => new WildcardMatche
 9829        {
 9830        }
 31
 32        /// <summary>
 33        /// Initializes a new instance of the <see cref="RequestMessagePathMatcher"/> class.
 34        /// </summary>
 35        /// <param name="matchers">The matchers.</param>
 11936        public RequestMessagePathMatcher([NotNull] params IStringMatcher[] matchers)
 11937        {
 11938            Check.NotNull(matchers, nameof(matchers));
 11939            Matchers = matchers;
 11940        }
 41
 42        /// <summary>
 43        /// Initializes a new instance of the <see cref="RequestMessagePathMatcher"/> class.
 44        /// </summary>
 45        /// <param name="funcs">The path functions.</param>
 146        public RequestMessagePathMatcher([NotNull] params Func<string, bool>[] funcs)
 147        {
 148            Check.NotNull(funcs, nameof(funcs));
 149            Funcs = funcs;
 150        }
 51
 52        /// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/>
 53        public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult)
 16854        {
 16855            double score = IsMatch(requestMessage);
 16856            return requestMatchResult.AddScore(GetType(), score);
 16857        }
 58
 59        private double IsMatch(RequestMessage requestMessage)
 16860        {
 16861             if (Matchers != null)
 16762            {
 33663                return Matchers.Max(m => m.IsMatch(requestMessage.Path));
 64            }
 65
 166             if (Funcs != null)
 167            {
 268                return MatchScores.ToScore(requestMessage.Path != null && Funcs.Any(func => func(requestMessage.Path)));
 69            }
 70
 071            return MatchScores.Mismatch;
 16872        }
 73    }
 74}