Adds testEnqueueBatchOfHTTPRequestOperationsWithRequests.

This commit is contained in:
Oliver Letterer 2013-05-16 21:16:39 +02:00
parent 4e72a84b76
commit 0fead2b2b9

View file

@ -86,6 +86,32 @@
expect([operation class]).to.equal([AFImageRequestOperation class]);
}
- (void)testEnqueueBatchOfHTTPRequestOperationsWithRequests {
[Expecta setAsynchronousTestTimeout:5.0];
__block NSDate *firstCallbackTime = nil;
__block NSDate *batchCallbackTime = nil;
NSMutableURLRequest *request = [self.client requestWithMethod:@"GET" path:@"/" parameters:nil];
AFHTTPRequestOperation *firstOperation = [self.client HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
firstCallbackTime = [NSDate date];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
firstCallbackTime = [NSDate date];
}];
AFHTTPRequestOperation *secondOperation = [self.client HTTPRequestOperationWithRequest:request success:NULL failure:NULL];
[self.client enqueueBatchOfHTTPRequestOperations:@[ firstOperation, secondOperation ] progressBlock:NULL completionBlock:^(NSArray *operations) {
batchCallbackTime = [NSDate date];
}];
expect(self.client.operationQueue.operationCount).to.equal(@3);
expect(firstCallbackTime).willNot.beNil();
expect(batchCallbackTime).willNot.beNil();
expect(batchCallbackTime).beGreaterThan(firstCallbackTime);
}
- (void)testThatTheDefaultStringEncodingIsUTF8 {
expect(self.client.stringEncoding).to.equal(NSUTF8StringEncoding);
}