예제 #1
0
        public void TestMethod1_basket_updateSenrio()
        {
            setUp();
            DBtransactions.getInstance(true);

            Assert.AreEqual(0, basket_user.ShoppingCarts.Count);
            LinkedList <KeyValuePair <Product, int> > toInsert = new LinkedList <KeyValuePair <Product, int> >();

            Assert.AreEqual(null, basket_user.addProductsToCart(toInsert, store.Id, user.Id));

            toInsert.AddLast(new KeyValuePair <Product, int>(this.p1, 10));

            Assert.AreEqual(0, basket_user.ShoppingCarts.Count);
            Assert.AreEqual(expected: store.Id, actual: basket_user.addProductsToCart(toInsert, store.Id, user.Id).StoreId);
            Assert.AreEqual(1, basket_user.ShoppingCarts.Count);


            StubCart cart = new StubCart(-1, null, 10);

            cart.copy(basket_user.ShoppingCarts[store.Id]);
            basket_user.ShoppingCarts[store.Id] = cart;


            Assert.AreEqual(1, basket_user.ShoppingCarts.Count);
            Assert.AreEqual(10, basket_user.ShoppingCarts[cart.StoreId].Products[this.p1.Id].Quantity);

            Assert.AreEqual(expected: null, actual: basket_user.addProductsToCart(toInsert, store.Id, user.Id));
            Assert.AreEqual(1, basket_user.ShoppingCarts.Count);
            Assert.AreEqual(20, basket_user.ShoppingCarts[cart.StoreId].Products[this.p1.Id].Quantity);
        }
        public void testmethod_basket_success_remove()
        {
            setup();
            productsToRemove = new List <int>();
            productsToRemove.Add(product.Id);
            ShoppingBasket basket = new ShoppingBasket();
            ShoppingCart   cart   = new StubCart(store.Id, null, true);

            basket.ShoppingCarts.Add(store.Id, cart);
            DBtransactions.getInstance(true);
            Assert.AreEqual(true, basket.removeProductsFromCart(productsToRemove, store.Id, -1));
        }
예제 #3
0
        public void TestMethod1_payForBasket_succ()
        {
            setUp();
            sys.FinancialSystem = new StubFinancialSystem(true);
            sys.SupplySystem    = new StubProductSupplySystem(true);

            ShoppingCart cart = new StubCart(store.Id, store, 10);

            cart.Products.Add(p1.Id, new ProductInCart(1, cart, p1));
            cart.Products.Add(p2.Id, new ProductInCart(1, cart, p2));
            cart.Products.Add(p3.Id, new ProductInCart(1, cart, p3));
            cart.Products.Add(p4.Id, new ProductInCart(1, cart, p4));
            cart.Store  = new StubStore(1, "", 0, true, 0);
            user.Basket = new StubBasket(13);
            sys.Stores.Add(1, cart.Store);
            user.Basket.ShoppingCarts.Add(1, cart);
            List <String[]> check = sys.cartToString(cart);


            Assert.AreEqual(expected: check.Count, actual: sys.payForBasket(0, new DateTime(1990, 1, 1), user.Id).Count);
        }