Reputation: 10127
In OCMock there is the method OCMVerify
to verify interactions. So I did the following with MyObjectData
being a simple value holder class.
OCMVerify([dataStore createOrUpdateMyObject:[OCMArg isKindOfClass:[MyObjectData class]]]);
This works, but is not enough, since I want to verify that the method isn't called with any object of this class but with the correct values. So I did the following:
// ...
OCMVerify([dataStore createOrUpdateMyObject:[OCMArg checkWithSelector:@selector(verifyMyObjectDataAfterSave:) onObject:self]]);
}
- (BOOL)verifyMyObjectDataAfterSave:(id)obj {
return YES;
}
But the obj
parameter is not the MyObjectData
instance I expect to be passed but an instance of OCMVerifier
which is a proxy to the mocked data store.
Now the question is, how can I verify the argument correctly?
Upvotes: 1
Views: 1858
Reputation: 1568
Can you use an expectation?
id mockObj = OCMPartialMock(dataStore);
OCMExpect([mockObj createOrUpdateMyObject:[OCMArg checkWithBlock:^BOOL(MyObjectData *value)
{
XCTAssertEqual(value.someProperty, 999);
return [value isKindOfClass:[MyObjectData class]];
}]]);
[mockObj someMethod];
OCMVerifyAll(mockObj);
Upvotes: 2