所以我在名为PopoverProvider
- (void)showPopoverForAction:(MESAction *)action fromRect:(CGRect)rect inView:(UIView *)view onDoneBlock:(MESActionPopoverDoneBlock)block;
我想验证它是这样被调用的:
// popoverProvider is a PopoverProvider
[[[popoverProvider expect] andReturn:mockRecipeIngredientViewController]
showPopoverForAction:[OCMArg any]
fromRect:[OCMArg any] // !!!!
inView:[OCMArg any]
onDoneBlock:[OCMArg any]
];
标记的行会导致问题:[OCMArg any]
在CGRect
s上不匹配,这是一种结构类型。
答案 0 :(得分:4)
在这种情况下,由于你不关心rect的值,我会使用:
[[[[popoverProvider expect] andReturn:mockRecipeIngredientViewController] ignoringNonObjectArgs]
showPopoverForAction:[OCMArg any]
fromRect:CGRectMake(0.0f,0.0f,0.0f,0.0f)
inView:[OCMArg any]
onDoneBlock:[OCMArg any]
];
如果你有一个案例,你想忽略一个结构,但检查另一个结构,你可以这样做:
[[[[[popoverProvider expect] andReturn:mockRecipeIngredientViewController] ignoringNonObjectArgs] andDo:^(NSInvocation *invocation) {
CGRect theSize;
[invocation getArgument:&theSize atIndex:6];
STAssertEquals(theSize, CGSizeMake(20.0f,20.0f), @"No match!");
}]
showPopoverForAction:[OCMArg any]
fromRect:CGRectMake(0.0f,0.0f,0.0f,0.0f)
inView:[OCMArg any]
onDoneBlock:[OCMArg any]
someSize:CGSizeMake(0.0f,0.0f)
];