IOS-1469 add description and minor tweaks IOS-1469
authorAlejandro Gelos <agp@pep.security>
Tue, 19 Feb 2019 10:13:55 +0100
branchIOS-1469
changeset 771755ab53b7039b
parent 7716 e653ff4c54bc
child 7718 e355d17b8026
IOS-1469 add description and minor tweaks
pEpForiOS/Util/Reachability/ReachabilityUtils.swift
pEpForiOSTests/TestUtils/ReachabilityUtilsTest/NetworkReachibilityMock.swift
pEpForiOSTests/TestUtils/ReachabilityUtilsTest/ReachabilityUtilsTests.swift
     1.1 --- a/pEpForiOS/Util/Reachability/ReachabilityUtils.swift	Mon Feb 18 18:07:58 2019 +0100
     1.2 +++ b/pEpForiOS/Util/Reachability/ReachabilityUtils.swift	Tue Feb 19 10:13:55 2019 +0100
     1.3 @@ -5,6 +5,15 @@
     1.4  //  Created by Alejandro Gelos on 11/02/2019.
     1.5  //  Copyright © 2019 p≡p Security S.A. All rights reserved.
     1.6  //
     1.7 +//  This service allow an application to determine whether or not you have a working internet
     1.8 +//  connection.
     1.9 +//  Reachability supports asynchronous model. You get the internet connection status, in the
    1.10 +//  completion block by calling the getConnectionStatus(completion:failure:) function. You can also
    1.11 +//  call startNotifier() function, to start getting changes in internet connection status, on
    1.12 +//  ReachabilityDelegate, didChangeReachability(status:) function. The client must implement
    1.13 +//  ReachabilityDelegate to get new internet connection status. When startNotifier is call,
    1.14 +//  ReachabilityDelegate didChangeReachability(status:) will be call with the current internet
    1.15 +//  connection status.
    1.16  
    1.17  import Foundation
    1.18  import SystemConfiguration
     2.1 --- a/pEpForiOSTests/TestUtils/ReachabilityUtilsTest/NetworkReachibilityMock.swift	Mon Feb 18 18:07:58 2019 +0100
     2.2 +++ b/pEpForiOSTests/TestUtils/ReachabilityUtilsTest/NetworkReachibilityMock.swift	Tue Feb 19 10:13:55 2019 +0100
     2.3 @@ -11,7 +11,7 @@
     2.4  @testable import pEpForiOS
     2.5  
     2.6  
     2.7 -class YesInternetReachibilityMock: NetworkReachabilityProtocol {
     2.8 +class YesInternetReachabilityMock: NetworkReachabilityProtocol {
     2.9      let callback: SCNetworkReachabilityCallBack = { (reachability, flags, info) in
    2.10          guard let info = info else { return }
    2.11          
    2.12 @@ -34,7 +34,7 @@
    2.13      }
    2.14  }
    2.15  
    2.16 -class NoInternetReachibilityMock: NetworkReachabilityProtocol {
    2.17 +class NoInternetReachabilityMock: NetworkReachabilityProtocol {
    2.18      let callback: SCNetworkReachabilityCallBack = { (reachability, flags, info) in
    2.19          guard let info = info else { return }
    2.20          
     3.1 --- a/pEpForiOSTests/TestUtils/ReachabilityUtilsTest/ReachabilityUtilsTests.swift	Mon Feb 18 18:07:58 2019 +0100
     3.2 +++ b/pEpForiOSTests/TestUtils/ReachabilityUtilsTest/ReachabilityUtilsTests.swift	Tue Feb 19 10:13:55 2019 +0100
     3.3 @@ -13,8 +13,8 @@
     3.4      
     3.5      private var yesReachability: Reachability?
     3.6      private var noReachability:  Reachability?
     3.7 -    private let yesInternetNetworkReachibilityMock = YesInternetReachibilityMock()
     3.8 -    private let noInternetLocalNetworkReachibilityMock  = NoInternetReachibilityMock()
     3.9 +    private let yesInternetNetworkReachibilityMock = YesInternetReachabilityMock()
    3.10 +    private let noInternetLocalNetworkReachibilityMock  = NoInternetReachabilityMock()
    3.11      
    3.12      override func setUp() {
    3.13          yesReachability = Reachability(networkReachability: yesInternetNetworkReachibilityMock)
    3.14 @@ -38,8 +38,10 @@
    3.15      
    3.16      func testGetConnectionStatusYesInternet() {
    3.17          // Given
    3.18 -        guard let yesReachability = yesReachability else { XCTFail(); return }
    3.19 -        
    3.20 +        guard let yesReachability = yesReachability else {
    3.21 +            XCTFail()
    3.22 +            return
    3.23 +        }
    3.24          // When
    3.25          yesReachability.getConnectionStatus(
    3.26              completion: { result in
    3.27 @@ -52,8 +54,10 @@
    3.28      }
    3.29      
    3.30      func testGetConnectionStatusNoInternet() {
    3.31 -        guard let noReachability = noReachability else { XCTFail(); return }
    3.32 -        
    3.33 +        guard let noReachability = noReachability else {
    3.34 +            XCTFail()
    3.35 +            return
    3.36 +        }
    3.37          // When
    3.38          noReachability.getConnectionStatus(
    3.39              completion: { result in
    3.40 @@ -67,7 +71,10 @@
    3.41      
    3.42      func testStartNotifierYesInternet(){
    3.43          // Given
    3.44 -        guard let yesReachability = yesReachability else { XCTFail(); return }
    3.45 +        guard let yesReachability = yesReachability else {
    3.46 +            XCTFail()
    3.47 +            return
    3.48 +        }
    3.49          let exp = expectation(description: "delegate called for connected")
    3.50          let expectedConnected = Reachability.Connection.connected
    3.51          let testDelegate = ReachibilityUtilsTestsDelegate(withExp: exp,
    3.52 @@ -83,7 +90,10 @@
    3.53      
    3.54      func testStartNotifierNoInternet(){
    3.55          // Given
    3.56 -        guard let noReachability = noReachability else { XCTFail(); return }
    3.57 +        guard let noReachability = noReachability else {
    3.58 +            XCTFail()
    3.59 +            return
    3.60 +        }
    3.61          let exp = expectation(description: "delegate called for no connected")
    3.62          let expectedNotConnected = Reachability.Connection.notConnected
    3.63          let testDelegate = ReachibilityUtilsTestsDelegate(withExp: exp,