@Test public void testNetworkActiveWithNoConnectivity() { ConnectivityManager mockconnectivity = mock(ConnectivityManager.class); Reachability reachability = new Reachability(mockconnectivity, null); Assert.assertFalse(reachability.isNetworkActive()); }
@Test public void testNetworkActiveWithNullNetworkInfo() { ConnectivityManager mockconnectivity = mock(ConnectivityManager.class); when(mockconnectivity.getActiveNetworkInfo()).thenReturn(null); Reachability reachability = new Reachability(mockconnectivity, null); Assert.assertFalse(reachability.isNetworkActive()); }
public void testNetworkActiveWithNotConnectedNetwork() { NetworkInfo mockedinfo = mock(NetworkInfo.class); when(mockedinfo.isConnectedOrConnecting()).thenReturn(false); ConnectivityManager mockconnectivity = mock(ConnectivityManager.class); when(mockconnectivity.getActiveNetworkInfo()).thenReturn(mockedinfo); Reachability reachability = new Reachability(mockconnectivity, null); Assert.assertFalse(reachability.isNetworkActive()); }