public async Task <ActionResult> Update(int id, [FromBody] UpdateConsultationCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public async Task Handle_GivenInvalidId_ThrowsException() { var command = new UpdateConsultationCommand { Id = 99, Plans = "rv daily", }; var handler = new UpdateConsultationCommand.UpdateConsultationCommandHandler(Context, _mapper); Func <Task> action = () => handler.Handle(command, CancellationToken.None); await action.Should().ThrowExactlyAsync <NotFoundException>(); }
public async Task Handle_GivenValidId_ShouldUpdatePersistedTodoList() { var command = new UpdateConsultationCommand { Id = 2, Plans = "rv one more time this week" }; var handler = new UpdateConsultationCommand.UpdateConsultationCommandHandler(Context, _mapper); await handler.Handle(command, CancellationToken.None); var entity = Context.Consultations.Find(command.Id); entity.Should().NotBeNull(); entity.Plans.Should().Be(command.Plans); }