在我的应用委托类中,我有一个简单的属性
@property (strong, nonatomic) LoginAppDelegate *loginAppDelegate;
然后我在这里卸载所有登录视图的应用程序委托功能,这样我就可以保持我的主应用程序委托类很小(ish)
然后在登录应用程序委托上,我有一种方法可以在主导航控制器上推送视图控制器
- (void)launchSomeOtherViewController {}
痛苦的部分是当我在调用这个“启动”方法的视图控制器中时
- (void)callBackAfterSomeHttpMethodLetsSay
{
[self.appDelegate.loginAppDelegate launchSomeOtherViewController];
}
当我尝试对此进行模拟时,似乎我在应用程序委托上的存根不正确
- (void)testCallBackWithSignupTokenInvokesLaunchCompleteSignupViewControllerWithToken
{
id mockLoginAppDelegate = [OCMockObject mockForClass:[LoginAppDelegate class]];
id mockAppDelegate = [OCMockObject mockForClass:[AppDelegate class]];
[[[mockAppDelegate stub] andReturn:mockLoginAppDelegate] loginAppDelegate];
[[mockLoginAppDelegate expect] launchSomeOtherViewController];
[self.sut callBackAfterSomeHttpMethodLetsSay];
[mockLoginAppDelegate verify];
}
当我通过 ocunit 运行它时的错误是通常的“未调用预期的方法”
所以我的问题与我存根的方式有关-我可以做一个存根来返回登录模拟,还是我需要手动进入getter?