public void TestGetTransasctionInt()
        {
            Tuple <Product, int> item1 = new Tuple <Product, int>((new Product("Milk", 1, 1.89)), 3);
            Tuple <Product, int> item2 = new Tuple <Product, int>((new Product("Eggs", 2, 1.29)), 3);


            List <Tuple <Product, int> > list = new List <Tuple <Product, int> >();

            list.Add(item1);
            list.Add(item2);

            Transaction tran = new Transaction(1, list);

            TransactionDB.AddTransaction(tran);


            Tuple <Product, int> item3 = new Tuple <Product, int>((new Product("Milk", 1, 1.89)), 3);
            Tuple <Product, int> item4 = new Tuple <Product, int>((new Product("Eggs", 2, 1.29)), 3);

            list = new List <Tuple <Product, int> >();

            list.Add(item3);
            list.Add(item4);


            Transaction tran2 = new Transaction(2, list);

            TransactionDB.AddTransaction(tran2);

            Assert.AreEqual(TransactionDB.GetTransactionInt(), 4);
        }
Example #2
0
        public void TestAddToRebateList()
        {
            int    transactionID = 1;
            String rebatesBefore = RebateDB.GenerateRebateChecks();

            // Create Transaction
            int    salesID      = 1;
            int    itemID       = 1;
            int    itemQuantity = 1;
            double itemCost     = 2.29;
            // double rebatePercent = .05;
            // double totalRebate = itemQuantity * itemCost * rebatePercent;
            Product p1 = new Product("Diapers", itemID, itemCost);
            Tuple <Product, int>         tuple1 = new Tuple <Product, int>(p1, itemQuantity);
            List <Tuple <Product, int> > items  = new List <Tuple <Product, int> >();
            Transaction t1 = new Transaction(salesID, items);

            TransactionDB.AddTransaction(t1);

            // create a rebates controller and try to access the transaction and then rebate it. However, error with Transactions so fails
            Observer         ob         = new Observer((string s, State status) => { Assert.AreNotEqual(rebatesBefore, s); Assert.AreEqual(status, State.Rebate); });
            ReturnController controller = new ReturnController();

            controller.RegisterR(ob);
            controller.ProcessReturn(1, 1, 1);
        }
Example #3
0
        public void TestAllTestDB()
        {
            Product p = new Product("Test", 1, 1.99);

            Tuple <Product, int> tuple = new Tuple <Product, int>(p, 1);

            List <Tuple <Product, int> > l = new List <Tuple <Product, int> >();

            l.Add(tuple);

            Transaction trans = new Transaction(1, l);

            TransactionDB.AddTransaction(trans);

            Assert.Equals(TransactionDB.GetTransaction(1).GetItems[0].Item1.GetName, "Test");
        }
Example #4
0
        public void TestAddToRebateList()
        {
            int    transactionID = 1;
            String rebatesBefore = RebateDB.GenerateRebateChecks();

            // Create Transaction
            int     salesID      = 1;
            int     itemID       = 1;
            int     itemQuantity = 1;
            double  itemCost     = 2.29;
            Product p1           = new Product("Diapers", itemID, itemCost);
            Tuple <Product, int>         tuple1 = new Tuple <Product, int>(p1, itemQuantity);
            List <Tuple <Product, int> > items  = new List <Tuple <Product, int> >();
            Transaction t1 = new Transaction(salesID, items);

            TransactionDB.AddTransaction(t1);

            // Add transaction to rebate list
            Observer         ob         = new Observer((string s, State status) => { Assert.AreNotEqual(rebatesBefore, s); Assert.AreEqual(status, State.Rebate); });
            RebateController controller = new RebateController();

            controller.RegisterRC(ob);
            controller.AddToRebateList(Convert.ToDateTime("06/02/2018"), transactionID);
        }