The Testing things that involve dates or times and Testing things that involve randomness recipes show techniques for mocking relatively simple objects. In the case of the Testing things that involve dates or times recipe, the object being mocked is essentially stateless, and a single return value works nicely. In the Testing things that involve randomness recipe, the object has a state change, but the state change does not depend on any input arguments.
In these simpler cases, a test provides a series of requests to an object. Mock objects can be built which are based on a known and carefully planned sequence of state changes. The test case follows the object's internal state changes precisely. This is sometimes called white box testing because the implementation details of the object under test are required to define the test sequence and...