Example #1
0
        public void UpdateOrderTest()
        {
            int   order_id    = -1;
            int   customer_id = -1;
            float subtotal    = -1F;
            float tax_total   = -1F;
            float grand_total = -1F;
            char  condition   = 'z';

            Orders order;

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

            BLOrders.UpdateOrder(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 = 0;
            order.subtotal    = 0;
            order.grand_total = 0;
            order.tax_total   = 0;
            order.condition   = 'a';

            BLOrders.UpdateOrder(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.UpdateOrder(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.UpdateOrder(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.UpdateOrder(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.UpdateOrder(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.UpdateOrder(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.UpdateOrder(order, ref errors);
            Assert.AreEqual(1, errors.Count);
            AsynchLog.LogNow(errors);

            //all 7 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.UpdateOrder(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.UpdateOrder(order, ref errors);
            Assert.AreEqual(0, errors.Count);
            AsynchLog.LogNow(errors);
        }
Example #2
0
 public int UpdateOrder(Orders order, ref List <string> errors)
 {
     return(BLOrders.UpdateOrder(order, ref errors));
 }