Ejemplo n.º 1
0
        public void Test_Solo_Case()
        {
            BuildDataTest();
            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Carpet");

            Assert.AreEqual(40, pim.TotalPurchase());
        }
Ejemplo n.º 2
0
        public void Test_Buy_By_Weight_Special()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("flour", 10);

            Assert.AreEqual(60, pim.TotalPurchase());
        }
Ejemplo n.º 3
0
        public void Test_Buy_By_Weight()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("beef", 2);

            Assert.AreEqual(20, pim.TotalPurchase());
        }
Ejemplo n.º 4
0
        public void Test_Limited_Specials()
        {
            BuildDataTest();
            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Carpet");
            pim.Add("carpet");

            Assert.AreEqual(140, pim.TotalPurchase());
        }
Ejemplo n.º 5
0
        public void Test_Buy_By_Weight_Special_More_Activates_Than_Receives_Flip()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("chicken", 10);
            pim.Add("chicken", 5);

            Assert.AreEqual(100, pim.TotalPurchase());
        }
Ejemplo n.º 6
0
        public void Test_Buy_Item()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Beef", 1);
            pim.Add("Chicken", 1);

            Assert.AreEqual(2, pim.TotalPurchasedEntries());
            Assert.AreEqual(20, pim.TotalNoSpecialPurchase());
        }
Ejemplo n.º 7
0
        public void Test_Deferred()
        {
            BuildDataTest();
            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Beef", 10);
            pim.Add("Beef", 8);

            //10lb beef triggers the special
            //8lb beef gets the special (half off).
            Assert.AreEqual(140, pim.TotalPurchase());
        }
Ejemplo n.º 8
0
        public void Test_Special_Deal_Fixed_Active()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup", 1);
            pim.Add("soup", 1);
            pim.Add("soup", 1);

            Assert.AreEqual(6, pim.TotalPurchase());
        }
Ejemplo n.º 9
0
        public void Test_Buy_By_Weight_Multiple()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("beef", 2);
            pim.Add("beef", 3);
            pim.Add("chicken", 7);
            pim.Add("ChIcKeN", 3);

            Assert.AreEqual(150, pim.TotalNoSpecialPurchase());
        }
Ejemplo n.º 10
0
        public void Test_Limited_Removed()
        {
            BuildDataTest();
            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Carpet");
            pim.Add("carpet");

            pim.RemoveSpecific(0);


            Assert.AreEqual(40, pim.TotalPurchase());
        }
Ejemplo n.º 11
0
        public void Test_Buy_By_Weight_Special_Multiple()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("chicken", 10);
            pim.Add("chiCken", 5);
            pim.Add("cHicken", 10);
            pim.Add("chickEn", 5);

            Assert.AreEqual(200, pim.TotalPurchase());
        }
        public static CustomerDetails GetCustomer(int id)
        {
            try
            {
                IManager <Customer>     customerManager     = new CustomerManager();
                IManager <Purchase>     purchaseManager     = new PurchaseManager();
                IManager <PurchaseItem> purchaseItemManager = new PurchaseItemManager();
                IManager <Item>         itemManager         = new ItemManager();

                CustomerDetails customer = new CustomerDetails(customerManager.GetById(id));

                Purchase conditionPurchase = new Purchase {
                    CustomerId = id
                };
                PurchaseItem conditionPurchaseItem = new PurchaseItem();

                foreach (Purchase purchase in purchaseManager.GetAllWhere(conditionPurchase))
                {
                    customer.PurchaseHistory.Add(new PurchaseHistory(purchase));
                }

                foreach (PurchaseHistory purchaseHistory in customer.PurchaseHistory)
                {
                    conditionPurchaseItem.PurchaseId = purchaseHistory.Purchase.Id;

                    foreach (PurchaseItem purchaseItem in purchaseItemManager.GetAllWhere(conditionPurchaseItem))
                    {
                        if (purchaseHistory.Purchase.Status == ProfileStringConstants.PENDING)
                        {
                            Item item = itemManager.GetById(purchaseItem.ItemId);
                            purchaseItem.Price    = item.Price;
                            purchaseItem.SubTotal = purchaseItem.Quantity * item.Price;
                            purchaseItemManager.Update(purchaseItem);
                            purchaseHistory.PurchaseDetails.Add(new PurchaseDetails(purchaseItem, item));
                        }
                        else
                        {
                            purchaseHistory.PurchaseDetails.Add(new PurchaseDetails(purchaseItem, itemManager.GetById(purchaseItem.ItemId)));
                        }
                    }
                }

                return(customer);
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex.ToString());
                return(null);
            }
        }
