SharedPreferencesHelper { public boolean saveSortBy(int sortBy) { SharedPreferences.Editor editor = mSharedPreferences.edit(); editor.putInt(STATE_CURRENT_SORT, sortBy); return editor.commit(); } SharedPreferencesHelper(SharedPreferences sharedPreferences); boolean saveSortBy(int sortBy); int getSortBy(); boolean imageUploading(String itemId); void setImageUploading(String itemId); void removeImageUploading(String itemId);  }
@Test public void saveSortByFailed_ReturnsFalse() { boolean success = mMockBrokenSharedPreferencesHelper.saveSortBy(SORT_BY_EXPIRY); assertThat("Makes sure writing to a broken SharedPreferencesHelper returns false", success, is(false)); }