Guest User

Untitled

a guest
Dec 22nd, 2012
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. - (void)testApiClass {
  2. //Check object
  3. NSString* classKey = @"Api";
  4. id obj = NSClassFromString(classKey);
  5. STAssertNotNil(obj, [NSString stringWithFormat:@"Model '%@' not found.", classKey]);
  6. //Check properties
  7. NSArray* properties =
  8. @[
  9. @"performSyncRequestWithUri::",
  10. @"performAsyncRequestWithUri:::",
  11. ];
  12. for (NSString* property in properties) {
  13. SEL propertySel = NSSelectorFromString(property);
  14. BOOL isRespondsToSel = [obj respondsToSelector:propertySel];
  15. STAssertTrue(isRespondsToSel, [NSString stringWithFormat:@"Property '%@' not found on object of class name '%@'", property, [obj class]]);
  16. }
  17. }
  18.  
  19.  
  20. @interface Api : NSObject
  21.  
  22. - (NSDictionary*)performSyncRequestWithUri:(NSString *)requestUri params:(NSDictionary *)params;
  23. - (void)performAsyncRequestWithUri:(NSString *)requestUri params:(NSDictionary *)params completionHandler:(void (^)(NSDictionary *, NSError *))completionBlock;
  24.  
  25. @end
  26.  
  27. SEL selectors[] = {
  28. @selector(performSyncRequestWithUri:params:),
  29. @selector(performAsyncRequestWithUri:params:completionHandler:),
  30. NULL
  31. };
  32.  
  33. for (size_t i = 0; selectors[i]; ++i) {
  34. SEL selector = selectors[i];
  35. BOOL respondsToSelector = [obj respondsToSelector:selector];
  36. STAssertTrue(respondsToSelector, [NSString stringWithFormat:
  37. @"Object %@ doesn't respond to selector %s",
  38. obj, sel_getName(selector)]);
  39. }
Add Comment
Please, Sign In to add comment