mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-27 18:57:00 +02:00
* Version 2.x * Setup .NET 9 * 12 * cleanup some #if for NETSTANDARD1_3 * cleanup + fix tests for net8 * openapi * NO ConfigureAwait(false) + cleanup * . * #endif * HashSet * WireMock.Net.NUnit * HttpContext * Add WebSockets (#1423) * Add WebSockets * Add tests * fix * more tests * Add tests * ... * remove IOwin * - * tests * fluent * ok * match * . * byte[] * x * func * func * byte * trans * ... * frameworks......... * jmes * xxx * sc * using var httpClient = new HttpClient(); * usings * maxRetries * up * xunit v3 * ct * --- * ct * ct2 * T Unit * WireMock.Net.TUnitTests / 10 * t unit first * --project * no tunit * t2 * --project * --project * ci - --project * publish ./test/wiremock-coverage.xml * windows * . * log * ... * log * goed * BodyType * . * . * --scenario * ... * pact * ct * . * WireMock.Net.RestClient.AwesomeAssertions (#1427) * WireMock.Net.RestClient.AwesomeAssertions * ok * atpath * fix test * sonar fixes * ports * proxy test * FIX? * --- * await Task.Delay(100, _ct); * ? * --project * Aspire: use IDistributedApplicationEventingSubscriber (#1428) * broadcast * ok * more tsts * . * Collection * up * . * 2 * remove nfluent * <VersionPrefix>2.0.0-preview-02</VersionPrefix> * ... * . * nuget icon * . * <PackageReference Include="JmesPath.Net" Version="1.1.0" /> * x * 500 * . * fix some warnings * ws
84 lines
3.5 KiB
C#
84 lines
3.5 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using WireMock.Extensions;
|
|
using WireMock.Matchers;
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace WireMock.Client.AwesomeAssertions;
|
|
|
|
#pragma warning disable CS1591
|
|
public partial class WireMockAdminApiAssertions
|
|
{
|
|
[CustomAssertion]
|
|
public AndWhichConstraint<WireMockAdminApiAssertions, string> AtAbsolutePath(string absolutePath, string because = "", params object[] becauseArgs)
|
|
{
|
|
_ = AtAbsolutePath(new ExactMatcher(true, absolutePath), because, becauseArgs);
|
|
|
|
return new AndWhichConstraint<WireMockAdminApiAssertions, string>(this, absolutePath);
|
|
}
|
|
|
|
[CustomAssertion]
|
|
public AndWhichConstraint<WireMockAdminApiAssertions, IStringMatcher> AtAbsolutePath(IStringMatcher absolutePathMatcher, string because = "", params object[] becauseArgs)
|
|
{
|
|
var (filter, condition) = BuildFilterAndCondition(request => absolutePathMatcher.IsPerfectMatch(request.AbsolutePath));
|
|
|
|
var absolutePath = absolutePathMatcher.GetPatterns().FirstOrDefault().GetPattern();
|
|
|
|
chain
|
|
.BecauseOf(because, becauseArgs)
|
|
.Given(() => RequestMessages)
|
|
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
|
.FailWith(
|
|
"Expected {context:wiremockadminapi} to have been called at address matching the absolute path {0}{reason}, but no calls were made.",
|
|
absolutePath
|
|
)
|
|
.Then
|
|
.ForCondition(condition)
|
|
.FailWith(
|
|
"Expected {context:wiremockadminapi} to have been called at address matching the absolute path {0}{reason}, but didn't find it among the calls to {1}.",
|
|
_ => absolutePath,
|
|
requests => requests.Select(request => request.AbsolutePath)
|
|
);
|
|
|
|
FilterRequestMessages(filter);
|
|
|
|
return new AndWhichConstraint<WireMockAdminApiAssertions, IStringMatcher>(this, absolutePathMatcher);
|
|
}
|
|
|
|
[CustomAssertion]
|
|
public AndWhichConstraint<WireMockAdminApiAssertions, string> AtPath(string path, string because = "", params object[] becauseArgs)
|
|
{
|
|
_ = AtPath(new ExactMatcher(true, path), because, becauseArgs);
|
|
|
|
return new AndWhichConstraint<WireMockAdminApiAssertions, string>(this, path);
|
|
}
|
|
|
|
[CustomAssertion]
|
|
public AndWhichConstraint<WireMockAdminApiAssertions, IStringMatcher> AtPath(IStringMatcher pathMatcher, string because = "", params object[] becauseArgs)
|
|
{
|
|
var (filter, condition) = BuildFilterAndCondition(request => pathMatcher.IsPerfectMatch(request.Path));
|
|
|
|
var path = pathMatcher.GetPatterns().FirstOrDefault().GetPattern();
|
|
|
|
chain
|
|
.BecauseOf(because, becauseArgs)
|
|
.Given(() => RequestMessages)
|
|
.ForCondition(requests => CallsCount == 0 || requests.Any())
|
|
.FailWith(
|
|
"Expected {context:wiremockadminapi} to have been called at address matching the path {0}{reason}, but no calls were made.",
|
|
path
|
|
)
|
|
.Then
|
|
.ForCondition(condition)
|
|
.FailWith(
|
|
"Expected {context:wiremockadminapi} to have been called at address matching the path {0}{reason}, but didn't find it among the calls to {1}.",
|
|
_ => path,
|
|
requests => requests.Select(request => request.Path)
|
|
);
|
|
|
|
FilterRequestMessages(filter);
|
|
|
|
return new AndWhichConstraint<WireMockAdminApiAssertions, IStringMatcher>(this, pathMatcher);
|
|
}
|
|
}
|