Esempio n. 1
0
        public void DropShoppingCart_Should_ZeroOutCart_RestoreInventory()
        {
            var store        = new OnlineStore(new Catalog());
            var customerName = CustomerName;

            store.CreateShoppingCart(customerName);
            var originalTotalInventory = Catalog.GetTotalProducts();

            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 3);

            Assert.AreEqual(originalTotalInventory - 3, Catalog.GetTotalProducts());
            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Backpack, 2);
            Assert.AreEqual(originalTotalInventory - 3 - 2, Catalog.GetTotalProducts());

            Assert.AreEqual(3, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent));
            Assert.AreEqual(2, store.GetItemCountInCart(customerName, ProductTypeEnum.Backpack));

            store.DropShoppingCart(customerName);
            Assert.AreEqual(store.GetItemCountInCart(customerName, ProductTypeEnum.Tent), 0);
            Assert.AreEqual(store.GetItemCountInCart(customerName, ProductTypeEnum.Backpack), 0);
            // total inventory changed back
            Assert.AreEqual(originalTotalInventory, Catalog.GetTotalProducts());
        }