use of org.mockito.internal.verification.InOrderContextImpl in project mockito by mockito.
the class AtLeastXNumberOfInvocationsCheckerTest method shouldReportTooLittleInvocationsInOrder.
@Test
public void shouldReportTooLittleInvocationsInOrder() {
InOrderContext context = new InOrderContextImpl();
//given
Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
exception.expect(VerificationInOrderFailure.class);
exception.expectMessage("iMethods.simpleMethod()");
exception.expectMessage("Wanted *at least* 2 times");
exception.expectMessage("But was 1 time");
//when
checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 2, context);
}
use of org.mockito.internal.verification.InOrderContextImpl in project mockito by mockito.
the class InvocationMarkerTest method shouldMarkInvocationsAsVerifiedInOrder.
@Test
public void shouldMarkInvocationsAsVerifiedInOrder() {
//given
InOrderContextImpl context = new InOrderContextImpl();
Invocation i = new InvocationBuilder().toInvocation();
InvocationMatcher im = new InvocationBuilder().toInvocationMatcher();
assertFalse(context.isVerified(i));
assertFalse(i.isVerified());
//when
InvocationMarker.markVerifiedInOrder(Arrays.asList(i), im, context);
//then
assertTrue(context.isVerified(i));
assertTrue(i.isVerified());
}
use of org.mockito.internal.verification.InOrderContextImpl in project mockito by mockito.
the class InvocationsFinderTest method shouldFindFirstUnverifiedInOrderAndRespectSequenceNumber.
@Test
public void shouldFindFirstUnverifiedInOrderAndRespectSequenceNumber() throws Exception {
//given
InOrderContextImpl context = new InOrderContextImpl();
assertSame(simpleMethodInvocation, InvocationsFinder.findFirstUnverifiedInOrder(context, invocations));
//when
//skipping verification of first invocation, then:
context.markVerified(simpleMethodInvocationTwo);
context.markVerified(differentMethodInvocation);
//then
assertSame(null, InvocationsFinder.findFirstUnverifiedInOrder(context, invocations));
}
use of org.mockito.internal.verification.InOrderContextImpl in project mockito by mockito.
the class InvocationsFinderTest method shouldFindFirstUnverifiedInOrder.
@Test
public void shouldFindFirstUnverifiedInOrder() throws Exception {
//given
InOrderContextImpl context = new InOrderContextImpl();
assertSame(simpleMethodInvocation, InvocationsFinder.findFirstUnverifiedInOrder(context, invocations));
//when
context.markVerified(simpleMethodInvocationTwo);
context.markVerified(simpleMethodInvocation);
//then
assertSame(differentMethodInvocation, InvocationsFinder.findFirstUnverifiedInOrder(context, invocations));
//when
context.markVerified(differentMethodInvocation);
//then
assertNull(InvocationsFinder.findFirstUnverifiedInOrder(context, invocations));
}
use of org.mockito.internal.verification.InOrderContextImpl in project mockito by mockito.
the class AtLeastXNumberOfInvocationsCheckerTest method shouldMarkActualInvocationsAsVerifiedInOrder.
@Test
public void shouldMarkActualInvocationsAsVerifiedInOrder() {
InOrderContext context = new InOrderContextImpl();
//given
Invocation invocation = new InvocationBuilder().simpleMethod().toInvocation();
Invocation invocationTwo = new InvocationBuilder().differentMethod().toInvocation();
//when
checkAtLeastNumberOfInvocations(asList(invocation, invocationTwo), new InvocationMatcher(invocation), 1, context);
//then
assertThat(invocation.isVerified()).isTrue();
}
Aggregations