Compare commits

...

6 Commits

Author SHA1 Message Date
Stef Heyenrath 1d4f820f1a Fix BodyParser 2026-06-12 18:48:08 +02:00
Stef Heyenrath 89b3149732 Update NuGet packages (Aspire, MessagePack and more) (#1475) 2026-06-12 12:01:09 +02:00
Stef Heyenrath d2b794ec5a 2.10.0 2026-06-07 22:52:32 +02:00
Stef Heyenrath 921a3ebc63 Update JsonConverter to 0.13.0 (#1472) 2026-06-07 22:37:55 +02:00
Stef Heyenrath 428657a97e 2.9.0 2026-06-02 22:43:03 +02:00
Stef Heyenrath fe9745235a Fix WireMock.Net.Aspire project when using Aspire 13.4.0 (#1470) 2026-06-02 22:39:32 +02:00
37 changed files with 222 additions and 112 deletions
+16
View File
@@ -1,3 +1,19 @@
# 2.10.0 (07 June 2026)
- [#1472](https://github.com/wiremock/WireMock.Net/pull/1472) - Update JsonConverter to 0.13.0 [bug] contributed by [StefH](https://github.com/StefH)
# 2.9.0 (02 June 2026)
- [#1470](https://github.com/wiremock/WireMock.Net/pull/1470) - Fix WireMock.Net.Aspire project when using Aspire 13.4.0 [bug] contributed by [StefH](https://github.com/StefH)
- [#1469](https://github.com/wiremock/WireMock.Net/issues/1469) - WireMock.Net doesn't play well with Aspire 13.4.0 [bug]
# 2.8.0 (31 May 2026)
- [#1447](https://github.com/wiremock/WireMock.Net/pull/1447) - Add SystemTextJsonMatchers [feature] contributed by [StefH](https://github.com/StefH)
- [#1466](https://github.com/wiremock/WireMock.Net/pull/1466) - Bump System.Text.RegularExpressions from 4.3.0 to 4.3.1 in Aspire Example project [dependencies, .NET] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#1467](https://github.com/wiremock/WireMock.Net/pull/1467) - Bump System.Net.Http from 4.3.0 to 4.3.4 in Aspire Example project [dependencies, .NET] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#1468](https://github.com/wiremock/WireMock.Net/pull/1468) - Update JsonMatcher to support IgnoreArrayOrder [feature] contributed by [StefH](https://github.com/StefH)
- [#1439](https://github.com/wiremock/WireMock.Net/issues/1439) - JSON reference properties cannot be used when using System.Text.Json serialization [bug]
- [#1445](https://github.com/wiremock/WireMock.Net/issues/1445) - Configurable JSON DE-serialization support (Newtonsoft.Json vs System.Text.Json) [feature]
- [#1460](https://github.com/wiremock/WireMock.Net/issues/1460) - Option to ignore array order when comparing json body [feature]
# 2.7.0 (24 May 2026)
- [#1457](https://github.com/wiremock/WireMock.Net/pull/1457) - Update OpenTelemetry.Api from 1.14.0 to 1.15.3 in unit test project [dependencies] contributed by [dependabot[bot]](https://github.com/apps/dependabot)
- [#1459](https://github.com/wiremock/WireMock.Net/pull/1459) - chore: update Handlebars 2.5.2 to 2.5.5 [dependencies] contributed by [kamisoft-fr](https://github.com/kamisoft-fr)
+2 -2
View File
@@ -4,7 +4,7 @@
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>2.8.0</VersionPrefix>
<VersionPrefix>2.10.0</VersionPrefix>
<PackageIcon>WireMock.Net-Logo.png</PackageIcon>
<PackageProjectUrl>https://github.com/wiremock/WireMock.Net</PackageProjectUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
@@ -52,7 +52,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.103" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
+1 -1
View File
@@ -1,6 +1,6 @@
rem https://github.com/StefH/GitHubReleaseNotes
SET version=2.8.0
SET version=2.10.0
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels wontfix test question invalid doc duplicate example environment --version %version% --token %GH_TOKEN%
+2 -6
View File
@@ -1,8 +1,4 @@
# 2.7.0 (24 May 2026)
- #1457 Update OpenTelemetry.Api from 1.14.0 to 1.15.3 in unit test project [dependencies]
- #1459 chore: update Handlebars 2.5.2 to 2.5.5 [dependencies]
- #1461 Update Testcontainers nuget package to 4.12.0 [dependencies]
- #1462 Update Scriban.Signed to latest [dependencies]
- #1458 update Handlebars Humanizer package version [feature]
# 2.10.0 (07 June 2026)
- #1472 Update JsonConverter to 0.13.0 [bug]
The full release notes can be found here: https://github.com/wiremock/WireMock.Net/blob/master/CHANGELOG.md
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
<Sdk Name="Aspire.AppHost.Sdk" Version="13.4.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
@@ -18,7 +18,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.4.3" />
<!-- CVE-2026-48109 -->
<PackageReference Include="MessagePack" Version="2.5.302" />
</ItemGroup>
<ItemGroup>
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
<Sdk Name="Aspire.AppHost.Sdk" Version="13.4.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
@@ -15,7 +15,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.4.3" />
<!-- CVE-2026-48109 -->
<PackageReference Include="MessagePack" Version="2.5.302" />
</ItemGroup>
</Project>
@@ -9,9 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.25.1" />
<PackageReference Include="Grpc.Net.Client" Version="2.60.0" />
<PackageReference Include="Grpc.Tools" Version="2.60.0">
<PackageReference Include="Google.Protobuf" Version="3.33.5" />
<PackageReference Include="Grpc.Net.Client" Version="2.76.0" />
<PackageReference Include="Grpc.Tools" Version="2.78.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
@@ -16,7 +16,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="WireMock.Net" Version="2.6.0" />
<PackageReference Include="WireMock.Net" Version="2.10.0" />
</ItemGroup>
</Project>
@@ -97,7 +97,7 @@
<Version>2.3.9</Version>
</PackageReference>
<PackageReference Include="WireMock.Net">
<Version>1.25.0</Version>
<Version>2.10.0</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
@@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
</ItemGroup>
<ItemGroup>
@@ -39,7 +39,7 @@
</ItemGroup>-->
<ItemGroup>
<PackageReference Include="FluentBuilder" Version="0.14.0">
<PackageReference Include="FluentBuilder" Version="0.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
@@ -45,7 +45,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting" Version="13.1.0" />
<PackageReference Include="Aspire.Hosting" Version="13.4.3" />
<!-- CVE-2026-48109 -->
<PackageReference Include="MessagePack" Version="2.5.302" />
</ItemGroup>
<ItemGroup>
@@ -21,11 +21,6 @@ public class WireMockHealthCheck(WireMockServerResource resource) : IHealthCheck
return HealthCheckResult.Unhealthy("WireMock.Net is not healthy");
}
if (resource.ApiMappingState == WireMockMappingState.NotSubmitted)
{
return HealthCheckResult.Unhealthy("WireMock.Net has not received mappings");
}
return HealthCheckResult.Healthy();
}
@@ -41,4 +36,4 @@ public class WireMockHealthCheck(WireMockServerResource resource) : IHealthCheck
return false;
}
}
}
}
@@ -21,7 +21,13 @@ internal class WireMockLifecycleSubscriber(ILoggerFactory loggerFactory) : IDist
var endpoint = wireMockServerResource.GetEndpoint();
Debug.Assert(endpoint.IsAllocated);
}
});
eventing.Subscribe<ResourceReadyEvent>(async (@event, ct) =>
{
if (@event.Resource is WireMockServerResource wireMockServerResource)
{
await wireMockServerResource.WaitForHealthAsync(ct);
await wireMockServerResource.CallAddProtoDefinitionsAsync(ct);
@@ -25,7 +25,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JsonConverter.Abstractions" Version="0.12.0" />
<PackageReference Include="JsonConverter.Abstractions" Version="0.13.0" />
</ItemGroup>
<ItemGroup>
@@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
@@ -25,9 +25,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.12.0" />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.13.0" />
<PackageReference Include="NUnit" Version="4.4.0" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
</ItemGroup>
<ItemGroup>
@@ -43,7 +43,7 @@
<PackageReference Include="RamlToOpenApiConverter.SourceOnly" Version="0.11.0" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.19.1" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
@@ -65,6 +65,7 @@ public static class WireMockAdminApiExtensions
waitTime = (int)(InitialWaitingTimeInMilliSeconds * Math.Pow(2, retries));
await Task.Delay(waitTime, cancellationToken);
isHealthy = await IsHealthyAsync(adminApi, cancellationToken);
retries++;
totalWaitTime += waitTime;
}
@@ -33,9 +33,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.12.0" />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.13.0" />
<PackageReference Include="RestEase" Version="1.6.4" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
</ItemGroup>
<ItemGroup>
@@ -305,12 +305,6 @@ public class WireMockServerSettings
[PublicAPI, JsonIgnore]
public IDictionary<string, Func<MatcherModel, IMatcher>>? CustomMatcherMappings { get; set; }
/// <summary>
/// The <see cref="JsonSerializerSettings"/> used when the JSON response is generated.
/// </summary>
[PublicAPI, JsonIgnore]
public JsonSerializerSettings? JsonSerializerSettings { get; set; }
/// <summary>
/// The Culture to use.
/// Currently used for:
+3 -2
View File
@@ -5,6 +5,7 @@ using System.Text;
using Stef.Validation;
using WireMock.Constants;
using WireMock.Matchers;
using WireMock.Serialization;
using WireMock.Types;
namespace WireMock.Util;
@@ -25,7 +26,7 @@ internal static class BodyParser
CONNECT - No defined body semantics
PATCH - Body supported.
*/
private static readonly IDictionary<string, bool> BodyAllowedForMethods = new Dictionary<string, bool>
private static readonly Dictionary<string, bool> BodyAllowedForMethods = new()
{
{ HttpRequestMethod.HEAD, false },
{ HttpRequestMethod.GET, false },
@@ -173,7 +174,7 @@ internal static class BodyParser
{
try
{
data.BodyAsJson = settings.DefaultJsonConverter.Deserialize<object>(data.BodyAsString);
data.BodyAsJson = settings.DefaultJsonConverter.Deserialize<object>(data.BodyAsString, JsonSerializationConstants.JsonConverterOptionsWithDateParsingNone);
data.DetectedBodyType = BodyType.Json;
}
catch
@@ -27,11 +27,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.3.9" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="AnyOf" Version="0.5.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.12.0" />
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.12.0" />
<PackageReference Include="JsonConverter.Newtonsoft.Json" Version="0.13.0" />
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.13.0" />
</ItemGroup>
<ItemGroup>
@@ -27,7 +27,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="TUnit.Core" Version="1.17.29" />
</ItemGroup>
@@ -38,7 +38,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="Testcontainers" Version="4.12.0" />
</ItemGroup>
@@ -23,7 +23,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="xunit.v3.extensibility.core" Version="3.2.2" />
</ItemGroup>
@@ -26,7 +26,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="Stef.Validation" Version="0.2.0" />
<PackageReference Include="Stef.Validation" Version="0.3.0" />
<PackageReference Include="xUnit.abstractions" Version="2.0.3" />
</ItemGroup>
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.1.0" />
<Sdk Name="Aspire.AppHost.Sdk" Version="13.4.0" />
<PropertyGroup>
<OutputType>Exe</OutputType>
@@ -19,7 +19,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.1.1" />
<PackageReference Include="Aspire.Hosting.AppHost" Version="13.4.3" />
<!-- CVE-2026-48109 -->
<PackageReference Include="MessagePack" Version="2.5.302" />
</ItemGroup>
<ItemGroup>
@@ -14,7 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aspire.Hosting.Testing" Version="13.1.1" />
<PackageReference Include="Aspire.Hosting.Testing" Version="13.4.3" />
<PackageReference Include="Codecov" Version="1.13.0" />
<PackageReference Include="coverlet.msbuild" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
@@ -25,13 +25,16 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<!-- CVE-2026-48109 -->
<PackageReference Include="MessagePack" Version="2.5.302" />
</ItemGroup>
<ItemGroup>
@@ -92,17 +92,11 @@ public class WireMockServerBuilderExtensionsTests
Tag = "latest"
});
var endpointAnnotation = wiremock.Resource.Annotations.OfType<EndpointAnnotation>().FirstOrDefault();
endpointAnnotation.Should().BeEquivalentTo(new EndpointAnnotation(
protocol: ProtocolType.Tcp,
uriScheme: "http",
transport: null,
name: null,
port: port,
targetPort: 80,
isExternal: null,
isProxied: true
));
var endpointAnnotation = wiremock.Resource.Annotations.OfType<EndpointAnnotation>().First();
endpointAnnotation.Protocol.Should().Be(ProtocolType.Tcp);
endpointAnnotation.UriScheme.Should().Be("http");
endpointAnnotation.Port.Should().Be(port);
endpointAnnotation.TargetPort.Should().Be(80);
wiremock.Resource.Annotations.OfType<EnvironmentCallbackAnnotation>().FirstOrDefault().Should().NotBeNull();
wiremock.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().FirstOrDefault().Should().NotBeNull();
@@ -153,39 +147,24 @@ public class WireMockServerBuilderExtensionsTests
endpointAnnotations.Should().HaveCount(3);
var endpointAnnotationForHttp80 = endpointAnnotations[0];
endpointAnnotationForHttp80.Should().BeEquivalentTo(new EndpointAnnotation(
protocol: ProtocolType.Tcp,
uriScheme: "http",
transport: null,
name: null,
port: null,
targetPort: 80,
isExternal: null,
isProxied: true
));
endpointAnnotationForHttp80.Protocol.Should().Be(ProtocolType.Tcp);
endpointAnnotationForHttp80.UriScheme.Should().Be("http");
endpointAnnotationForHttp80.Port.Should().BeNull();
endpointAnnotationForHttp80.TargetPort.Should().Be(80);
var endpointAnnotationForHttpFreePort = endpointAnnotations[1];
endpointAnnotationForHttpFreePort.Should().BeEquivalentTo(new EndpointAnnotation(
protocol: ProtocolType.Tcp,
uriScheme: "http",
transport: null,
name: $"http-{freePorts[0]}",
port: freePorts[0],
targetPort: freePorts[0],
isExternal: null,
isProxied: true
));
endpointAnnotationForHttpFreePort.Protocol.Should().Be(ProtocolType.Tcp);
endpointAnnotationForHttpFreePort.UriScheme.Should().Be("http");
endpointAnnotationForHttpFreePort.Name.Should().Be($"http-{freePorts[0]}");
endpointAnnotationForHttpFreePort.Port.Should().Be(freePorts[0]);
endpointAnnotationForHttpFreePort.TargetPort.Should().Be(freePorts[0]);
var endpointAnnotationForGrpcFreePort = endpointAnnotations[2];
endpointAnnotationForGrpcFreePort.Should().BeEquivalentTo(new EndpointAnnotation(
protocol: ProtocolType.Tcp,
uriScheme: "grpc",
transport: null,
name: $"grpc-{freePorts[1]}",
port: freePorts[1],
targetPort: freePorts[1],
isExternal: null,
isProxied: true
));
endpointAnnotationForGrpcFreePort.Protocol.Should().Be(ProtocolType.Tcp);
endpointAnnotationForGrpcFreePort.UriScheme.Should().Be("grpc");
endpointAnnotationForGrpcFreePort.Name.Should().Be($"grpc-{freePorts[1]}");
endpointAnnotationForGrpcFreePort.Port.Should().Be(freePorts[1]);
endpointAnnotationForGrpcFreePort.TargetPort.Should().Be(freePorts[1]);
wiremock.Resource.Annotations.OfType<EnvironmentCallbackAnnotation>().FirstOrDefault().Should().NotBeNull();
wiremock.Resource.Annotations.OfType<CommandLineArgsCallbackAnnotation>().FirstOrDefault().Should().NotBeNull();
@@ -16,7 +16,7 @@
<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -24,7 +24,7 @@
</PackageReference>
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
@@ -11,12 +11,12 @@
<ItemGroup>
<PackageReference Include="AwesomeAssertions" Version="9.4.0" />
<PackageReference Include="coverlet.collector" Version="8.0.1">
<PackageReference Include="coverlet.collector" Version="10.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="WireMock.Net" Version="2.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="WireMock.Net" Version="2.10.0" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
@@ -416,4 +416,20 @@ public class JsonPartialWildcardMatcherTests
// Assert
Assert.Equal(1.0, match);
}
}
[Fact]
public void JsonPartialWildcardMatcher_IsMatch_WithRegexTrue_DateFormat_ShouldMatch()
{
// Assign
var matcher = new JsonPartialWildcardMatcher(
new { date = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$", id = 1 },
ignoreCase: false,
regex: true);
// Act
var match = matcher.IsMatch("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}").Score;
// Assert
Assert.Equal(1.0, match);
}
}
@@ -366,17 +366,33 @@ public class SystemTextJsonPartialWildcardMatcherTests
Assert.Equal(1.0, match);
}
[Fact]
public void SystemTextJsonPartialWildcardMatcher_IsMatch_JsonElement_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonPartialWildcardMatcher(new { Id = 1, Name = "Test" });
[Fact]
public void SystemTextJsonPartialWildcardMatcher_IsMatch_JsonElement_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonPartialWildcardMatcher(new { Id = 1, Name = "Test" });
// Act
var jsonElement = JsonDocument.Parse("{ \"Id\" : 1, \"Name\" : \"Test\", \"Extra\" : \"value\" }").RootElement;
var match = matcher.IsMatch(jsonElement).Score;
// Act
var jsonElement = JsonDocument.Parse("{ \"Id\" : 1, \"Name\" : \"Test\", \"Extra\" : \"value\" }").RootElement;
var match = matcher.IsMatch(jsonElement).Score;
// Assert
Assert.Equal(1.0, match);
// Assert
Assert.Equal(1.0, match);
}
[Fact]
public void SystemTextJsonPartialWildcardMatcher_IsMatch_WithRegexTrue_DateFormat_ShouldMatch()
{
// Assign
var matcher = new SystemTextJsonPartialWildcardMatcher(
new { date = "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$", id = 1 },
ignoreCase: false,
regex: true);
// Act
var match = matcher.IsMatch("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}").Score;
// Assert
Assert.Equal(1.0, match);
}
}
}
@@ -69,7 +69,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.6.0" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -53,6 +53,81 @@ public partial class WireMockServerTests
response.Should().BeEquivalentTo("{\"first_name\":\"John\",\"last_name\":\"Smith\"}");
}
[Fact]
public async Task WireMockServer_WithBodyAsJson_WithJsonPartialWildcardMatcher()
{
// Arrange
using var server = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(testOutputHelper)
});
server
.Given(
Request.Create()
.WithPath("/test")
.UsingPost()
.WithBody(new JsonPartialWildcardMatcher(
new
{
date = @"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$",
id = 1
},
ignoreCase: true,
regex: true
)
)
)
.RespondWith(Response.Create().WithStatusCode(200).WithBody("matched"));
// Act
var requestUri = new Uri($"http://localhost:{server.Port}/test");
var response = await server.CreateClient().PostAsync(requestUri, new StringContent("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}"), _ct);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
server.Stop();
}
[Fact]
public async Task WireMockServer_WithBodyAsJson_WithSystemTextJsonPartialWildcardMatcher()
{
// Arrange
using var server = WireMockServer.Start(new WireMockServerSettings
{
Logger = new TestOutputHelperWireMockLogger(testOutputHelper),
DefaultJsonSerializer = new SystemTextJsonConverter()
});
server
.Given(
Request.Create()
.WithPath("/test")
.UsingPost()
.WithBody(new SystemTextJsonPartialWildcardMatcher(
new
{
date = @"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$",
id = 1
},
ignoreCase: true,
regex: true
)
)
)
.RespondWith(Response.Create().WithStatusCode(200).WithBody("matched"));
// Act
var requestUri = new Uri($"http://localhost:{server.Port}/test");
var response = await server.CreateClient().PostAsync(requestUri, new StringContent("{\"date\":\"2026-06-09T22:23:18.53421+00:00\",\"id\":1}"), _ct);
// Assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
server.Stop();
}
[Fact]
public async Task WireMockServer_WithBodyAsJson_Using_PostAsJsonAsync_And_MultipleJmesPathMatchers_ShouldMatch()
{