Exemplo n.º 1
0
        public void TestIsInternetAvailable(NetworkConnectivityLevel networkConnectivity)
        {
            // Setup any objects and mocks.
            var           mockConnectionProfile  = new Mock <IKConnectionProfile>();
            var           mockNetworkInformation = new Mock <IKNetworkInformation>();
            NetworkStatus networkStatus          = new NetworkStatus(mockNetworkInformation.Object);

            mockConnectionProfile
            .Setup(obj => obj.GetNetworkConnectivityLevel())
            .Returns(networkConnectivity);
            mockNetworkInformation
            .Setup(obj => obj.GetInternetConnectionProfile())
            .Returns(mockConnectionProfile.Object);

            // Call the method under test.
            bool available = networkStatus.IsInternetAvailable();
            bool expected  = networkConnectivity == NetworkConnectivityLevel.InternetAccess;

            // Verify the results produced.
            Assert.AreEqual(
                expected, available,
                "Function is not reporting the correct status");
        }