Search code examples
c#pactconsumercontractpact-net

Match any value from list of strings


I new pact testing, I have a pact consumer test in which a property can have any value from a defined set of string:

this.pact
        .ExpectsToReceive("an event indicating that an order has been created")
        .WithJsonContent(new
            {
               PayloadType = Match.MinType(new List<string> { "apple", "orange" }, 1),
           })

Not sure how to match PayloadType to have one value either "apple" or "orange". Please guide.


Solution

  • I used Match.Regex to achieve matching strings:

    this.pact
            .ExpectsToReceive("an event indicating that an order has been created")
            .WithJsonContent(new
                {
                   PayloadType = Match.Regex("apple", ("apple|orange")),
               })