<#464 Matching fails on double / float / decimal w...
# pact-net
g
#464 Matching fails on double / float / decimal with integer value Issue created by Manny651 When a match condition is a decimal number with an integer value, there is a verification mismatch when the JSON value is represented by a integer. Example:
Copy code
var 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:
Copy code
{
  "actual": "10",
  "expected": "10.0",
  "mismatch": "Expected '10.0' to be equal to '10'",
  "path": "$.value",
  "type": "BodyMismatch"
}
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-net