Reputation: 5
[[OCMExpect([[self.mockDelegate ignoringNonObjectArgs] adLoaded:OCMOCK_ANY statusChanged:statusStarted]) ignoringNonObjectArgs] andDo:^(NSInvocation *invocation) {
...
...
}];
I broke the point and found that andDo is only executed works once(when status==statusStarted
).The function is not triggered when status==statusEnded
.
But when I copied the above code and found that the andDo function was triggered when status==statusEnded
.
code show as below:
[[OCMExpect([[self.mockDelegate ignoringNonObjectArgs] adLoaded:OCMOCK_ANY statusChanged:statusStarted]) ignoringNonObjectArgs] andDo:^(NSInvocation *invocation) {
...
...
}];
[[OCMExpect([[self.mockDelegate ignoringNonObjectArgs] adLoaded:OCMOCK_ANY statusChanged:statusStarted]) ignoringNonObjectArgs] andDo:^(NSInvocation *invocation) {
...
...
}];
After experimenting I found that OCMVerifyAllWithDelay(self.adMockDelegate, 10) is not equivalent to:
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(10 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
OCMVerifyAll(self.adMockDelegate);
});
OCMVerifyAllWithDelay blocks the thread for 10 seconds,instead of extending the verification time of the mock by 10 seconds.why?
Upvotes: 0
Views: 98