Code example for SharedPreferences

Methods: edit

0
		socializeSessionFactory = AndroidMock.createMock(SocializeSessionFactory.class);
	} 
	 
	public void testPreferencePersistDelete() throws JSONException { 
 
		AndroidMock.expect(context.getSharedPreferences("SocializeSession", Context.MODE_PRIVATE)).andReturn(prefs);
		AndroidMock.expect(prefs.edit()).andReturn(editor);
		AndroidMock.expect(editor.clear()).andReturn(editor);
		AndroidMock.expect(editor.commit()).andReturn(true);
		 
		AndroidMock.replay(context);
		AndroidMock.replay(prefs);
		AndroidMock.replay(editor);
		 
		PreferenceSessionPersister persister = new PreferenceSessionPersister(userFactory, socializeSessionFactory);
		 
		persister.delete(context);
		 
		AndroidMock.verify(context);
		AndroidMock.verify(prefs);
		AndroidMock.verify(editor);
	} 
} 
Experience pair programming with AI  Get Codota for Java