GitHub
05/26/2023, 3:06 PMvar pact = Pact.V3("My API", "Consumer").WithHttpInteractions();
var body = new { value = 10m };
pact.UponReceiving("A request with decimals")
.WithRequest(<http://HttpMethod.Post|HttpMethod.Post>, "/test")
.WithJsonBody(body)
.WillRespond()
.WithStatus(HttpStatusCode.OK);
pact.Verify(context =>
{
var client = new HttpClient { BaseAddress = context.MockServerUri };
client.PostAsJsonAsync("/test", body).Wait();
});
Gives Verification mismatches:
It looks like the library expects the decimals to be serialized by Json.NET (which always serializes floats and decimals with a decimal point), unlike System.Text.Json or other frameworks. pact-foundation/pact-netCopy code{ "actual": "10", "expected": "10.0", "mismatch": "Expected '10.0' to be equal to '10'", "path": "$.value", "type": "BodyMismatch" }
GitHub
05/26/2023, 4:26 PM