public async Task <ActionResult> Update(int id, UpdateTodoCategoryCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public void ShouldRequireValidTodoListId() { var command = new UpdateTodoCategoryCommand { Id = 99, CategoryTitle = "New Title" }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <NotFoundException>(); }
public async Task ShouldUpdateTodoList() { var userId = await RunAsDefaultUserAsync(); var categoryId = await SendAsync(new CreateTodoCategoryCommand { CategoryTitle = "New List" }); var command = new UpdateTodoCategoryCommand { Id = categoryId, CategoryTitle = "Updated List Title" }; await SendAsync(command); var list = await FindAsync <TodoCategory>(categoryId); list.CategoryTitle.Should().Be(command.CategoryTitle); }
public async Task ShouldRequireUniqueTitle() { var categoryId = await SendAsync(new CreateTodoCategoryCommand { CategoryTitle = "New List" }); await SendAsync(new CreateTodoCategoryCommand { CategoryTitle = "Other List" }); var command = new UpdateTodoCategoryCommand { Id = categoryId, CategoryTitle = "Other List" }; FluentActions.Invoking(() => SendAsync(command)) .Should().Throw <ValidationException>().Where(ex => ex.Errors.ContainsKey("CategoryTitle")) .And.Errors["CategoryTitle"].Should().Contain("The specified title already exists."); }