mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-20 00:03:48 +01:00
* ProtoBuf
* .
* x
* ---
* x
* fx
* ...
* sc
* ...
* .
* groen
* x
* fix tests
* ok!?
* fix tests
* fix tests
* !
* x
* 6
* .
* x
* ivaluematcher
* transformer
* .
* sc
* .
* mapping
* x
* tra
* com
* ...
* .
* .
* .
* AddProtoDefinition
* .
* set
* grpahj
* .
* .
* IdOrText
* ...
* async
* async2
* .
* t
* nuget
* <PackageReference Include="ProtoBufJsonConverter" Version="0.2.0-preview-04" />
* http version
* tests
* .WithHttpVersion("2")
* <PackageReference Include="ProtoBufJsonConverter" Version="0.2.0" />
* HttpVersionParser
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Stef.Validation;
|
|
|
|
namespace WireMock.Matchers.Request;
|
|
|
|
/// <summary>
|
|
/// The composite request matcher.
|
|
/// </summary>
|
|
public abstract class RequestMessageCompositeMatcher : IRequestMatcher
|
|
{
|
|
private readonly CompositeMatcherType _type;
|
|
|
|
/// <summary>
|
|
/// Gets the request matchers.
|
|
/// </summary>
|
|
/// <value>
|
|
/// The request matchers.
|
|
/// </value>
|
|
private IEnumerable<IRequestMatcher> RequestMatchers { get; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="RequestMessageCompositeMatcher"/> class.
|
|
/// </summary>
|
|
/// <param name="requestMatchers">The request matchers.</param>
|
|
/// <param name="type">The CompositeMatcherType type (Defaults to 'And')</param>
|
|
protected RequestMessageCompositeMatcher(IEnumerable<IRequestMatcher> requestMatchers, CompositeMatcherType type = CompositeMatcherType.And)
|
|
{
|
|
RequestMatchers = Guard.NotNull(requestMatchers);
|
|
_type = type;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public double GetMatchingScore(IRequestMessage requestMessage, IRequestMatchResult requestMatchResult)
|
|
{
|
|
if (!RequestMatchers.Any())
|
|
{
|
|
return MatchScores.Mismatch;
|
|
}
|
|
|
|
if (_type == CompositeMatcherType.And)
|
|
{
|
|
return RequestMatchers.Average(requestMatcher => requestMatcher.GetMatchingScore(requestMessage, requestMatchResult));
|
|
}
|
|
|
|
return RequestMatchers.Max(requestMatcher => requestMatcher.GetMatchingScore(requestMessage, requestMatchResult));
|
|
}
|
|
} |