mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-02-16 07:17:42 +01:00
81 lines
3.3 KiB
C#
81 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using WireMock.Matchers;
|
|
using WireMock.Matchers.Request;
|
|
using Stef.Validation;
|
|
|
|
namespace WireMock.RequestBuilders;
|
|
|
|
public partial class Request
|
|
{
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string, MatchBehaviour)"/>
|
|
public IRequestBuilder WithCookie(string name, string pattern, MatchBehaviour matchBehaviour)
|
|
{
|
|
return WithCookie(name, pattern, true, matchBehaviour);
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string, bool, MatchBehaviour)"/>
|
|
public IRequestBuilder WithCookie(string name, string pattern, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
{
|
|
Guard.NotNull(name, nameof(name));
|
|
Guard.NotNull(pattern, nameof(pattern));
|
|
|
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, pattern, ignoreCase));
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string[], MatchBehaviour)"/>
|
|
public IRequestBuilder WithCookie(string name, string[] patterns, MatchBehaviour matchBehaviour)
|
|
{
|
|
return WithCookie(name, patterns, true, matchBehaviour);
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, string[], bool, MatchBehaviour)"/>
|
|
public IRequestBuilder WithCookie(string name, string[] patterns, bool ignoreCase = true, MatchBehaviour matchBehaviour = MatchBehaviour.AcceptOnMatch)
|
|
{
|
|
Guard.NotNull(name, nameof(name));
|
|
Guard.NotNull(patterns, nameof(patterns));
|
|
|
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, patterns));
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
|
public IRequestBuilder WithCookie(string name, params IStringMatcher[] matchers)
|
|
{
|
|
Guard.NotNull(name, nameof(name));
|
|
Guard.NotNullOrEmpty(matchers, nameof(matchers));
|
|
|
|
_requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, false, matchers));
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, bool, IStringMatcher[])"/>
|
|
public IRequestBuilder WithCookie(string name, bool ignoreCase, params IStringMatcher[] matchers)
|
|
{
|
|
Guard.NotNull(name, nameof(name));
|
|
Guard.NotNullOrEmpty(matchers, nameof(matchers));
|
|
|
|
_requestMatchers.Add(new RequestMessageCookieMatcher(MatchBehaviour.AcceptOnMatch, name, ignoreCase, matchers));
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(string, IStringMatcher[])"/>
|
|
public IRequestBuilder WithCookie(string name, bool ignoreCase, MatchBehaviour matchBehaviour, params IStringMatcher[] matchers)
|
|
{
|
|
Guard.NotNull(name, nameof(name));
|
|
Guard.NotNullOrEmpty(matchers, nameof(matchers));
|
|
|
|
_requestMatchers.Add(new RequestMessageCookieMatcher(matchBehaviour, name, ignoreCase, matchers));
|
|
return this;
|
|
}
|
|
|
|
/// <inheritdoc cref="ICookiesRequestBuilder.WithCookie(Func{IDictionary{string, string}, bool}[])"/>
|
|
public IRequestBuilder WithCookie(params Func<IDictionary<string, string>, bool>[] funcs)
|
|
{
|
|
Guard.NotNullOrEmpty(funcs, nameof(funcs));
|
|
|
|
_requestMatchers.Add(new RequestMessageCookieMatcher(funcs));
|
|
return this;
|
|
}
|
|
} |