|
@@ -42,7 +42,6 @@
|
|
}
|
|
}
|
|
|
|
|
|
- (void)tearDown {
|
|
- (void)tearDown {
|
|
- // Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
|
|
[super tearDown];
|
|
[super tearDown];
|
|
[self.sessionManager invalidateSessionCancelingTasks:YES];
|
|
[self.sessionManager invalidateSessionCancelingTasks:YES];
|
|
self.sessionManager = nil;
|
|
self.sessionManager = nil;
|
|
@@ -71,6 +70,9 @@
|
|
NSURLSessionDataTask *task = [self.sessionManager
|
|
NSURLSessionDataTask *task = [self.sessionManager
|
|
dataTaskWithRequest:self.request
|
|
dataTaskWithRequest:self.request
|
|
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
|
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
|
|
|
+ //Without the dispatch after, this test would PASS errorenously because the test
|
|
|
|
+ //would finish before the notification was posted to all objects that were
|
|
|
|
+ //observing it.
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
[expectation fulfill];
|
|
[expectation fulfill];
|
|
});
|
|
});
|
|
@@ -90,6 +92,9 @@
|
|
NSURLSessionDataTask *task = [self.sessionManager
|
|
NSURLSessionDataTask *task = [self.sessionManager
|
|
dataTaskWithRequest:self.request
|
|
dataTaskWithRequest:self.request
|
|
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
|
completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
|
|
|
|
+ //Without the dispatch after, this test would PASS errorenously because the test
|
|
|
|
+ //would finish before the notification was posted to all objects that were
|
|
|
|
+ //observing it.
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
[expectation fulfill];
|
|
[expectation fulfill];
|
|
});
|
|
});
|
|
@@ -126,6 +131,9 @@
|
|
AFHTTPRequestOperation *operation = [self.operationManager
|
|
AFHTTPRequestOperation *operation = [self.operationManager
|
|
HTTPRequestOperationWithRequest:self.request
|
|
HTTPRequestOperationWithRequest:self.request
|
|
success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
success:^(AFHTTPRequestOperation *operation, id responseObject) {
|
|
|
|
+ //Without the dispatch after, this test would PASS errorenously because the test
|
|
|
|
+ //would finish before the notification was posted to all objects that were
|
|
|
|
+ //observing it.
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
[expectation fulfill];
|
|
[expectation fulfill];
|
|
});
|
|
});
|
|
@@ -138,5 +146,4 @@
|
|
[operation cancel];
|
|
[operation cancel];
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-@end
|
|
|
|
|
|
+@end
|