Code example for TelephonyManager

Methods: getDeviceId

0
    @Test 
    public void shouldGiveDeviceId() { 
        String testId = "TESTING123";
        TelephonyManager telephonyManager = (TelephonyManager) application.getSystemService(TELEPHONY_SERVICE);
        shadowOf(telephonyManager).setDeviceId(testId);
        assertEquals(testId, telephonyManager.getDeviceId());
    } 
 
    @Test 
    public void shouldGiveNetworkOperatorName() { 
        TelephonyManager telephonyManager = (TelephonyManager) application.getSystemService(TELEPHONY_SERVICE);
        ShadowTelephonyManager shadowTelephonyManager = shadowOf(telephonyManager);
        shadowTelephonyManager.setNetworkOperatorName("SomeOperatorName");
        assertEquals("SomeOperatorName", telephonyManager.getNetworkOperatorName());
    } 
 
    @Test 
    public void shouldGiveNetworkCountryIso() { 
        TelephonyManager telephonyManager = (TelephonyManager) application.getSystemService(TELEPHONY_SERVICE);
        ShadowTelephonyManager shadowTelephonyManager = shadowOf(telephonyManager);
        shadowTelephonyManager.setNetworkCountryIso("SomeIso");