public void Test_UpdateExpense_Fail() { _expenseRepository.Setup(e => e.GetExpenseByExpenseId(It.IsAny <long>())); _expenseRepository.Setup(e => e.UpdateExpense(It.IsAny <long>(), It.IsAny <decimal>())); var expenseServices = new BudgetExpensesServices(_expenseRepository.Object); Assert.ThrowsAsync <Exception>(() => expenseServices.UpdateExpense(1, 2)); _expenseRepository.Verify(e => e.UpdateExpense(It.IsAny <long>(), It.IsAny <decimal>()), Times.Never); }
public async Task Test_UpdateExpense_Success() { _expenseRepository.Setup(e => e.GetExpenseByExpenseId(It.IsAny <long>())) .ReturnsAsync(new BudgetExpenses()); _expenseRepository.Setup(e => e.UpdateExpense(It.IsAny <long>(), It.IsAny <decimal>())) .Returns(Task.CompletedTask); var expenseServices = new BudgetExpensesServices(_expenseRepository.Object); await expenseServices.UpdateExpense(1, 4); _expenseRepository.Verify(e => e.UpdateExpense(It.IsAny <long>(), It.IsAny <decimal>()), Times.Once); }