Skip to content

Commit

Permalink
Add tests for verifing reachability manager consistence for notificat…
Browse files Browse the repository at this point in the history
…ion posting and getting
  • Loading branch information
pengwp committed Jul 15, 2018
1 parent 06079ad commit ffbcabe
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Tests/Tests/AFNetworkReachabilityManagerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,28 @@ - (void)testDomainReachabilityBlock {
[self verifyReachabilityStatusBlockGetsCalledWithManager:self.domainReachability];
}

- (void)testDifferentReachabilityManagerNotificationPostsAndGets {
[self verifyReachabilityNotificationPostsAndGetsConsistenceWithManager:self.domainReachability notificationManager:self.addressReachability];
}

- (void)testSameReachabilityManagerNotificationPostsAndGets {
[self verifyReachabilityNotificationPostsAndGetsConsistenceWithManager:self.addressReachability notificationManager:self.addressReachability];
}

- (void)verifyReachabilityNotificationPostsAndGetsConsistenceWithManager:(AFNetworkReachabilityManager *)currentManager notificationManager:(AFNetworkReachabilityManager *)noteManager {
BOOL isSameReachabilityManager = [currentManager isEqual:noteManager];
[self expectationForNotification:AFNetworkingReachabilityDidChangeNotification
object:nil
handler:^BOOL(NSNotification *note) {
id currentReachabilityRef = (__bridge id)currentManager.currentNetworkReachability;
id noteReachabilityRef = note.object;
BOOL isSameReachabilityRef = [currentReachabilityRef isEqual:noteReachabilityRef];
return isSameReachabilityManager == isSameReachabilityRef;
}];

[noteManager startMonitoring];

[self waitForExpectationsWithCommonTimeout];
}

@end

0 comments on commit ffbcabe

Please sign in to comment.