use of org.mockitousage.IMethods in project mockito by mockito.
the class StubbingWithAdditionalAnswersTest method will_execute_a_void_based_on_strongly_typed_three_parameter_function.
@Test
public void will_execute_a_void_based_on_strongly_typed_three_parameter_function() throws Exception {
final IMethods target = mock(IMethods.class);
given(iMethods.threeArgumentMethodWithStrings(anyInt(), anyString(), anyString())).will(answerVoid(new VoidAnswer3<Integer, String, String>() {
public void answer(Integer i, String s1, String s2) {
target.threeArgumentMethodWithStrings(i, s1, s2);
}
}));
// invoke on iMethods
iMethods.threeArgumentMethodWithStrings(1, "string1", "string2");
// expect the answer to write correctly to "target"
verify(target, times(1)).threeArgumentMethodWithStrings(1, "string1", "string2");
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class VerificationCollectorImplTest method should_not_throw_any_exceptions_when_verifications_are_succesful.
@Test
public void should_not_throw_any_exceptions_when_verifications_are_succesful() {
VerificationCollector collector = MockitoJUnit.collector().assertLazily();
IMethods methods = mock(IMethods.class);
methods.simpleMethod();
verify(methods).simpleMethod();
collector.collectAndReport();
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class ModellingDescriptiveMessagesTest method shouldSayUnstubbedMethodWasInvokedHere.
@Test
public void shouldSayUnstubbedMethodWasInvokedHere() {
mock = mock(IMethods.class, RETURNS_SMART_NULLS);
IMethods m = mock.iMethodsReturningMethod();
m.simpleMethod();
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_verify_called_n_times_for_serialized_mock.
@Test
public void should_verify_called_n_times_for_serialized_mock() throws Exception {
IMethods mock = mock(IMethods.class, withSettings().serializable());
List<?> value = Collections.emptyList();
when(mock.objectArgMethod(anyString())).thenReturn(value);
mock.objectArgMethod("");
// when
ByteArrayOutputStream serialized = serializeMock(mock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
verify(readObject, times(1)).objectArgMethod("");
}
use of org.mockitousage.IMethods in project mockito by mockito.
the class MocksSerializationTest method should_serialize_method_calls_using_any_string_matcher.
@Test
public void should_serialize_method_calls_using_any_string_matcher() throws Exception {
IMethods mock = mock(IMethods.class, withSettings().serializable());
List<?> value = Collections.emptyList();
when(mock.objectArgMethod(anyString())).thenReturn(value);
// when
ByteArrayOutputStream serialized = serializeMock(mock);
// then
IMethods readObject = deserializeMock(serialized, IMethods.class);
assertEquals(value, readObject.objectArgMethod(""));
}
Aggregations