AllSharedPreferences { public void saveIsSyncInProgress(Boolean isSyncInProgress) { preferences.edit().putBoolean(IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, isSyncInProgress).commit(); } AllSharedPreferences(SharedPreferences preferences); void updateANMUserName(String userName); String fetchRegisteredANM(); String fetchLanguagePreference(); void saveLanguagePreference(String languagePreference); Boolean fetchIsSyncInProgress(); void saveIsSyncInProgress(Boolean isSyncInProgress); static final String ANM_IDENTIFIER_PREFERENCE_KEY; }
@Test public void shouldSaveIsSyncInProgress() throws Exception { SharedPreferences.Editor editor = mock(SharedPreferences.Editor.class); when(preferences.edit()).thenReturn(editor); when(editor.putBoolean(IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, true)).thenReturn(editor); allSharedPreferences.saveIsSyncInProgress(true); verify(editor).putBoolean(IS_SYNC_IN_PROGRESS_PREFERENCE_KEY, true); verify(editor).commit(); }