public async Task Handle_GivenInvalidId_ThrowsNotFoundException() { int invalidId = 10; var command = new DeleteContentCommand() { Id = invalidId }; await ShouldThrowAsyncExtensions.ShouldThrowAsync <NotFoundException>(() => _handler.Handle(command, CancellationToken.None)); }
public async Task Handle_GivenValidId_DeletesContent() { int validId = 1; var command = new DeleteContentCommand() { Id = validId }; await _handler.Handle(command, CancellationToken.None); var content = await _context.Contents.FindAsync(validId); content.ShouldBe(null); }
public Task <IActionResult> DeleteAsync( [FromServices] DeleteContentCommand command, long contentId, CancellationToken cancellationToken) => command.ExecuteAsync(contentId, cancellationToken);
public async Task <IActionResult> Delete([FromRoute] DeleteContentCommand command) { var result = await _mediator.Send(command); return(Ok(result)); }