コード例 #1
0
        public void UpdateProductSameDescription()
        {
            String description = "abcdefghijabcdefghijabcdefghij";
            int id = 7;
            ProductService productService = new ProductService();

            Boolean result = false;
            try
            {
                result = productService.UpdateProductDescription(id, description);
            }
            catch (EntityDoesNotExistException exc)
            {
                Assert.AreEqual("", exc.Message);
            }
            Assert.AreEqual(true, result);
            Product product = productService.GetProductById(id);
            Assert.AreEqual(product.Description, description);
        }
コード例 #2
0
        public void UpdateProductNullDescription()
        {
            String description = "Product";
            int id = 100;
            ProductService productService = new ProductService();

            Boolean result = false;
            try
            {
                result = productService.UpdateProductDescription(id, description);
            }
            catch (EntityDoesNotExistException exc)
            {
                Assert.AreEqual("Product is null", exc.Message);
            }
            Assert.AreEqual(false, result);
        }
コード例 #3
0
        public void UpdateProductDuplicateDescription()
        {
            Product product = new Product();
            product.Name = "product";
            product.Description = "Description";
            CategoryService categoryService = new CategoryService();
            Category category = categoryService.GetCategoryById(2);
            product.Categories.Add(category);
            ProductService productService = new ProductService();
            productService.AddProduct(product);

            String desc = "abcdefghijabcdefghijabcdefghij";
            int id = 18;

            Boolean result = false;
            try
            {
                result = productService.UpdateProductDescription(id, desc);
            }
            catch (DuplicateException exc)
            {
                Assert.AreEqual("The same product already exists - same name, description and category", exc.Message);
            }
            Assert.AreEqual(false, result);
        }
コード例 #4
0
 public void UpdateProductDescriptionZeroCharacters()
 {
     String description = "";
     int id = 9;
     ProductService ProductService = new ProductService();
     Boolean result = false;
     try
     {
         result = ProductService.UpdateProductDescription(id, description);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("", exc.Message);
     }
     Assert.AreEqual(true, result);
 }
コード例 #5
0
 public void UpdateProductDescriptionTwoHundredAndOneCharacters()
 {
     String description = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901";
     int id = 8;
     ProductService ProductService = new ProductService();
     Boolean result = false;
     try
     {
         result = ProductService.UpdateProductDescription(id, description);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("Invalid product's description.", exc.Message);
     }
     Assert.AreEqual(false, result);
 }
コード例 #6
0
 public void UpdateProductDescriptionNull()
 {
     String description = null;
     int id = 1;
     ProductService ProductService = new ProductService();
     Boolean result = false;
     try
     {
         result = ProductService.UpdateProductDescription(id, description);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("Invalid product's description.", exc.Message);
     }
     Assert.AreEqual(false, result);
 }