public void AddProductNull()
        {
            Product product = null;
            ProductService productService = new ProductService();

            try
            {
                productService.AddProduct(product);
            }
            catch (ValidationException e)
            {
                Assert.AreEqual("Product is null", e.Message);
            }
        }
        public void AddProductNullDescription()
        {
            Product product = new Product();
            product.Name = "Product";
            product.Description = null;

            ProductService productService = new ProductService();
            Boolean result = false;
            try
            {
                result = productService.AddProduct(product);
            }
            catch (ValidationException exc)
            {
                Assert.AreEqual("Invalid product's name/description.", exc.Message);
            }
            Assert.AreEqual(result, false);
        }
 public void AddProductExistent()
 {
     Product product = new Product();
     product.Name = "thr";
     product.Description = "";
     CategoryService categoryService = new CategoryService();
     Category category = categoryService.GetCategoryById(2);
     product.Categories.Add(category);
     ProductService productService = new ProductService();
     Boolean result = false;
     try
     {
         result = productService.AddProduct(product);
     }
     catch (DuplicateException exc)
     {
         Assert.AreEqual("The same product already exists - same name, description and category", exc.Message);
     }
     Assert.AreEqual(result, false);
 }
        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);
        }
        public void AddProductZeroCharactesDescription()
        {
            Product product = new Product();
            product.Name = "Product";
            product.Description = "";

            CategoryService categoryService = new CategoryService();
            Category category = categoryService.GetCategoryById(2);
            product.Categories.Add(category);
            ProductService productService = new ProductService();
            Boolean result = false;
            try
            {
                result = productService.AddProduct(product);
            }
            catch (ValidationException exc)
            {
                Assert.AreEqual("", exc.Message);
            }
            Assert.AreEqual(result, true);
        }
        public void AddProductWithNullCategory()
        {
            Product product = new Product();
            product.Name = "prod";
            product.Description = "";

            ProductService productService = new ProductService();
            Boolean result = false;
            try
            {
                result = productService.AddProduct(product);
            }
            catch (ValidationException exc)
            {
                Assert.AreEqual("The product must have at least one category setted!", exc.Message);
            }
            Assert.AreEqual(result, false);
        }
        public void AddProductWithNullCategories()
        {
            Product product = new Product();
            product.Name = "prod";
            product.Description = "";
            product.Categories = null;

            ProductService productService = new ProductService();
            Boolean result = false;
            try
            {
                result = productService.AddProduct(product);
            }
            catch (ValidationException exc)
            {
                Assert.AreEqual("Product's categories are null", exc.Message);
            }
            Assert.AreEqual(result, false);
        }
        public void AddProductWithInexistentCategory()
        {
            Product product = new Product();
            product.Name = "prod";
            product.Description = "";
            Category category = new Category();
            product.Categories.Add(category);

            ProductService productService = new ProductService();
            Boolean result = false;
            try
            {
                result = productService.AddProduct(product);
            }
            catch (EntityDoesNotExistException exc)
            {
                Assert.AreEqual("One or more categories of the product do not exist", exc.Message);
            }
            Assert.AreEqual(result, false);
        }
        public void AddProductTwoHundredAndOneCharactersDescription()
        {
            Product product = new Product();
            product.Name = "product";
            product.Description = "abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghija";

            ProductService productService = new ProductService();
            Boolean result = false;
            try
            {
                result = productService.AddProduct(product);
            }
            catch (ValidationException exc)
            {
                Assert.AreEqual("Invalid product's name/description.", exc.Message);
            }
            Assert.AreEqual(result, false);
        }
 public void AddProductThirtyOneCharactersName()
 {
     Product product = new Product();
     product.Name = "1234567890123456789012345678901";
     ProductService productService = new ProductService();
     Boolean result = false;
     try
     {
         result = productService.AddProduct(product);
     }
     catch (ValidationException exc)
     {
         Assert.AreEqual("Invalid product's name/description.", exc.Message);
     }
     Assert.AreEqual(result, false);
 }