Mattersight / pact-net-messages

Pact.Net v3 implementation of message only for services that communicate via event streams and message queues
MIT License
10 stars 5 forks source link

Pact format for regex matcher is not recognized by provider verification test #3

Open Gokulaprakash opened 5 years ago

Gokulaprakash commented 5 years ago

The pact format generated by pact-net-message library looks like below. The matcher format generated is not recognized as matcher by the verfiication and keeps giving me error as Path $.Property1.json_class, expected: Pact::Term, actual:

{
  "provider": {
    "name": "test-provider-amqp"
  },
  "consumer": {
    "name": "test-consumer-amqp"
  },
  "messages": [
    {
      "description": "Verify the payload contract is satisfied",
      "providerState": "Pay load",
      "contents": {
        "EventName": "test.message",
        "Property1": {
          "json_class": "Pact::Term",
          "data": {
            "generate": "83F9262F-28F1-4703-AB1A-8CFD9E8249C9",
            "matcher": {
              "json_class": "Regexp",
              "o": 0,
              "s": "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"
            }
          }
        }
      },
      "metaData": {
        "routingKey": "test.message"
      }
    }
  ],
  "metadata": {
    "pactSpecificationVersion": "3.0"
  }
}

Here's the pact generation code:

           var guidRegex = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
            var eventName = "test.message";
            var guid = "83F9262F-28F1-4703-AB1A-8CFD9E8249C9";

            dynamic eventData = new
            {
                EventName = eventName,
                Property1 = Match.Regex(guid, guidRegex)
            };

            amqpProvider.PactMessageBuilder.MockMq().Given("Pay load")
                .UponReceiving("Verify the payload contract is satisfied")
                .WithMetaData(new { routingKey = "test.message" })
                .WithContent(eventData);