mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 22:23:05 +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
129 lines
4.2 KiB
C#
129 lines
4.2 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
// ReSharper disable once CheckNamespace
|
|
namespace WireMock.Admin.Mappings;
|
|
|
|
/// <summary>
|
|
/// BodyModelBuilder
|
|
/// </summary>
|
|
public partial class BodyModelBuilder
|
|
{
|
|
public BodyModelBuilder WithNotNullOrEmptyMatcher(bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("NotNullOrEmptyMatcher")
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithCSharpCodeMatcher(string pattern, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("CSharpCodeMatcher", pattern, rejectOnMatch);
|
|
}
|
|
|
|
public BodyModelBuilder WithLinqMatcher(string pattern, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("LinqMatcher", pattern, rejectOnMatch);
|
|
}
|
|
|
|
public BodyModelBuilder WithExactMatcher(string pattern, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("ExactMatcher", pattern, rejectOnMatch);
|
|
}
|
|
|
|
public BodyModelBuilder WithExactObjectMatcher(object value, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("ExactObjectMatcher", value, rejectOnMatch);
|
|
}
|
|
|
|
public BodyModelBuilder WithGraphQLMatcher(string pattern, IDictionary<string, Type>? customScalars = null, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("GraphQLMatcher")
|
|
.WithCustomScalars(customScalars)
|
|
.WithPattern(pattern)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithProtoBufMatcher(string pattern, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("ProtoBufMatcher")
|
|
.WithPattern(pattern)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithRegexMatcher(string pattern, bool ignoreCase = false, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("RegexMatcher")
|
|
.WithPattern(pattern)
|
|
.WithIgnoreCase(ignoreCase)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithJsonMatcher(string pattern, bool ignoreCase = false, bool useRegex = false, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("JsonMatcher")
|
|
.WithPattern(pattern)
|
|
.WithIgnoreCase(ignoreCase)
|
|
.WithRegex(useRegex)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithJsonPartialMatcher(string pattern, bool ignoreCase = false, bool useRegex = false, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("JsonPartialMatcher")
|
|
.WithPattern(pattern)
|
|
.WithIgnoreCase(ignoreCase)
|
|
.WithRegex(useRegex)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithJsonPathMatcher(string pattern, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("JsonPathMatcher", pattern, rejectOnMatch);
|
|
}
|
|
|
|
public BodyModelBuilder WithJmesPathMatcher(string pattern, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("JmesPathMatcher", pattern, rejectOnMatch);
|
|
}
|
|
|
|
public BodyModelBuilder WithXPathMatcher(string pattern, XmlNamespace[]? xmlNamespaceMap = null, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName("PathMatcher")
|
|
.WithPattern(pattern)
|
|
.WithXmlNamespaceMap(xmlNamespaceMap)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
);
|
|
}
|
|
|
|
public BodyModelBuilder WithWildcardMatcher(string pattern, bool ignoreCase = false, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("WildcardMatcher", pattern, rejectOnMatch, ignoreCase);
|
|
}
|
|
|
|
public BodyModelBuilder WithSimMetricsMatcher(string pattern, bool ignoreCase = false, bool rejectOnMatch = false)
|
|
{
|
|
return WithMatcher("SimMetricsMatcher", pattern, rejectOnMatch, ignoreCase);
|
|
}
|
|
|
|
private BodyModelBuilder WithMatcher(string name, object pattern, bool rejectOnMatch, bool ignoreCase = false)
|
|
{
|
|
return WithMatcher(mb => mb
|
|
.WithName(name)
|
|
.WithPattern(pattern)
|
|
.WithRejectOnMatch(rejectOnMatch)
|
|
.WithIgnoreCase(ignoreCase)
|
|
);
|
|
}
|
|
} |