MoodleViewModel extends AndroidViewModel { public int getAssignmentsSortIndex() { SharedPreferences settings = getApplication().getSharedPreferences(MOODLE_PREFS, Context.MODE_PRIVATE); return settings.getInt(SORT_ASSIGNMENTS_PREF, SORT_BY_DATE); } MoodleViewModel(Application application, MoodleRepository moodleRepository); boolean isShowCaseHasBeenDisplayed(); void setShowCaseHasBeenDisplayed(boolean display); LiveData<RemoteResource<List<MoodleCourse>>> getCourses(); LiveData<RemoteResource<List<MoodleAssignmentCourse>>> getAssignmentCourses(); LiveData<RemoteResource<MoodleAssignmentSubmission>> getAssignmentSubmission(int assignId); void setDisplayPastAssignments(boolean display); boolean isDisplayPastAssignments(); void setAssignmentsSortIndex(int index); int getAssignmentsSortIndex(); Comparator<MoodleAssignment> getAssignmentsSortComparator(); void selectAssignment(MoodleAssignment selectedAssignment); LiveData<MoodleAssignment> getSelectedAssignment(); static final int SORT_BY_DATE; static final int SORT_ALPHA; }
@Test public void getAssignmentsSortIndex() { createMockSharedPreferences(); assertEquals(viewModel.getAssignmentsSortIndex(), MoodleViewModel.SORT_ALPHA); }