public async Task can_create_find_update_delete_a_budget() { BudgetGateway sut = new BudgetGateway(TestHelpers.ConnectionString); int categoryId = 0; DateTime date1 = TestHelpers.RandomBirthDate(1); DateTime date2 = TestHelpers.RandomBirthDate(2); int amount = 50; int collocId = 0; Result <int> budgetResult = await sut.CreateBudget(categoryId, date1, date2, amount); Assert.That(budgetResult.Status, Is.EqualTo(Status.Created)); int budgetId = budgetResult.Content; Result <BudgetData> budgetData; { budgetData = await sut.FindBudgetById(budgetId); checkBudget(budgetData, categoryId, date1, date2, amount, collocId); } { CategoryGateway categoryGateway = new CategoryGateway(TestHelpers.ConnectionString); Result <int> result = await categoryGateway.CreateCategory(TestHelpers.RandomTestName(), TestHelpers.RandomTestName(), 0); categoryId = result.Content; CollocGateway collocGateway = new CollocGateway(TestHelpers.ConnectionString); Result <int> result1 = await collocGateway.CreateColloc(TestHelpers.RandomTestName(), 0); collocId = result.Content; amount = 100; date1 = TestHelpers.RandomBirthDate(2); date2 = TestHelpers.RandomBirthDate(3); await sut.UpdateBudget(budgetId, categoryId, date1, date2, amount, collocId); budgetData = await sut.FindBudgetById(budgetId); checkBudget(budgetData, categoryId, date1, date2, amount, collocId); } { Result r = await sut.DeleteBudget(budgetId); Assert.That(r.Status, Is.EqualTo(Status.Ok)); budgetData = await sut.FindBudgetById(budgetId); Assert.That(budgetData.Status, Is.EqualTo(Status.NotFound)); } }
public async Task <IActionResult> DeleteBudget(int budgetId) { Result result = await _budgetGateway.DeleteBudget(budgetId); return(this.CreateResult(result)); }