Code example for Preference

Methods: setKey

0
    	shadow = Robolectric.shadowOf(group);
 
		pref1 = new Preference(context);
		pref1.setKey("pref1");
 
		pref2 = new Preference(context);		
		pref2.setKey("pref2");
    } 
     
	@Test 
	public void shouldInheritFromPreference() { 
		assertThat(shadow, instanceOf(ShadowPreference.class));
	}	 
	 
	@Test 
	public void shouldAddPreferences() {		 
		assertThat( group.getPreferenceCount(), equalTo(0));
		 
		// First add succeeds 
		assertThat( group.addPreference(pref1), equalTo(true));
		assertThat( group.getPreferenceCount(), equalTo(1));