public void UpdateProductThreeCharactersName()
 {
     String name = "pro";
     int id = 2;
     ProductService ProductService = new ProductService();
     Boolean result = false;
     try
     {
         result = ProductService.UpdateProduct(id, name);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("", exc.Message);
     }
     Assert.AreEqual(true, result);
 }
 public void UpdateProductThirtyOneCharactersName()
 {
     String name = "1234567890123456789012345678901";
     int id = 2;
     ProductService ProductService = new ProductService();
     Boolean result = false;
     try
     {
         result = ProductService.UpdateProduct(id, name);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("Invalid product's name.", exc.Message);
     }
     Assert.AreEqual(false, result);
 }
        public void UpdateProductSameName()
        {
            String name = "product";
            int id = 7;
            ProductService productService = new ProductService();

            Boolean result = false;
            try
            {
                result = productService.UpdateProduct(id, name);
            }
            catch (EntityDoesNotExistException exc)
            {
                Assert.AreEqual("", exc.Message);
            }
            Assert.AreEqual(true, result);
            Product product = productService.GetProductById(id);
            Assert.AreEqual(product.Name, name);
        }
        public void UpdateProductNull()
        {
            String name = "Product";
            int id = 100;
            ProductService productService = new ProductService();

            Boolean result = false;
            try
            {
                result = productService.UpdateProduct(id, name);
            }
            catch (EntityDoesNotExistException exc)
            {
                Assert.AreEqual("Product is null", exc.Message);
            }
            Assert.AreEqual(false, result);
        }
 public void UpdateProductNameNull()
 {
     String name = null;
     int id = 2;
     ProductService ProductService = new ProductService();
     Boolean result = false;
     try
     {
         result = ProductService.UpdateProduct(id, name);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("Invalid product's name.", exc.Message);
     }
     Assert.AreEqual(false, result);
 }
        public void UpdateProductDuplicateName()
        {
            Product product = new Product();
            product.Name = "Product1";
            product.Description = "Description";
            CategoryService categoryService = new CategoryService();
            Category category = categoryService.GetCategoryById(8);
            product.Categories.Add(category);
            ProductService productService = new ProductService();
            productService.AddProduct(product);

            String name = "Product";
            int id = 19;
            Product p = productService.GetProductById(id);
            Boolean result = false;
            try
            {
                result = productService.UpdateProduct(id, name);
            }
            catch (DuplicateException exc)
            {
                Assert.AreEqual("The same product already exists - same name, description and category", exc.Message);
            }
            Assert.AreEqual(false, result);
        }