I do have a class that handles all my network communication like this:
typedef void (^ networkEndblock) (NSArray *, NSError *);
@interface NetworkAPI : NetworkBase
+ (void) doSomeNetworkAcion:(networkEndblock) endBlock;
@end
I use the above code like this (I do not want to get into irrelevant details here)
- (void) runMyProcess:(SomeEndBlock)proccesEnded{
// Bussiness logic
// Get Data from the web
[NetworkAPI doSomeNetworkAcion:^(NSArray *resultArray, NSError *error){
// Check for error. if we have error then do error handling
// If no error, check for array.
// If array is empty then go to code that handles empty array
// else Process data
}];
}
In my test method I want to trigger runMyProcess to test, I do not want it to go and hit the network, I want to control that and set cases to make it return an error, empty array ...etc. I know how to use SenTest and it is MACROS but I do not how to fake my network API.
I looked into stubs and expect but I got confused if I can do what I want.
Thanks