public async void GivenPostNotFound_WhenExecuted_ThenThrows() { // Arrange var command = new DeletePost.Command(76); // Act + Assert await Assert.ThrowsAsync <InvalidOperationException>(() => ((IRequestHandler <DeletePost.Command>)sut).Handle(command, default)); }
public async void GivenPostPresent_WhenExecuted_ThenPostRemoved() { // Arrange await th.Context.Posts.AddAsync(new Post { Id = 76 }); await th.Context.SaveChangesAsync(); var command = new DeletePost.Command(76); // Act await((IRequestHandler <DeletePost.Command>)sut).Handle(command, default); // Assert Assert.True(th.Context.Posts.All(x => x.Id != 76)); }