// Copyright © WireMock.Net using System; using System.Linq; using Stef.Validation; namespace WireMock.Matchers.Request; /// /// The request method matcher. /// internal class RequestMessageMethodMatcher : IRequestMatcher { /// /// The /// public MatchBehaviour MatchBehaviour { get; } /// /// The /// public MatchOperator MatchOperator { get; } /// /// The methods /// public string[] Methods { get; } /// /// Initializes a new instance of the class. /// /// The methods. public RequestMessageMethodMatcher(params string[] methods) : this(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, methods) { } /// /// Initializes a new instance of the class. /// /// The match behaviour. /// The to use. /// The methods. public RequestMessageMethodMatcher(MatchBehaviour matchBehaviour, MatchOperator matchOperator, params string[] methods) { Methods = Guard.NotNull(methods); MatchBehaviour = matchBehaviour; MatchOperator = matchOperator; } /// public double GetMatchingScore(IRequestMessage requestMessage, IRequestMatchResult requestMatchResult) { var scores = Methods.Select(m => string.Equals(m, requestMessage.Method, StringComparison.OrdinalIgnoreCase)).ToArray(); var score = MatchScores.ToScore(scores, MatchOperator); return requestMatchResult.AddScore(GetType(), score, null); } }