when top-level property
Expectation
get
when
Create a stub method response.
Call a method on a mock object within the call to when, and call a
canned response method on the result. For example:
when(cat.eatFood("fish")).thenReturn(true);
Mockito will store the fake call to cat.eatFood, and pair the exact
arguments given with the response. When cat.eatFood is called outside a
when or verify context (a call "for real"), Mockito will respond with
the stored canned response, if it can match the mock method parameters.
The response generators include thenReturn, thenAnswer, and thenThrow.
See the README for more information.
Implementation
Expectation get when {
if (_whenCall != null) {
throw StateError('Cannot call `when` within a stub response');
}
_whenInProgress = true;
return <T>(T _) {
_whenInProgress = false;
return PostExpectation<T>();
};
}