Beispiel #1
0
        public void UpdateProductVariationInfoTest()
        {
            char gender    = 'M';
            char condition = 'a';

            ProductVariationInfo ProductVariationInfo = new ProductVariationInfo(1, 2, 2, 2, 2, 2, gender, "L", 2, (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.UpdatePV(ProductVariationInfo, ref errors);

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

            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, result);
            Assert.AreEqual(pv.product_variation_id, 1);
            Assert.AreEqual(pv.product_id, 2);
            Assert.AreEqual(pv.product_brand_id, 2);
            Assert.AreEqual(pv.product_cutting_id, 2);
            Assert.AreEqual(pv.product_color_id, 2);
            Assert.AreEqual(pv.product_type_id, 2);
            Assert.AreEqual(pv.sex, gender);
            Assert.AreEqual(pv.size, "L");
            Assert.AreEqual(pv.stock, 2);
            Assert.AreEqual(pv.price, (float)1.0);
            Assert.AreEqual(pv.condition, condition);
        }
Beispiel #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);
        }
Beispiel #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 = 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);
        }
Beispiel #4
0
        public void ReadAllPVTest()
        {
            List <string> errors                = new List <string>(); // TODO: Initialize to an appropriate value
            List <string> errorsExpected        = new List <string>(); // TODO: Initialize to an appropriate value
            List <ProductVariationInfo> pvList1 = BLProductVariation.ReadAllPV(ref errors);

            AsynchLog.LogNow(errors);
            List <ProductVariationInfo> pvList2 = BLProductVariation.ReadAllPV(ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(pvList1.Count, pvList2.Count);
            Assert.AreEqual(errors.Count, 0);
            for (int i = 0; i < pvList1.Count; i++)
            {
                Assert.AreEqual(pvList1[i].product_variation_id, pvList2[i].product_variation_id);
                Assert.AreEqual(pvList1[i].product_id, pvList2[i].product_id);
                Assert.AreEqual(pvList1[i].product_brand_id, pvList2[i].product_brand_id);
                Assert.AreEqual(pvList1[i].product_cutting_id, pvList2[i].product_cutting_id);
                Assert.AreEqual(pvList1[i].product_color_id, pvList2[i].product_color_id);
                Assert.AreEqual(pvList1[i].product_type_id, pvList2[i].product_type_id);
                Assert.AreEqual(pvList1[i].sex, pvList2[i].sex);
                Assert.AreEqual(pvList1[i].size, pvList2[i].size);
                Assert.AreEqual(pvList1[i].stock, pvList2[i].stock);
                Assert.AreEqual(pvList1[i].price, pvList2[i].price);
                Assert.AreEqual(pvList1[i].condition, pvList2[i].condition);
            }
        }
Beispiel #5
0
        public void DeleteUserTest()
        {
            int           id     = 0;
            List <string> errors = new List <string>();

            //id = 0
            BLUser.DeleteUser(id, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #6
0
        public void CreateProductColorNullErrorTest()
        {
            List <string> errors         = new List <string>(); // TODO: Initialize to an appropriate value
            List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value

            BLProductColor.CreateProductColor(null, ref errors);
            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, errors.Count);
        }
Beispiel #7
0
        public void BrandReadErrorTest()
        {
            List <string> errors           = new List <string>(); // TODO: Initialize to an appropriate value
            int           invalid_Brand_id = BLBrand.ReadAllBrand(ref errors).Count + 1;

            BLBrand.ReadBrand(invalid_Brand_id, ref errors);
            BLBrand.ReadBrand(-1, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #8
0
        public void ProductColorReadErrorTest()
        {
            List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value
            int           invalid_ProductColor_id = BLProductColor.ReadAllProductColor(ref errors).Count + 1;

            BLProductColor.ReadProductColor(invalid_ProductColor_id, ref errors);
            AsynchLog.LogNow(errors);
            BLProductColor.ReadProductColor(-1, ref errors);
            AsynchLog.LogNow(errors);
            Assert.AreEqual(2, errors.Count);
        }
        public void ProductTypeUpdateErrorTest()
        {
            List <string> errors = new List <string>(); // TODO: Initialize to an appropriate value
            int           invalid_ProductType_id = BLProductType.ReadAllProductType(ref errors).Count + 1;

            BLProductType.UpdateProductType(-1, "Louis", ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);
            BLProductType.UpdateProductType(invalid_ProductType_id, "Louis", ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #10
0
        public void UpdateBrandTest()
        {
            Random        rand           = new Random();
            String        updateString   = "Hello Kitty" + rand.Next(1000);
            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         = BLBrand.UpdateBrand(1, updateString, ref errors);
            BrandInfo     Brand          = BLBrand.ReadBrand(1, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, result);
            Assert.AreEqual(Brand.brand_id, 1);
            Assert.AreEqual(Brand.brand_name, updateString);
        }
Beispiel #11
0
        public void ReadUserTest()
        {
            int           id     = 0;
            List <string> errors = new List <string>();

            //id = 0
            BLUser.ReadUser(id, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //no errors
            errors = new List <string>();
            BLUser.ReadUser(1, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #12
0
        public void UpdateProductColorTest()
        {
            Random        rand           = new Random();
            String        updateString   = "Hello Kitty Pink " + rand.Next(1000);
            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         = BLProductColor.UpdateProductColor(1, updateString, ref errors);

            AsynchLog.LogNow(errors);
            ProductColorInfo ProductColor = BLProductColor.ReadProductColor(1, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, result);
            Assert.AreEqual(ProductColor.product_color_id, 1);
            Assert.AreEqual(ProductColor.product_color_name, updateString);
        }
        public void UpdateProductCuttingTest()
        {
            Random        rand           = new Random();
            String        updateString   = "Tall " + rand.Next(1000);
            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         = BLProductCutting.UpdateProductCutting(1, updateString, ref errors);

            AsynchLog.LogNow(errors);
            ProductCuttingInfo ProductCutting = BLProductCutting.ReadProductCutting(1, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, result);
            Assert.AreEqual(ProductCutting.product_cutting_id, 1);
            Assert.AreEqual(ProductCutting.product_cutting_name, updateString);
        }
        public void UpdateProductTypeTest()
        {
            Random        rand           = new Random();
            String        updateString   = "Lingerie " + rand.Next(1000);
            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         = BLProductType.UpdateProductType(1, updateString, ref errors);

            AsynchLog.LogNow(errors);
            ProductTypeInfo ProductType = BLProductType.ReadProductType(1, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(1, result);
            Assert.AreEqual(ProductType.product_type_id, 1);
            Assert.AreEqual(ProductType.product_type_name, updateString);
        }
Beispiel #15
0
        public void ReadAllBrandTest()
        {
            List <string>    errors         = new List <string>(); // TODO: Initialize to an appropriate value
            List <string>    errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value
            List <BrandInfo> BrandList1     = BLBrand.ReadAllBrand(ref errors);
            List <BrandInfo> BrandList2     = BLBrand.ReadAllBrand(ref errors);


            Assert.AreEqual(BrandList1.Count, BrandList2.Count);
            Assert.AreEqual(errors.Count, 0);
            AsynchLog.LogNow(errors);
            for (int i = 0; i < BrandList1.Count; i++)
            {
                Assert.AreEqual(BrandList1[i].brand_id, BrandList2[i].brand_id);
                Assert.AreEqual(BrandList1[i].brand_name, BrandList2[i].brand_name);
            }
        }
Beispiel #16
0
        public void CreateBrandTest()
        {
            Random rand         = new Random();
            String createString = "Sanrio " + rand.Next(1000);

            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         = BLBrand.CreateBrand(createString, ref errors);

            Assert.AreNotEqual(result, -1);

            BrandInfo Brand = BLBrand.ReadBrand(result, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(Brand.brand_id, result);
            Assert.AreEqual(Brand.brand_name, createString);
        }
        public void CreateProductCuttingTest()
        {
            Random rand         = new Random();
            String createString = "Midget " + rand.Next(1000);

            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         = BLProductCutting.CreateProductCutting(createString, ref errors);

            AsynchLog.LogNow(errors);
            Assert.AreNotEqual(result, -1);
            ProductCuttingInfo ProductCutting = BLProductCutting.ReadProductCutting(result, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(ProductCutting.product_cutting_id, result);
            Assert.AreEqual(ProductCutting.product_cutting_name, createString);
        }
Beispiel #18
0
        public void ProductVariationUpdateErrorTest()
        {
            List <string> errors        = new List <string>(); // TODO: Initialize to an appropriate value
            int           invalid_pv_id = BLProductVariation.ReadAllPV(ref errors).Count + 1;

            char gender    = 'M';
            char condition = 'a';

            ProductVariationInfo ProductVariationInfo1 = new ProductVariationInfo(invalid_pv_id, 2, 2, 2, 2, 2, gender, "L", 2, (float)1.0, condition); // TODO: Initialize to an appropriate value

            ProductVariationInfo ProductVariationInfo2 = new ProductVariationInfo(-1, 2, 2, 2, 2, 2, gender, "L", 2, (float)1.0, condition);            // TODO: Initialize to an appropriate value

            BLProductVariation.UpdatePV(ProductVariationInfo1, ref errors);
            Assert.AreEqual(1, errors.Count);
            BLProductVariation.UpdatePV(ProductVariationInfo2, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #19
0
        public void CreateBrandErrorTest()
        {
            List <string> errors         = new List <string>(); // TODO: Initialize to an appropriate value
            List <string> errorsExpected = new List <string>(); // TODO: Initialize to an appropriate value

            BLBrand.CreateBrand(null, ref errors);

            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            errors = new List <string>(); // TODO: Initialize to an appropriate value
            Random rand       = new Random();
            string iBrandName = "Louis" + rand.Next(1000);

            BLBrand.CreateBrand(iBrandName, ref errors);
            BLBrand.CreateBrand(iBrandName, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);
        }
        public void CreateProductTypeTest()
        {
            Random rand         = new Random();
            String createString = "Super deep v turtle neck " + rand.Next(1000);

            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         = BLProductType.CreateProductType(createString, ref errors);

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

            ProductTypeInfo ProductType = BLProductType.ReadProductType(result, ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(ProductType.product_type_id, result);
            Assert.AreEqual(ProductType.product_type_name, createString);
        }
Beispiel #21
0
        public void ReadAllProductColorTest()
        {
            List <string>           errors            = new List <string>(); // TODO: Initialize to an appropriate value
            List <string>           errorsExpected    = new List <string>(); // TODO: Initialize to an appropriate value
            List <ProductColorInfo> ProductColorList1 = BLProductColor.ReadAllProductColor(ref errors);

            AsynchLog.LogNow(errors);
            List <ProductColorInfo> ProductColorList2 = BLProductColor.ReadAllProductColor(ref errors);

            AsynchLog.LogNow(errors);

            Assert.AreEqual(ProductColorList1.Count, ProductColorList2.Count);
            Assert.AreEqual(errors.Count, 0);
            for (int i = 0; i < ProductColorList1.Count; i++)
            {
                Assert.AreEqual(ProductColorList1[i].product_color_id, ProductColorList2[i].product_color_id);
                Assert.AreEqual(ProductColorList1[i].product_color_name, ProductColorList2[i].product_color_name);
            }
        }
Beispiel #22
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);
        }
Beispiel #23
0
        public void CreateProductColorTest()
        {
            Random rand         = new Random();
            String createString = "Sanrio Pink " + rand.Next(1000);

            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         = BLProductColor.CreateProductColor(createString, ref errors);

            AsynchLog.LogNow(errors);
            Assert.AreNotEqual(result, -1);
            System.Diagnostics.Debug.WriteLine("RESULT:" + result);
            ProductColorInfo ProductColor = BLProductColor.ReadProductColor(result, ref errors);

            AsynchLog.LogNow(errors);

            System.Diagnostics.Debug.WriteLine("RESULT:" + ProductColor.product_color_id);
            System.Diagnostics.Debug.WriteLine("RESULT:" + ProductColor.product_color_name);

            Assert.AreEqual(ProductColor.product_color_id, result);
            Assert.AreEqual(ProductColor.product_color_name, createString);
        }
Beispiel #24
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);
        }
Beispiel #25
0
        public void CreateOrderTest()
        {
            int   order_id    = -1;
            int   customer_id = -1;
            float subtotal    = -1F;
            float tax_total   = -1F;
            float grand_total = -1F;
            char  condition   = 'z';



            Orders order = null;

            List <string> errors = new List <string>();

            BLOrders.CreateOrder(null, ref errors);
            Assert.AreEqual(1, errors.Count);

            AsynchLog.LogNow(errors);

            //order_id = -1
            errors = new List <string>();

            order             = new Orders();
            order.order_id    = order_id;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //customer_id = -1
            order.order_id    = 1;
            order.customer_id = customer_id;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();

            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //subtotal = -1
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = subtotal;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);

            //grand_total = -1
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = grand_total;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);

            //tax_total = -1
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = tax_total;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(2, errors.Count);
            AsynchLog.LogNow(errors);

            //grand_total calculation
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 1F;
            order.grand_total = 0;
            order.tax_total   = 1F;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //condition = k
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = condition;

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //all 8 errors
            order.order_id    = order_id;
            order.customer_id = customer_id;
            order.subtotal    = subtotal;
            order.grand_total = grand_total;
            order.tax_total   = tax_total;
            order.condition   = condition;

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(7, errors.Count);
            AsynchLog.LogNow(errors);

            //no errors
            order.order_id    = 1;
            order.customer_id = 1;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            errors = new List <string>();
            BLOrders.CreateOrder(order, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #26
0
        public void CreateUserTest()
        {
            int    users_id    = 0;
            int    customer_id = 0;
            char   user_level  = 'j';
            char   condition   = 'c';
            string email       = "such@[email protected]";

            Random random = new Random();
            Users  users;

            List <string> errors = new List <string>();

            BLUser.CreateUser(null, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //users_id = 0
            errors = new List <string>();
            users  = new Users(users_id, 1, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //customer_id = 0
            errors = new List <string>();
            users  = new Users(1, customer_id, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //user_level = j
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", user_level,
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //condition = c
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, condition);
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //email = such@[email protected]
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", 'u',
                               email, DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //all 5
            errors = new List <string>();
            users  = new Users(users_id, customer_id, "username" + random.Next(10000), "password", user_level,
                               email, DateTime.Now, DateTime.Now, condition);
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(5, errors.Count);
            AsynchLog.LogNow(errors);

            //none
            errors = new List <string>();
            users  = new Users(1, 1, "username" + random.Next(10000), "password", 'u',
                               "test" + random.Next(10000) + "@test.com", DateTime.Now, DateTime.Now, 'a');
            BLUser.CreateUser(users, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }
Beispiel #27
0
        public void CreateCustomerTest()
        {
            int      customer_id = 0;
            int      age         = 0;
            int      zip         = 0;
            char     gender      = 'T';
            int      income      = -1;
            int      children    = -1;
            string   degree      = "Elementary School Diploma";
            int      ownHouse    = -1;
            Customer customer;

            List <string> errors = new List <string>();

            BLCustomer.CreateCustomer(null, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //customer_id = 0
            errors   = new List <string>();
            customer = new Customer(customer_id, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    'M', "None", 80000, 2, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //age = 0
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, age,
                                    'M', "None", 80000, 2, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //zip = 0
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", zip, 20,
                                    'M', "None", 80000, 2, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //gender = T
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    gender, "None", 80000, 2, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //income = -1
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    'M', "None", income, 2, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //children = -1
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    'M', "None", 80000, children, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //degree = Elementary School Diploma
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    'M', "None", 80000, 2, degree, 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //ownHouse = -1
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    'M', "None", 80000, 2, "None", ownHouse);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);
            //ownHouse = -1

            //all 8 errors
            errors   = new List <string>();
            customer = new Customer(customer_id, "first", "last", "address1", "city1", "CA", zip, age,
                                    gender, "None", income, children, degree, ownHouse);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(8, errors.Count);
            AsynchLog.LogNow(errors);

            //no errors
            errors   = new List <string>();
            customer = new Customer(1, "first", "last", "address1", "city1", "CA", 92037, 20,
                                    'M', "None", 80000, 2, "None", 1);
            BLCustomer.CreateCustomer(customer, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }