I am new to OCMockObjects and trying to mock an instance method of ACAccount class:
-(NSArray *)accountsWithAccountType:(ACAccountType *)accountType;
I wrote this code in the test class to intialize mockObject:
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
id mockAccountStore = [OCMockObject partialMockForObject:accountStore];
[[[mockAccountStore stub] andReturn:@[@"someArray"]] accountsWithAccountType:[OCMArg any]];
//call the test method
[myClassInstance methodToTest];
In myClass the methodToTest looks like this:
-(void) methodToTest
{
ACAccountStore *accountStore = [[ACAccountStore alloc] init];
ACAccountType* accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray* expectedArray = [accountStore accountsWithAccountType:accountType];
//Getting nil value to Array rather than the returned value in stub
}
Any idea what am i doing wrong here. Thanks.