public void Handle_GivenInvalidId_ThrowsException() { var command = new UpdateProductCommand { Id = 99, Title = "This item doesn't exist.", }; var sut = new UpdateProductCommand.UpdateProductCommandHandler(Context); Should.ThrowAsync <NotFoundException>(() => sut.Handle(command, CancellationToken.None)); }
public async Task Handle_GivenValidId_ShouldUpdatePersistedProduct() { var command = new UpdateProductCommand { Id = 1, Title = "This thing is also done.", }; var handler = new UpdateProductCommand.UpdateProductCommandHandler(Context); await handler.Handle(command, CancellationToken.None); var entity = Context.Products.Find(command.Id); entity.ShouldNotBeNull(); entity.Title.ShouldBe(command.Title); }
public void Setup() { _handler = new UpdateProductCommand.UpdateProductCommandHandler(UnitOfWork); }