public async Task DeleteImage() { var sut = new DeleteImageCommandHandler(this.unitOfWork, this.imageFileProviderMock.Object); await sut.HandleAsync(new DeleteImageCommand() { Id = this.image.Id }); Assert.Empty(this.unitOfWork.Images); this.imageFileProviderMock.Verify(i => i.DeleteFileAsync($"{this.image.Id}.png"), Times.Once); }
public async Task ShouldDeleteImage() { var image = await AddImage(); IRequestHandler <DeleteImageCommand> handler = new DeleteImageCommandHandler(RequestDbContext, TestContext.CreateImageService()); var message = new DeleteImageCommand() { Id = image.Id }; await handler.Handle(message, CancellationToken.None); Assert.Equal(null, await RequestDbContext.Images.FindAsync(image.Id)); }
public async Task Delete([FromBody] int id) { await DeleteImageCommandHandler.DeleteImage(_imageRepository, id); }