public void ShouldReturnVerificationMessagesWhenHandlerThrowsPactVerificationException()
        {
            var verificationMessages = PactVerifier.InvokeProviderStateHandler(
                new List <ProviderState> {
                new ProviderState {
                    Name = "ps1"
                }
            },
                (p) => throw new PactVerificationException("Unknown provider state."));

            Assert.AreEqual($"Provider could not handle provider state \"ps1\": Unknown provider state.", verificationMessages.First());
        }
 public void ShouldThrowPactExceptionWhenProviderStateHandlerThrowsAnyOtherException()
 {
     try
     {
         PactVerifier.InvokeProviderStateHandler(new List <ProviderState> {
             new ProviderState {
                 Name = "ps1"
             }
         }, (p) => throw new ArgumentNullException());
     }
     catch (PactException e)
     {
         Assert.AreEqual("Exception occured while invoking ProviderStateHandler.", e.Message);
         throw;
     }
 }
 public void ShouldThrowPactExceptionWhenProviderStateHandlerIsNotConfigured()
 {
     try
     {
         PactVerifier.InvokeProviderStateHandler(new List <ProviderState> {
             new ProviderState {
                 Name = "ps1"
             }
         }, null);
     }
     catch (PactException e)
     {
         Assert.AreEqual("Cannot verify this Pact contract because a ProviderStateHandler was not configured.", e.Message);
         throw;
     }
 }
        public void ShouldInvokeProviderStateHandlerForEveryProviderState()
        {
            var invocations = new List <string>();

            PactVerifier.InvokeProviderStateHandler(
                new List <ProviderState> {
                new ProviderState {
                    Name = "ps1"
                }, new ProviderState {
                    Name = "ps2"
                }
            },
                (p) => invocations.Add(p.Name));

            Assert.AreEqual(2, invocations.Count);
        }