Code example for Preference

Methods: setKey

0
    	attrs = new TestAttributeSet( new HashMap<String, String>() );
 
    	group = new TestPreferenceGroup(context, attrs);
    	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));