One of the parameter of my method is **error and my project is in ARC mode. When writing stub for this method to call a mock method i set parameter to below possible values. Either it causes compile error or failing to match the argument to call the mock method.
- OCMOCK_ANY
- [OCMArg anyPointer]
- Created a NSError object error and said [OCMArg setTo:error].
Nothing works.
How to mock such method? Please advice.
Edit
-(id)init{
self = [super init];
if (self) {
id wcm = [OCMockObject partialMockForObject:self];
[[[wcm stub] andCall:@selector(mockGetWakeupCallsForRoomNumber:error:) onObject:self] getWakeupCallsForRoomNumber:OCMOCK_ANY error:((NSError __autoreleasing **) [OCMArg anyPointer])];
//[[[wcm stub] andCall:@selector(testMockMethod) onObject:self] testMethod];
}
return self;
}
-(void)testMethod
{
NSLog(@"Original");
}
-(void)testMockMethod
{
NSLog(@"Mock");
}
-(NSArray*)mockGetWakeupCallsForRoomNumber:(NSString*)roomNumber error:(NSError**)error
{
@throw @"Mock method called";
}
-(NSArray*)getWakeupCallsForRoomNumber:(NSString*)roomNumber error:(NSError**)error
{
}
Mock on testMockMethod works.