Reputation: 7938
Let's say that I have a method like this
[SomeObject someMethod:(id)object someRect:(CGRect)rect];
When doing unit test, I want to very that this function is called with a specific object and any rect, but this code doesn't work:
[verifyCount(mockObject, MKTTimes(1)) someMethod:HC_equalTo(message) someRect:HC_anything()];
Compiler would say that HC_anything is not a CGRect.
Is there any way to solve this?
Upvotes: 0
Views: 98
Reputation: 20980
[[verify(mockObject) withMatcher:anything() forArgument:1]
someMethod:message someRect:CGRectZero];
Basically, pass in a rect that will be ignored, because we've overridden the matching using withMatcher:forArgument:
…Note that verify
is short for verifyCount
with times(1)
. Also, passing message
directly is short for equalTo(message)
.
Upvotes: 1