public async Task <ActionResult> UpdateAccountCategory(int id, [FromBody] UpdateAccountCategoryCommand model) { try { var result = await _Mediator.Send(model); return(NoContent()); } catch (NotFoundException e) { return(NotFound(e.Message)); } }
public async Task ThrowNotFoundException() { //Given UpdateAccountCategoryCommand command = new UpdateAccountCategoryCommand() { Id = 1, AccountType = 1, CategoryName = "Petty Cash" }; UpdateAccountCategoryCommandHandler handler = new UpdateAccountCategoryCommandHandler(_Database); //When //Then await Assert.ThrowsAsync <NotFoundException> (() => handler.Handle(command, CancellationToken.None)); }
public async Task NotThrowNotFoundException() { //Given UpdateAccountCategoryCommand command = new UpdateAccountCategoryCommand() { Id = 10, AccountType = 1, CategoryName = "Petty Cash" }; UpdateAccountCategoryCommandHandler handler = new UpdateAccountCategoryCommandHandler(_Database); //When var result = await handler.Handle(command, CancellationToken.None); //Then Assert.Equal(Unit.Value, result); }