mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-28 03:51:05 +01:00
Add MatchOperator "Or", "And" and "Average" for patterns (#755)
* wip * ... * . * ... * ... * path * url * b * t * client * . * RequestMessageMethodMatcherTests * . * h * . * fix tests * .
This commit is contained in:
48
src/WireMock.Net/RequestBuilders/Request.ClientIP.cs
Normal file
48
src/WireMock.Net/RequestBuilders/Request.ClientIP.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using Stef.Validation;
|
||||
using WireMock.Matchers;
|
||||
using WireMock.Matchers.Request;
|
||||
|
||||
namespace WireMock.RequestBuilders;
|
||||
|
||||
public partial class Request
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IRequestBuilder WithClientIP(params IStringMatcher[] matchers)
|
||||
{
|
||||
return WithClientIP(MatchOperator.Or, matchers);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRequestBuilder WithClientIP(MatchOperator matchOperator, params IStringMatcher[] matchers)
|
||||
{
|
||||
Guard.NotNullOrEmpty(matchers);
|
||||
|
||||
_requestMatchers.Add(new RequestMessageClientIPMatcher(MatchBehaviour.AcceptOnMatch, MatchOperator.Or, matchers));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRequestBuilder WithClientIP(params string[] paths)
|
||||
{
|
||||
return WithClientIP(MatchOperator.Or, paths);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRequestBuilder WithClientIP(MatchOperator matchOperator, params string[] paths)
|
||||
{
|
||||
Guard.NotNullOrEmpty(paths);
|
||||
|
||||
_requestMatchers.Add(new RequestMessageClientIPMatcher(MatchBehaviour.AcceptOnMatch, matchOperator, paths));
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IRequestBuilder WithClientIP(params Func<string, bool>[] funcs)
|
||||
{
|
||||
Guard.NotNullOrEmpty(funcs);
|
||||
|
||||
_requestMatchers.Add(new RequestMessageClientIPMatcher(funcs));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user