public void GetMatchingMockInteraction_WithInteractionsNull_ThrowsPactFailureException() { var context = new NancyContext(); context.Items[Constants.PactMockInteractionsKey] = null; Assert.Throws<PactFailureException>(() => context.GetMatchingMockInteraction(HttpVerb.Get, "/events")); }
private Response HandlePactRequest(NancyContext context) { var actualRequest = _requestMapper.Convert(context.Request); var matchingInteraction = context.GetMatchingMockInteraction(actualRequest.Method, actualRequest.Path); _mockProviderRepository.AddHandledRequest(new HandledRequest(actualRequest, matchingInteraction)); return _responseMapper.Convert(matchingInteraction.Response); }
public void GetMatchingMockInteraction_WithNoMatchingInteraction_ThrowsPactFailureException() { var interactions = new List<ProviderServiceInteraction> { new ProviderServiceInteraction { Request = new ProviderServiceRequest { Method = HttpVerb.Get, Path = "/hello" }, Response = new ProviderServiceResponse()} }; var context = new NancyContext(); context.SetMockInteraction(interactions); Assert.Throws<PactFailureException>(() => context.GetMatchingMockInteraction(HttpVerb.Get, "/events")); }
public void GetMatchingMockInteraction_WithNoInteractions_ThrowsPactFailureException() { var context = new NancyContext(); Assert.Throws<PactFailureException>(() => context.GetMatchingMockInteraction(HttpVerb.Get, "/events")); }
public void GetMatchingMockInteraction_WithOneMatchingInteraction_ReturnsInteraction() { var interactions = new List<ProviderServiceInteraction> { new ProviderServiceInteraction { Request = new ProviderServiceRequest { Method = HttpVerb.Get, Path = "/events" }, Response = new ProviderServiceResponse()}, new ProviderServiceInteraction { Request = new ProviderServiceRequest { Method = HttpVerb.Post, Path = "/events" }, Response = new ProviderServiceResponse()}, }; var context = new NancyContext(); context.SetMockInteraction(interactions); var result = context.GetMatchingMockInteraction(HttpVerb.Get, "/events"); Assert.Equal(interactions.First(), result); }