I have a class that handles all my network communications as follows:
typedef void (^ networkEndblock) (NSArray *, NSError *);
@interface NetworkAPI : NetworkBase
+ (void) doSomeNetworkAcion:(networkEndblock) endBlock;
@end
I use the above code like this (I don't want to go 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 testing method, I want to run runMyProcess for testing, I do not want it to go and get on the network, I want to control this and set the cases so that it returns an error, an empty array ... etc. I know how to use SenTest, and this is MACROS, but I can’t fake my network API.
I looked at the stubs and expected, but I was embarrassed if I can do what I want.
thanks
source
share