示例#1
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 = BLProductVariation.CreatePV(ProductVariationInfo, ref errors);

            Assert.AreNotEqual(result, -1);
            AsynchLog.LogNow(errors);

            ProductVariationInfo pv = BLProductVariation.ReadPV(result, ref errors);

            AsynchLog.LogNow(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);
            Assert.AreEqual(0, errors.Count);
        }
示例#2
0
        public void CreateProductVariationErrorTest()
        {
            List <string> errors         = new List <string>(); // TODO: Initialize to an appropriate value
            List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value

            BLProductVariation.CreatePV(null, ref errors);
            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, errors.Count);

            errors = new List <string>(); // TODO: Initialize to an appropriate value
            int    invalid_pv_id              = BLProductVariation.ReadAllPV(ref errors).Count + 1;
            int    invalid_product_id         = BLProduct.ReadAllProduct(ref errors).Count + 1;
            int    invalid_brand_id           = BLBrand.ReadAllBrand(ref errors).Count + 1;
            int    invalid_product_color_id   = BLProductColor.ReadAllProductColor(ref errors).Count + 1;
            int    invalid_product_cutting_id = BLProductCutting.ReadAllProductCutting(ref errors).Count + 1;
            char   invalid_sex             = 'Q';
            string invalid_size            = "huge";
            int    invalid_stock           = -1;
            int    invalid_price           = -1;
            char   invalid_condition       = 'f';
            int    invalid_product_type_id = BLProductType.ReadAllProductType(ref errors).Count + 1;

            ProductVariationInfo ipv = new ProductVariationInfo(invalid_pv_id, invalid_product_id, invalid_brand_id, invalid_product_cutting_id, invalid_product_color_id,
                                                                invalid_product_type_id, invalid_sex, invalid_size, invalid_stock, invalid_price, invalid_condition);


            BLProductVariation.CreatePV(ipv, ref errors);
            Assert.AreEqual(8, errors.Count);
            AsynchLog.LogNow(errors);
        }
示例#3
0
        public void DeleteProductVariationInfoTest()
        {
            char gender    = 'M';
            char condition = 'a';

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

            AsynchLog.LogNow(errors);
            int t = BLProductVariation.DeletePV(result, ref errors);

            AsynchLog.LogNow(errors);

            ProductVariationInfo pv = BLProductVariation.ReadPV(result, ref errors);

            AsynchLog.LogNow(errors);
            Assert.AreEqual('d', pv.condition);
        }
示例#4
0
        public void ProductVariationDeleteErrorTest()
        {
            List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value
            //int invalid_pv_id = BLProductVariation.ReadAllPV(ref errors).Count + 1;

            //create PV, should have no errors
            char gender    = 'M';
            char condition = 'a';
            ProductVariationInfo ProductVariationInfo = new ProductVariationInfo(1, 1, 1, 1, 1, 1, gender, "L", 1, (float)1.0, condition);
            int id_created = BLProductVariation.CreatePV(ProductVariationInfo, ref errors);

            Assert.AreEqual(0, errors.Count);
            Console.WriteLine("id: " + id_created);
            //should delete without error
            BLProductVariation.DeletePV(id_created, ref errors);
            Assert.AreEqual(0, errors.Count);


            //BLProductVariation.DeletePV(invalid_pv_id, ref errors);
            Assert.AreEqual(0, errors.Count);
            BLProductVariation.DeletePV(-1, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);
        }
 public int CreatePV(ProductVariationInfo ProductVariation, ref List <string> errors)
 {
     return(BLProductVariation.CreatePV(ProductVariation, ref errors));
 }