I'm doing something like this in my test
- (void)testSomething {
__block BOOL isActive = NO;
void (^doSomething)(void) = ^void(void) {
isActive = YES;
.....
}
[[someMock stub] andDo:^(NSInvocation *invocation) {
NSValue *returnValue =
[NSValue valueWithBytes:&isRegistrationClientActive
objCType:@encode(BOOL)];
[invocation setReturnValue:&returnValue];
}] isSomeMockActive];
[self.someObject doSomethingWithHandler:doSomething];
/// === verify ===
}
What I've observed is when isSomeMockActive is hit my isActive is correct NO and then YES but invariably what is being returned by isSomeMockActive is always NO.
PS: I've tried using [self.mock stub] andReturnValue:...] and that seems to be having the same issue.
Is there anything wrong I'm doing?
Aucun commentaire:
Enregistrer un commentaire