Ejemplo n.º 13
0
        public void Test_Specials_Remove()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");

            pim.RemoveLast("soup");

            Assert.AreEqual(10, pim.TotalPurchase());
        }
Ejemplo n.º 14
0
        public void Test_CartItem_Price_After_Special()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");

            Assert.AreEqual(2, pim.GetAtPosition(0).GetPrice());
            Assert.AreEqual(2, pim.GetAtPosition(1).GetPrice());
            Assert.AreEqual(2, pim.GetAtPosition(2).GetPrice());
        }
Ejemplo n.º 15
0
        public void Test_Bundle()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("flour");
            pim.Add("flour");
            pim.Add("flour");

            //Three bags of flour for just $6 as opposed to 18.

            Assert.AreEqual(6, pim.TotalPurchase());
        }
Ejemplo n.º 16
0
        public void Test_Multiple_Applied_Specials()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");

            Assert.AreEqual(12, pim.TotalPurchase());
        }
Ejemplo n.º 17
0
        public void Test_Deferred_Scale_Down()
        {
            BuildDataTest();
            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Beef", 20);
            pim.Add("Beef", 10);
            pim.Add("Beef", 8);

            pim.RemoveSpecific(1);

            //20 pounder starts. 10 gets the special.
            //10 then gets removed, so 8 gets the special.
            Assert.AreEqual(240, pim.TotalPurchase());
        }
Ejemplo n.º 18
0
        public void Test_Deferred_Scale_Up()
        {
            BuildDataTest();
            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Beef", 10);
            pim.Add("Beef", 8);
            pim.Add("Beef", 20);

            //10lb beef triggers the special
            //8lb beef gets the special (half off).
            //20lb beef then causes itself to be the header, moving the special
            //from the 8 pounder to the 10 pounder.
            Assert.AreEqual(330, pim.TotalPurchase());
        }
Ejemplo n.º 19
0
        public void Test_Special_Interwoven()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup");
            pim.Add("chicken");
            pim.Add("soup");
            pim.Add("beef");
            pim.Add("soup");
            pim.Add("peas");

            Assert.AreEqual(36, pim.TotalPurchase());
        }
Ejemplo n.º 20
0
        public void Test_Special_Multiple()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("candy");
            pim.Add("Candy");

            //soup for 5-3, 2 x 3
            //candy for 4-2, 2 x 2
            Assert.AreEqual(10, pim.TotalPurchase());
        }
        public void LoadData()
        {
            Customer.PurchaseHistory.Clear();

            foreach (Purchase purchase in PurchaseManager.GetAllById(Customer.Info.Id, "CustomerId"))
            {
                Customer.PurchaseHistory.Add(new PurchaseHistory(purchase));
            }

            foreach (PurchaseHistory purchaseHistory in Customer.PurchaseHistory)
            {
                foreach (PurchaseItem purchaseItem in PurchaseItemManager.GetAllById(purchaseHistory.Purchase.Id, "PurchaseId"))
                {
                    purchaseHistory.PurchaseDetails.Add(new PurchaseDetails(purchaseItem, ItemManager.GetById(purchaseItem.ItemId, "Id")));
                }
            }
        }
Ejemplo n.º 22
0
        public void Test_Buy_By_Weight_Special_Interwoven()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("chicken", 10);
            pim.Add("soup");
            pim.Add("chiCken", 5);
            pim.Add("soup");
            pim.Add("cHicken", 5);
            pim.Add("soup");

            //3 for 6 on soup and 50% off on expensive-est chicken.

            Assert.AreEqual(156, pim.TotalPurchase());
        }
Ejemplo n.º 23
0
        public void Test_Buy_Item_Multiple()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("Beef", 1);
            pim.Add("beef", 1);
            pim.Add("beeF", 1);
            pim.Add("chicken", 1);
            pim.Add("Chicken", 1);
            pim.Add("soup", 1);
            pim.Add("Soup", 1);
            pim.Add("soUp", 1);

            Assert.AreEqual(8, pim.TotalPurchasedEntries());
            Assert.AreEqual(65, pim.TotalNoSpecialPurchase());
        }
Ejemplo n.º 24
0
        public void Test_Multiple_Applied_Specials_Remove()
        {
            BuildDataTest();

            PurchaseItemManager pim = new PurchaseItemManager();

            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");
            pim.Add("soup");

            pim.RemoveLast("Soup");

            //Three at discount (5 - 3)
            //Two at normal (5)
            //For a total of 16.
            Assert.AreEqual(16, pim.TotalPurchase());
        }