public async Task Test_RemoveExpense_Fail_BadRequest() { var controller = new BudgetExpensesController(_expensesServices.Object); var response = await controller.RemoveExpense(null); Assert.NotNull(response); Assert.AreEqual(400, ((ObjectResult)response).StatusCode); }
public async Task Test_RemoveExpense_Success() { _expensesServices.Setup(e => e.RemoveExpense(It.IsAny <long>())) .Returns(Task.CompletedTask); var controller = new BudgetExpensesController(_expensesServices.Object); var response = await controller.RemoveExpense(new RemoveExpenseRequest() { ExpenseId = 1 }); Assert.NotNull(response); Assert.AreEqual(200, ((OkResult)response).StatusCode); }
public async Task Test_RemoveExpense_Fail_InternalServerError() { _expensesServices.Setup(e => e.RemoveExpense(It.IsAny <long>())) .ThrowsAsync(new Exception("Internal Error")); var controller = new BudgetExpensesController(_expensesServices.Object); var response = await controller.RemoveExpense(new RemoveExpenseRequest() { ExpenseId = 1 }); Assert.NotNull(response); Assert.AreEqual(500, ((ObjectResult)response).StatusCode); }