openapi-generator/samples/client/petstore/objc/tests/UserApiTest.m
2013-08-16 21:22:06 -07:00

48 lines
1.1 KiB
Objective-C

#import "UserApiTest.h"
@implementation UserApiTest
- (void)setUp {
[super setUp];
api = [[RVBUserApi alloc ]init];
}
- (void)tearDown {
[super tearDown];
}
- (void)testLoginUser {
bool done = false;
static NSString* authString = nil;
static NSError * gError = nil;
[api loginUserWithCompletionBlock:@"foo"
password:@"bar"
completionHandler:^(NSString *output, NSError *error) {
if(error) {
gError = error;
}
if(output == nil){
NSLog(@"failed to login");
}
else {
authString = [NSString stringWithString:output];
}
}];
NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10];
while(!done && [loopUntil timeIntervalSinceNow] > 0){
if(gError){
STFail(@"got error %@", gError);
done = true;
}
if(authString){
done = true;
}
}
STAssertTrue([authString length] > 0, @"string was zero chars");
NSLog(@"got login %@", authString);
}
@end