Exemple #1
0
        public void DeleteProductVariationInfoTest()
        {
            List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value

            //create a new pv
            ProductVariationInfo ProductVariationInfo = new ProductVariationInfo(1, 2, 3, 4, 5, 2, 'M', "XL", 1, (float)10.0, 'a');
            int id = DALProductVariationInfo.CreatePV(ProductVariationInfo, ref errors);

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

            ProductVariationInfo pv = DALProductVariationInfo.ReadPVDetail(id, ref errors);

            Assert.AreEqual(pv.product_id, 5);
            Assert.AreEqual(pv.product_brand_id, 3);
            Assert.AreEqual(pv.product_cutting_id, 4);
            Assert.AreEqual(pv.product_color_id, 5);
            Assert.AreEqual(pv.product_type_id, 2);
            Assert.AreEqual(pv.sex, 'M');
            Assert.AreEqual(pv.size, "XL");
            Assert.AreEqual(pv.stock, 1);
            Assert.AreEqual(pv.price, 10.0F);
            Assert.AreEqual(pv.condition, 'a');

            List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value
            int           expected       = 1;                   // TODO: Initialize to an appropriate value
            int           actual;

            actual = DALProductVariationInfo.DeleteProductVariationInfo(id, ref errors);
            pv     = DALProductVariationInfo.ReadPVDetail(id, ref errors);
            Assert.AreEqual(expected, actual);
            Assert.AreEqual('d', pv.condition);
        }
Exemple #2
0
        public static int CreatePV(ProductVariationInfo productVariation, ref List <string> errors)
        {
            if (productVariation == null)
            {
                errors.Add("Product Variation cannot be null");
                return(-1);
            }
            System.Diagnostics.Debug.WriteLine("THIS IS THE PID:" + productVariation.product_id);
            if (productVariation.product_id <= 0 || productVariation.product_id > DALProduct.ReadProductList(ref errors).Count)
            {
                errors.Add("Invalid product_id");
            }

            if (productVariation.product_brand_id <= 0 || productVariation.product_brand_id > DALBrand.ReadBrandList(ref errors).Count)
            {
                errors.Add("Invalid product_brand_id");
            }
            if (productVariation.product_cutting_id <= 0 || productVariation.product_cutting_id > DALProductCutting.ReadProductCuttingList(ref errors).Count)
            {
                errors.Add("Invalid product_cutting_id");
            }
            if (productVariation.product_color_id <= 0 || productVariation.product_color_id > DALProductColor.ReadProductColorList(ref errors).Count)
            {
                errors.Add("Invalid product_color_id");
            }
            if (productVariation.sex != 'F' && productVariation.sex != 'M' && productVariation.sex != 'U')
            {
                errors.Add("Invalid sex");
            }
            if (productVariation.size != "XS" && productVariation.size != "S" && productVariation.size != "M" && productVariation.size != "L" && productVariation.size != "XL" && productVariation.size != "XXL")
            {
                errors.Add("Invalid size");
            }
            if (productVariation.stock < 0)
            {
                errors.Add("Invalid stock");
            }
            if (productVariation.price < 0)
            {
                errors.Add("Invalid price");
            }
            if (productVariation.condition != 'a' && productVariation.condition != 's' && productVariation.condition != 'd')
            {
                errors.Add("Invalid condition");
            }

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

            return(DALProductVariationInfo.CreatePV(productVariation, ref errors));
        }
Exemple #3
0
        public void CreatePVTest()
        {
            char gender    = 'M';
            char condition = 'a';

            ProductVariationInfo ProductVariationInfo = new ProductVariationInfo(1, 1, 1, 1, 1, 1, gender, "L", 1, (float)1.0, condition); // TODO: Initialize to an appropriate value
            List <string>        errors         = new List <string>();                                                                     // TODO: Initialize to an appropriate value
            List <string>        errorsExpected = new List <string>();                                                                     // TODO: Initialize to an appropriate value
            int result = DALProductVariationInfo.CreatePV(ProductVariationInfo, ref errors);

            ProductVariationInfo pv = DALProductVariationInfo.ReadPVDetail(result, ref errors);

            Assert.AreEqual(pv.product_id, ProductVariationInfo.product_id);
            Assert.AreEqual(pv.product_brand_id, ProductVariationInfo.product_brand_id);
            Assert.AreEqual(pv.product_cutting_id, ProductVariationInfo.product_cutting_id);
            Assert.AreEqual(pv.product_color_id, ProductVariationInfo.product_color_id);
            Assert.AreEqual(pv.product_type_id, ProductVariationInfo.product_type_id);
            Assert.AreEqual(pv.sex, ProductVariationInfo.sex);
            Assert.AreEqual(pv.size, ProductVariationInfo.size);
            Assert.AreEqual(pv.stock, ProductVariationInfo.stock);
            Assert.AreEqual(pv.price, ProductVariationInfo.price);
            Assert.AreEqual(pv.condition, ProductVariationInfo.condition);
        }