Adds testEnqueueBatchOfHTTPRequestOperations.

This commit is contained in:
Oliver Letterer 2013-05-16 21:28:23 +02:00
parent 0fead2b2b9
commit 5c90fd599a

View file

@ -86,7 +86,7 @@
expect([operation class]).to.equal([AFImageRequestOperation class]); expect([operation class]).to.equal([AFImageRequestOperation class]);
} }
- (void)testEnqueueBatchOfHTTPRequestOperationsWithRequests { - (void)testEnqueueBatchOfHTTPRequestOperations {
[Expecta setAsynchronousTestTimeout:5.0]; [Expecta setAsynchronousTestTimeout:5.0];
__block NSDate *firstCallbackTime = nil; __block NSDate *firstCallbackTime = nil;
@ -112,6 +112,36 @@
expect(batchCallbackTime).beGreaterThan(firstCallbackTime); expect(batchCallbackTime).beGreaterThan(firstCallbackTime);
} }
- (void)testEnqueueBatchOfHTTPRequestOperationsWithRequests {
[Expecta setAsynchronousTestTimeout:5.0];
[self.client registerHTTPOperationClass:[AFJSONRequestOperation class]];
[self.client registerHTTPOperationClass:[AFImageRequestOperation class]];
__block NSArray *batchOperations = nil;
NSMutableURLRequest *firstRequest = [self.client requestWithMethod:@"GET" path:@"/" parameters:nil];
[firstRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
NSMutableURLRequest *secondeRequest = [self.client requestWithMethod:@"GET" path:@"/" parameters:nil];
[secondeRequest setValue:@"image/png" forHTTPHeaderField:@"Accept"];
[self.client enqueueBatchOfHTTPRequestOperationsWithRequests:@[ firstRequest, secondeRequest ] progressBlock:^(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations) {
} completionBlock:^(NSArray *operations) {
batchOperations = operations;
}];
expect(self.client.operationQueue.operationCount).to.equal(@3);
expect(batchOperations).willNot.beNil();
expect(self.client.operationQueue.operationCount).to.equal(@0);
expect(batchOperations.count).to.equal(@2);
expect([[batchOperations objectAtIndex:0] class]).to.equal([AFJSONRequestOperation class]);
expect([[batchOperations objectAtIndex:1] class]).to.equal([AFImageRequestOperation class]);
}
- (void)testThatTheDefaultStringEncodingIsUTF8 { - (void)testThatTheDefaultStringEncodingIsUTF8 {
expect(self.client.stringEncoding).to.equal(NSUTF8StringEncoding); expect(self.client.stringEncoding).to.equal(NSUTF8StringEncoding);
} }