erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

When I OCMProtocolMock a protocol(This protocol has a method),How can I invoke the real implementation of the method #514

Closed samiu980728 closed 2 years ago

samiu980728 commented 2 years ago

code show as below:

- (void)test_method {
    id mockDelegate = OCMProtocolMock(@protocol(adDelegate));
    OCMExpect([mockDelegate adLoaded:OCMOCK_ANY error:OCMOCK_ANY]);
    self.delegate = mockDelegate;
    if ([self.delegate respondsToSelector:@selector(adLoaded:error:)]) {
         [self.delegate adLoaded:array error:nil];
    }
    OCMVerifyAllWithDelay(mockDelegate, 15);
}

// adDelegate callback method
- (void)adLoaded:array:(NSArray*)array error:(NSError *)error {
    ......
    ......
}

Because I let:self.delegate = mockDelegate,So this method cannot be invoked.

How can I invoke the real implementation of the method?

dmaclach commented 2 years ago

I'm going to channel my inner Erik and suggest that this is something that should go on stackoverflow. See the first paragraph here: https://ocmock.org/support/

samiu980728 commented 2 years ago

I'm going to channel my inner Erik and suggest that this is something that should go on stackoverflow. See the first paragraph here: https://ocmock.org/support/

stackoverflow QA:https://stackoverflow.com/questions/70752837/ocmockocmprotocolmockocmstubwhen-i-ocmprotocolmock-a-protocolthis-protoco

Question asked a week ago

dmaclach commented 2 years ago

Responded on StackOverflow.

samiu980728 commented 2 years ago

Thanks a million.