public async Task <ActionResult> Update(int id, UpdateTermCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public void ShouldRequireValidTermId() { var command = new UpdateTermCommand { Id = 99, TermText = "Test Term", Definition = "Test Definition" }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <NotFoundException>(); }
public async Task ShouldUpdateTerm() { var command = new CreateTermCommand { TermText = "Test Term", Definition = "Test Definition" }; var termCreated = await SendAsync(command); var updateCommand = new UpdateTermCommand { Id = termCreated.Id, TermText = "Test Term Updated", Definition = "Test Definition updated" }; await SendAsync(updateCommand); var updatedTerm = await FindAsync <Domain.Entities.Term>(termCreated.Id); updatedTerm.TermText.Should().Be(updateCommand.TermText); updatedTerm.LastModified.Should().NotBeNull(); }