diff --git a/Tests/Tests/AFNetworkReachabilityManagerTests.m b/Tests/Tests/AFNetworkReachabilityManagerTests.m index 20b7d8bf5f..a79530dde4 100644 --- a/Tests/Tests/AFNetworkReachabilityManagerTests.m +++ b/Tests/Tests/AFNetworkReachabilityManagerTests.m @@ -64,17 +64,9 @@ - (void)verifyReachabilityNotificationGetsPostedWithManager:(AFNetworkReachabili handler:^BOOL(NSNotification *note) { AFNetworkReachabilityStatus status; status = [note.userInfo[AFNetworkingReachabilityNotificationStatusItem] integerValue]; - BOOL reachable = (status == AFNetworkReachabilityStatusReachableViaWiFi - || status == AFNetworkReachabilityStatusReachableViaWWAN); - - if (reachable) { - XCTAssert(reachable, - @"Expected network to be reachable but got '%@'", - AFStringFromNetworkReachabilityStatus(status)); - XCTAssertEqual(reachable, manager.isReachable, @"Expected status to match 'isReachable'"); - } - - return reachable; + BOOL isReachable = (status == AFNetworkReachabilityStatusReachableViaWiFi + || status == AFNetworkReachabilityStatusReachableViaWWAN); + return isReachable; }]; [manager startMonitoring]; @@ -86,24 +78,21 @@ - (void)testAddressReachabilityNotification { [self verifyReachabilityNotificationGetsPostedWithManager:self.addressReachability]; } -//Commenting out for Travis Stability -//- (void)testDomainReachabilityNotification { -// [self verifyReachabilityNotificationGetsPostedWithManager:self.domainReachability]; -//} +- (void)testDomainReachabilityNotification { + [self verifyReachabilityNotificationGetsPostedWithManager:self.domainReachability]; +} - (void)verifyReachabilityStatusBlockGetsCalledWithManager:(AFNetworkReachabilityManager *)manager { - __weak XCTestExpectation *expectation = [self expectationWithDescription:@"reachability status change block gets called"]; + __weak __block XCTestExpectation *expectation = [self expectationWithDescription:@"reachability status change block gets called"]; - typeof(manager) __weak weakManager = manager; [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { - BOOL reachable = (status == AFNetworkReachabilityStatusReachableViaWiFi - || status == AFNetworkReachabilityStatusReachableViaWWAN); - - XCTAssert(reachable, @"Expected network to be reachable but got '%@'", AFStringFromNetworkReachabilityStatus(status)); - XCTAssertEqual(reachable, weakManager.isReachable, @"Expected status to match 'isReachable'"); - - [expectation fulfill]; + BOOL isReachable = (status == AFNetworkReachabilityStatusReachableViaWiFi + || status == AFNetworkReachabilityStatusReachableViaWWAN); + if (isReachable) { + [expectation fulfill]; + expectation = nil; + } }]; [manager startMonitoring]; @@ -117,9 +106,8 @@ - (void)testAddressReachabilityBlock { [self verifyReachabilityStatusBlockGetsCalledWithManager:self.addressReachability]; } -//Commenting out for Travis Stability -//- (void)testDomainReachabilityBlock { -// [self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability]; -//} +- (void)testDomainReachabilityBlock { + [self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability]; +} @end