mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-27 03:41:50 +01:00
36 lines
1.3 KiB
C#
36 lines
1.3 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
#pragma warning disable CS1591
|
|
using System;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace WireMock.AwesomeAssertions;
|
|
|
|
public partial class WireMockAssertions
|
|
{
|
|
[CustomAssertion]
|
|
public AndWhichConstraint<WireMockAssertions, string> WithProxyUrl(string proxyUrl, string because = "", params object[] becauseArgs)
|
|
{
|
|
var (filter, condition) = BuildFilterAndCondition(request => string.Equals(request.ProxyUrl, proxyUrl, StringComparison.OrdinalIgnoreCase));
|
|
|
|
_chain
|
|
.BecauseOf(because, becauseArgs)
|
|
.Given(() => RequestMessages)
|
|
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
|
.FailWith(
|
|
"Expected {context:wiremockserver} to have been called with proxy url {0}{reason}, but no calls were made.",
|
|
proxyUrl
|
|
)
|
|
.Then
|
|
.ForCondition(condition)
|
|
.FailWith(
|
|
"Expected {context:wiremockserver} to have been called with proxy url {0}{reason}, but didn't find it among the calls with {1}.",
|
|
_ => proxyUrl,
|
|
requests => requests.Select(request => request.ProxyUrl)
|
|
);
|
|
|
|
FilterRequestMessages(filter);
|
|
|
|
return new AndWhichConstraint<WireMockAssertions, string>(this, proxyUrl);
|
|
}
|
|
} |