@Test public void testCloseConnection_successfulInvocationOfUnusedView() { mExpensesInboxPresenter.unusedView(); verify(mExpenseDao).closeConnection(); }
@Test public void testGetExpenses_obtainingEmptyExpensesList() { List<ExpenseModel> emptyExpenseModelList = new ArrayList<>(); when(mExpenseDao.getExpenses()).thenReturn(emptyExpenseModelList); mExpensesInboxPresenter.getExpenses(); verify(mExpenseDao).getExpenses(); verify(mExpensesInboxActivity).listExpenses(emptyExpenseModelList); }
@Test public void testGetExpenses_successfulObtainingExpensesList() { List<ExpenseModel> expenseModelList = getExpensesList(); when(mExpenseDao.getExpenses()).thenReturn(expenseModelList); mExpensesInboxPresenter.getExpenses(); verify(mExpenseDao).getExpenses(); verify(mExpensesInboxActivity).listExpenses(expenseModelList); }
@Test public void testDeleteExpense_deletionError() { long deletedRows = 0; long expenseId = 1; when(mExpenseDao.deleteExpense(anyLong())).thenReturn(deletedRows); mExpensesInboxPresenter.deleteExpense(expenseId); verify(mExpenseDao).deleteExpense(anyLong()); verify(mExpensesInboxActivity).errorDeletion(); }
@Test public void testDeleteExpense_successfulDeletion() { long deletedRows = 1; long expenseId = 4; when(mExpenseDao.deleteExpense(anyLong())).thenReturn(deletedRows); mExpensesInboxPresenter.deleteExpense(expenseId); verify(mExpenseDao).deleteExpense(anyLong()); verify(mExpensesInboxActivity).successfulDeletion(); }