public void ProductExists_ShouldUpdateTheProduct() { // Arrange var repository = GetEmptyProductRepository(); var sut = new UpdateUseCase(repository); var createUseCase = new CreateUseCase(repository); var getByIdUseCase = new GetByIdUseCase(repository); var id = Guid.NewGuid(); var createInput = new CreateInput { Id = id, Name = "Name", Description = "Description" }; var UpdateInput = new UpdateInput { Id = id, Name = "Name", Description = "Description" }; createUseCase.Execute(createInput); // Act sut.Execute(UpdateInput); var actual = getByIdUseCase.Execute(id); // Assert actual.Id .Should() .Be(id); }
public void ValidInput_ShouldCreateTheProduct() { // Arrange var repository = new InMemoryProductRepository(); var sut = new CreateUseCase(repository); var input = new CreateInput { Name = "Name", Description = "Description" }; // Act Action action = () => sut.Execute(input); // Assert action .Should() .NotThrow(); }
public void ProductAlreadyExists_ShouldThrowException() { // Arrange var repository = GetProductRepository(); var sut = new CreateUseCase(repository); var input = new CreateInput { Name = "Name", Description = "Description" }; // Act Action action = () => sut.Execute(input); // Assert action .Should() .Throw <ProductAlreadyExistsException>(); }