Stub dependencies with when()
masterUse when() to define canned responses for method calls on a mock object. To prevent side effects or unexpected behavior during the setup phase, you must wrap your stubbing logic between startStubbing() and stopStubbing().
fflib_ApexMocks mocks = new fflib_ApexMocks();
fflib_MyList.IList mockList = (fflib_MyList.IList)mocks.mock(fflib_MyList.class);
mocks.startStubbing();
mocks.when(mockList.get(0)).thenReturn('bob');
mocks.when(mockList.get(1)).thenReturn('fred');
mocks.stopStubbing();