mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-24 01:35:07 +01:00
* Create WireMock.Net.MimePart project * . * REFACTOR * ILRepack * -- * ... * x * x * . * fix * public class MimePartMatcher * shared * min * . * <!--<DelaySign>true</DelaySign>--> * Update README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
57 lines
1.9 KiB
C#
57 lines
1.9 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using Stef.Validation;
|
|
|
|
namespace WireMock.Matchers.Request;
|
|
|
|
/// <summary>
|
|
/// The request method matcher.
|
|
/// </summary>
|
|
internal class RequestMessageMethodMatcher : IRequestMatcher
|
|
{
|
|
/// <summary>
|
|
/// The <see cref="Matchers.MatchBehaviour"/>
|
|
/// </summary>
|
|
public MatchBehaviour MatchBehaviour { get; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="Matchers.MatchOperator"/>
|
|
/// </summary>
|
|
public MatchOperator MatchOperator { get; }
|
|
|
|
/// <summary>
|
|
/// The methods
|
|
/// </summary>
|
|
public string[] Methods { get; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RequestMessageMethodMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="methods">The methods.</param>
|
|
public RequestMessageMethodMatcher(params string[] methods) : this(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, methods)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RequestMessageMethodMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="matchBehaviour">The match behaviour.</param>
|
|
/// <param name="matchOperator">The <see cref="Matchers.MatchOperator"/> to use.</param>
|
|
/// <param name="methods">The methods.</param>
|
|
public RequestMessageMethodMatcher(MatchBehaviour matchBehaviour, MatchOperator matchOperator, params string[] methods)
|
|
{
|
|
Methods = Guard.NotNull(methods);
|
|
MatchBehaviour = matchBehaviour;
|
|
MatchOperator = matchOperator;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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);
|
|
}
|
|
} |