AGWaitForAsyncTestHelper icon indicating copy to clipboard operation
AGWaitForAsyncTestHelper copied to clipboard

Possibility to expect

Open hfossli opened this issue 12 years ago • 1 comments

We should have the possibility to set expectations. Like so:

static NSString *userId = @"asdf"; 
DummyViewController *viewController = [[DummyViewController alloc] initWithNibName:nil bundle:nil];
AGMockObject *managerMock = [AGMockObject mockForClass:[Manager class]];
[[managerMock expect] fetchDataForUserId:userId]; // we are expecting controller to call this method
viewController.manager = managerMock; 
viewController.userId = userId;

/*
We are waiting 0.1 seconds
We expect fetchDataForUserId: to be called with @"asdf" as argument
The trigger block will only trigger the viewController to actually do the expected method-call (example)
*/
[managerMock waitMax:0.1 andExpectWithTrigger:^{
    [viewController udpateUser]; 
}];

alternatively

WAIT_WHILE(![managerMock expectationsFulfilled], 1.0);
[managerMock verify];

This should really be implemented

hfossli avatar Apr 18 '13 08:04 hfossli

It could possibly be done with an additional method on OCMockObject ?

hfossli avatar Apr 18 '13 08:04 hfossli