0

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?

Jon Reid
  • 20,545
  • 2
  • 64
  • 95
CarmeloS
  • 7,868
  • 8
  • 56
  • 103

1 Answers1

1
[[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).

Jon Reid
  • 20,545
  • 2
  • 64
  • 95