Beispiel #1
0
        public void AgentCommission()
        {
            OrderingSystem os = new OrderingSystem();

            os.Setup();
            List <OrderItem> pitemList = new List <OrderItem>();

            foreach (OrderType ot in (OrderType[])Enum.GetValues(typeof(OrderType)))
            {
                switch (ot)
                {
                case OrderType.PhysicalProduct:
                    pitemList.Add(new OrderItem(1, "Physical Product", 1, 100));
                    Order pOrder = new Order(OrderType.PhysicalProduct, pitemList, 100.00);
                    Assert.AreEqual(os.AddOrder(pOrder), true);
                    Assert.AreEqual(pOrder.rule.IsCommissionApplicable, true);
                    break;

                case OrderType.Book:
                    pitemList.Add(new OrderItem(1, "Great Book", 1, 100));
                    Order bOrder = new Order(OrderType.PhysicalProduct, pitemList, 100.00);
                    Assert.AreEqual(os.AddOrder(bOrder), true);
                    Assert.AreEqual(bOrder.rule.IsCommissionApplicable, true);
                    break;

                case OrderType.MembershipActivation:
                    pitemList.Add(new OrderItem(1, "Membership Activation", 1, 100));
                    Order maOrder = new Order(OrderType.MembershipActivation, pitemList, 100.00);
                    Assert.AreEqual(os.AddOrder(maOrder), true);
                    Assert.AreEqual(maOrder.rule.IsCommissionApplicable, false);
                    break;

                case OrderType.MembershipUpgrade:
                    pitemList.Add(new OrderItem(1, "Membership Upgrade", 1, 100));
                    Order muOrder = new Order(OrderType.MembershipUpgrade, pitemList, 100.00);
                    Assert.AreEqual(os.AddOrder(muOrder), true);
                    Assert.AreEqual(muOrder.rule.IsCommissionApplicable, false);
                    break;

                case OrderType.Video:
                    pitemList.Add(new OrderItem(1, "Life on the rocks!", 1, 100));
                    Order vOrder = new Order(OrderType.Video, pitemList, 100.00);
                    Assert.AreEqual(os.AddOrder(vOrder), true);
                    Assert.AreEqual(vOrder.rule.IsCommissionApplicable, true);
                    break;
                }
            }
        }
Beispiel #2
0
        public void AddRemoveOrderTest()
        {
            OrderingSystem os = new OrderingSystem();

            os.Setup();
            List <OrderItem> itemList = new List <OrderItem>();

            itemList.Add(new OrderItem(1, "Membership Activation", 1, 100));
            Order neworder = new Order(OrderType.MembershipActivation, itemList, 100.00);

            Assert.AreEqual(os.AddOrder(neworder), true);
            Assert.AreEqual(os.RemoveOrder(neworder.OrderId), true);
        }
Beispiel #3
0
        protected void OrderButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateOrder())  //Validate Order
                {
                    List <OrderItem> itemList = new List <OrderItem>();
                    switch (OrderType.SelectedValue)
                    {
                    case "P":

                        itemList.Add(new OrderItem(1, "A Great Solid Product", 1, Convert.ToDouble(PaymentAmount.Text)));
                        Order newProductorder = new Order(eOrder.OrderType.PhysicalProduct, itemList, Convert.ToDouble(PaymentAmount.Text));
                        if (OSys.AddOrder(newProductorder))
                        {
                            ShowOrderPage(newProductorder);
                        }
                        else
                        {
                            FailureNotify.Visible = true;
                            SucessNotify.Visible  = false;
                        }
                        break;

                    case "B":
                        itemList.Add(new OrderItem(1, "A Great Book", 1, Convert.ToDouble(PaymentAmount.Text)));
                        Order newBookorder = new Order(eOrder.OrderType.Book, itemList, Convert.ToDouble(PaymentAmount.Text));
                        if (OSys.AddOrder(newBookorder))
                        {
                            ShowOrderPage(newBookorder);
                        }
                        else
                        {
                            FailureNotify.Visible = true;
                            SucessNotify.Visible  = false;
                        }
                        break;

                    case "M":
                        //Check if Activation or Upgrade
                        if (ActivationOption.Checked)
                        {
                            itemList.Add(new OrderItem(1, "Membership Activation", 1, Convert.ToDouble(PaymentAmount.Text)));
                            Order newMembershiporder = new Order(eOrder.OrderType.MembershipActivation, itemList, Convert.ToDouble(PaymentAmount.Text));
                            if (OSys.AddOrder(newMembershiporder))
                            {
                                ShowOrderPage(newMembershiporder);
                            }
                            else
                            {
                                FailureNotify.Visible = true;
                                SucessNotify.Visible  = false;
                            }
                        }
                        else if (UpgradeOption.Checked)
                        {
                            itemList.Add(new OrderItem(1, "Membership Upgrade", 1, Convert.ToDouble(PaymentAmount.Text)));
                            Order newMembershiporder = new Order(eOrder.OrderType.MembershipUpgrade, itemList, Convert.ToDouble(PaymentAmount.Text));
                            if (OSys.AddOrder(newMembershiporder))
                            {
                                ShowOrderPage(newMembershiporder);
                            }
                            else
                            {
                                FailureNotify.Visible = true;
                                SucessNotify.Visible  = false;
                            }
                        }
                        break;

                    case "V":
                        itemList.Add(new OrderItem(1, VideoLibraryDropdown.SelectedItem.ToString(), 1, Convert.ToDouble(PaymentAmount.Text)));
                        Order newVideoorder = new Order(eOrder.OrderType.Video, itemList, Convert.ToDouble(PaymentAmount.Text));
                        if (OSys.AddOrder(newVideoorder))
                        {
                            ShowOrderPage(newVideoorder);
                        }
                        else
                        {
                            FailureNotify.Visible = true;
                            SucessNotify.Visible  = false;
                        }
                        break;

                    default:
                        FailureNotify.Visible = true;
                        SucessNotify.Visible  = false;
                        break;
                    }
                }
                else
                {
                    FailureNotify.Visible = true;
                    SucessNotify.Visible  = false;
                }
            }
            catch (Exception)
            {
                FailureNotify.Visible = true;
                SucessNotify.Visible  = false;
            }
        }