NetworkManager { public String getConnectedNetworkType() { NetworkInfo info = getNetworkInfo(); return info != null && info.isConnected() ? info.getTypeName() : "unknown"; } NetworkManager(Context context); static NetworkManager getInstance(Context context); boolean isOnline(); String getConnectedNetworkType(); boolean isDataRoamingEnabled(); int getNetworkIBType();  }
@Test public void getNetworkTypeTest() { when(mNetworkInfo.isConnected()).thenReturn(false); assertEquals(mNetManager.getConnectedNetworkType(), "unknown"); when(mNetworkInfo.isConnected()).thenReturn(true); when(mNetworkInfo.getTypeName()).thenReturn("a8m"); assertEquals(mNetManager.getConnectedNetworkType(), "a8m"); }