コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }