Match any value from list of strings

104 views Asked by At

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.

1

There are 1 answers

0
User3250 On BEST ANSWER

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")),
           })