public void When_verifying_at_or_below_call_count_should_be_true(int callCount, int verifyCount, bool expected) { IsSent atMost = IsSent.AtMost(callCount); // Assert atMost.Verify(verifyCount).Should().Be(expected); }
public void When_verifying_at_or_above_call_count_should_be_true(int verifyCount, bool expected) { IsSent atLeastOnce = IsSent.AtLeastOnce(); // Assert atLeastOnce.Verify(verifyCount).Should().Be(expected); }
public void When_verifying_anything_other_than_1_should_be_false(int verifyCount, bool expected) { IsSent once = IsSent.Once(); // Assert once.Verify(verifyCount).Should().Be(expected); }
public void When_verifying_more_than_0_should_be_false(int verifyCount, bool expected) { IsSent never = IsSent.Never(); // Assert never.Verify(verifyCount).Should().Be(expected); }
public void When_verifying_above_or_below_call_count_should_be_false(int callCount, int verifyCount, bool expected) { IsSent exactly = IsSent.Exactly(callCount); // Assert exactly.Verify(verifyCount).Should().Be(expected); }
/// <summary> /// Verifies that a request matching the specified match conditions has been sent. /// </summary> /// <param name="matching">The conditions to match.</param> /// <param name="times">The number of times a request is allowed to be sent.</param> /// <param name="because">The reasoning for this expectation.</param> public async Task VerifyAsync(Action <RequestMatching> matching, IsSent times, string because = null) { if (matching is null) { throw new ArgumentNullException(nameof(matching)); } if (times is null) { times = IsSent.AtLeastOnce(); } var rm = new RequestMatching(); matching(rm); IReadOnlyCollection <IAsyncHttpRequestMatcher> matchers = rm.Build(); IReadOnlyList <IInvokedHttpRequest> matchedRequests = InvokedRequests; if (matchers.Count > 0) { var list = new List <IInvokedHttpRequest>(); foreach (IInvokedHttpRequest invokedHttpRequest in InvokedRequests) { var requestContext = new MockHttpRequestContext(invokedHttpRequest.Request); if (await matchers.AllAsync(requestContext).ConfigureAwait(false)) { list.Add(invokedHttpRequest); } } matchedRequests = list; } if (!times.Verify(matchedRequests.Count)) { throw new HttpMockException(times.GetErrorMessage(matchedRequests.Count, BecauseMessage(because))); } foreach (InvokedHttpRequest r in matchedRequests.Cast <InvokedHttpRequest>()) { r.MarkAsVerified(); } }