Esempio n. 1
0
        public static ProductTypeInfo ReadProductType(int ProductTypeId, ref List <string> errors)
        {
            if (ProductTypeId <= 0 || ProductTypeId > DALType.ReadProductTypeList(ref errors).Count)
            {
                errors.Add("Invalid ProductType id");
            }

            if (errors.Count > 0)
            {
                return(null);
            }

            return(DALType.ReadProductTypeDetail(ProductTypeId, ref errors));
        }
Esempio n. 2
0
        public void CreateProductTypeTest()
        {
            Random        rand = new Random();
            string        product_type_name = "extremely hot sweater " + rand.Next(10000);
            List <string> errors            = new List <string>();
            int           result            = DALType.CreateProductType(product_type_name, ref errors);

            Assert.AreEqual(0, errors.Count);
            Assert.AreNotEqual(-1, result);

            ProductTypeInfo verifyType = DALType.ReadProductTypeDetail(result, ref errors);

            Assert.AreEqual(0, errors.Count);

            Assert.AreEqual(result, verifyType.product_type_id);
            Assert.AreEqual(product_type_name, verifyType.product_type_name);
        }
Esempio n. 3
0
        public void UpdateProductTypeTest()
        {
            int             myId   = 1;
            Random          rand   = new Random();
            ProductTypeInfo type   = new ProductTypeInfo(myId, "extremely hot sweater " + rand.Next(10000));
            List <string>   errors = new List <string>();
            int             result = DALType.UpdateProductType(type.product_type_id, type.product_type_name, ref errors);

            Assert.AreEqual(0, errors.Count);
            Assert.AreNotEqual(-1, result);

            ProductTypeInfo verifyType = DALType.ReadProductTypeDetail(myId, ref errors);

            Assert.AreEqual(0, errors.Count);

            Assert.AreEqual(type.product_type_id, verifyType.product_type_id);
            Assert.AreEqual(type.product_type_name, verifyType.product_type_name);
        }