Permalink
Browse files

Improved test code.

  • Loading branch information...
1 parent fde4b24 commit 214aba2d41b9ef2144a067de49af0489d8523c82 @neonichu committed Feb 4, 2012
Showing with 22 additions and 15 deletions.
  1. +22 −15 Example/VUAppDelegate.m
View
@@ -35,6 +35,19 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}
+- (void)handleThing:(VUFlattrThing*)thing {
+ NSLog(@"Thing found: %@", thing);
+
+ [thing flattrThisWithCompletionHandler:^(id data, NSError *error) {
+ if (!data) {
+ [self alertForError:error];
+ return;
+ }
+
+ NSLog(@"Flattred a thing: %@", data);
+ }];
+}
+
- (void)lookUpThingWithUrl:(NSURL*)url user:(VUFlattrUser*)user {
[user thingForURL:url completionHandler:^(id data, NSError *error) {
if (!data) {
@@ -44,21 +57,15 @@ - (void)lookUpThingWithUrl:(NSURL*)url user:(VUFlattrUser*)user {
return;
}
- NSLog(@"Things found: %@", data);
+ NSAssert([data count] > 0, @"Flattr search returned empty result.");
+ data = [data objectAtIndex:0];
+
+ [self handleThing:data];
}];
return;
}
- NSLog(@"Thing found: %@", data);
-
- [data flattrThisWithCompletionHandler:^(id data, NSError *error) {
- if (!data) {
- [self alertForError:error];
- return;
- }
-
- NSLog(@"Flattred a thing: %@", data);
- }];
+ [self handleThing:data];
}];
}
@@ -82,11 +89,11 @@ - (void)loginToFlattr {
NSLog(@"Things for user: %@", data);
}];
- //NSURL* bamRealURL = [NSURL URLWithString:@"http://breakfast.vu0.org/"];
- NSURL* bamFlattrURL = [NSURL URLWithString:@"http://manuspielt.wordpress.com/2010/11/26/breakfast-at-manuspielts/"];
+ NSURL* bamRealURL = [NSURL URLWithString:@"http://breakfast.vu0.org/"];
+ //NSURL* bamFlattrURL = [NSURL URLWithString:@"http://manuspielt.wordpress.com/2010/11/26/breakfast-at-manuspielts/"];
- //[self lookUpThingWithUrl:bamRealURL user:user];
- [self lookUpThingWithUrl:bamFlattrURL user:user];
+ [self lookUpThingWithUrl:bamRealURL user:user];
+ //[self lookUpThingWithUrl:bamFlattrURL user:user];
//[user autosubmitURL:bamFlattrURL];
} scope:VUFlattrScope_Flattr];

0 comments on commit 214aba2

Please sign in to comment.