Summary

Class:WireMock.Matchers.Request.RequestMessageMethodMatcher
Assembly:WireMock.Net
File(s):C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessageMethodMatcher.cs
Covered lines:14
Uncovered lines:0
Coverable lines:14
Total lines:45
Line coverage:100%

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
GetMatchingScore(...)0010
IsMatch(...)0010
.ctor(...)0010

File(s)

C:\Users\StefHeyenrath\Documents\GitHub\WireMock.Net\src\WireMock.Net\Matchers\Request\RequestMessageMethodMatcher.cs

#LineLine coverage
 1using System;
 2using System.Linq;
 3using JetBrains.Annotations;
 4using WireMock.Validation;
 5
 6namespace WireMock.Matchers.Request
 7{
 8    /// <summary>
 9    /// The request verb matcher.
 10    /// </summary>
 11    internal class RequestMessageMethodMatcher : IRequestMatcher
 12    {
 13        private readonly MatchBehaviour _matchBehaviour;
 14
 15        /// <summary>
 16        /// The methods
 17        /// </summary>
 28718        public string[] Methods { get; }
 19
 20        /// <summary>
 21        /// Initializes a new instance of the <see cref="RequestMessageMethodMatcher"/> class.
 22        /// </summary>
 23        /// <param name="matchBehaviour">The match behaviour.</param>
 24        /// <param name="methods">The methods.</param>
 25425        public RequestMessageMethodMatcher(MatchBehaviour matchBehaviour, [NotNull] params string[] methods)
 25426        {
 25427            Check.NotNull(methods, nameof(methods));
 25428            _matchBehaviour = matchBehaviour;
 29
 25430            Methods = methods;
 25431        }
 32
 33        /// <inheritdoc cref="IRequestMatcher.GetMatchingScore"/>
 34        public double GetMatchingScore(RequestMessage requestMessage, RequestMatchResult requestMatchResult)
 28635        {
 28636            double score = MatchBehaviourHelper.Convert(_matchBehaviour, IsMatch(requestMessage));
 28637            return requestMatchResult.AddScore(GetType(), score);
 28638        }
 39
 40        private double IsMatch(RequestMessage requestMessage)
 28641        {
 28642            return MatchScores.ToScore(Methods.Contains(requestMessage.Method, StringComparer.OrdinalIgnoreCase));
 28643        }
 44    }
 45}