@Test public void testDeleteItemFail() throws Exception { when(mRepository.delete(anyLong())).thenReturn(Observable.just(false)); fetchData(); mViewModel.deleteItem(0).toBlocking().single(); assertThat(mViewModel.getTodoItems()).hasSize(3); assertEquals(View.GONE, mViewModel.getAlertVisibility().get()); }
@Test public void testDeleteItemSuccess() throws Exception { when(mRepository.delete(anyLong())).thenReturn(Observable.just(true)); fetchData(); for (int i = 0; i < 3; i++) mViewModel.deleteItem(0).toBlocking().single(); assertThat(mViewModel.getTodoItems()).hasSize(0); assertEquals(View.VISIBLE, mViewModel.getAlertVisibility().get()); }
@Test public void testGetAlertVisibilityGone() throws Exception { fetchData(); assertEquals(View.GONE, mViewModel.getAlertVisibility().get()); }
@Test public void testGetAlertVisibilityVisibleNoItem() throws Exception { when(mRepository.getAll()).thenReturn(Observable.just(DataUtils.provideEmptyList())); mViewModel.fetchAllTodo().toBlocking().single(); assertEquals(View.VISIBLE, mViewModel.getAlertVisibility().get()); }
@Test public void testGetAlertVisibilityOnStart() throws Exception { assertEquals(View.GONE, mViewModel.getAlertVisibility().get()); }
@Test public void testInsert() throws Exception { mViewModel.insert(DataUtils.provideTodo()); assertEquals(View.GONE, mViewModel.getAlertVisibility().get()); }