public void ThrowsExceptionGivenDuplicateNameAfterUpdate() { var product = _productRepository.GetById(TEST_ID2); var checker = new UniquessCheckerService(_productRepository); var result = Assert.Throws <Exception>(() => product.UpdateName(TEST_NAME, checker)); Assert.Equal("Duplicate name.", result.Message); }
public void UpdatesNameGivenCurrentName() { var product = _productRepository.GetById(TEST_ID2); var checker = new UniquessCheckerService(_productRepository); string newName = product.Name; product.UpdateName(newName, checker); Assert.Equal(newName, product.Name); }
public void UpdatesNameGivenNewUniqueName() { var product = _productRepository.GetById(TEST_ID2); var checker = new UniquessCheckerService(_productRepository); string newName = Guid.NewGuid().ToString(); product.UpdateName(newName, checker); Assert.Equal(newName, product.Name); }
public void ThrowsExceptionGivenDuplicateNameForNewEntity() { var newproduct = new Product() { Id = 3 }; var checker = new UniquessCheckerService(_productRepository); var result = Assert.Throws <Exception>(() => newproduct.UpdateName(TEST_NAME, checker)); Assert.Equal("Duplicate name.", result.Message); }
public void InsertsNewProductGivenUniqueName() { string newName = Guid.NewGuid().ToString(); var product = new Product(newName) { Id = 4 }; var checker = new UniquessCheckerService(_productRepository); product.UpdateName(newName, checker); _productRepository.Add(product); Assert.Equal(newName, product.Name); }