コード例 #1
0
        public void RemoveMoreItemsFromCart_Expecting_Exception()
        {
            var          store        = new OnlineStore(new Catalog());
            const string customerName = CustomerName;

            store.CreateShoppingCart(customerName);
            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 8);
            store.RemoveItemFromShoppingCart(customerName, ProductTypeEnum.Tent, 10);
        }
コード例 #2
0
        public void RemoveItemFromCart_ReturnsToInventory()
        {
            var store        = new OnlineStore(new Catalog());
            var customerName = CustomerName;

            store.CreateShoppingCart(customerName);
            bool hasInventory = store.CheckInventory(ProductTypeEnum.Tent) >= 5;

            Assert.IsTrue(hasInventory);
            store.AddItemToShoppingCart(customerName, ProductTypeEnum.Tent, 5);
            int tentInInventory = store.CheckInventory(ProductTypeEnum.Tent);

            Assert.AreEqual(tentInInventory, 4);

            Assert.AreEqual(5, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent));
            // now take one item from cart
            store.RemoveItemFromShoppingCart(customerName, ProductTypeEnum.Tent, 1);
            // show be 4 left in cart
            Assert.AreEqual(4, store.GetItemCountInCart(customerName, ProductTypeEnum.Tent));
            // inventory should have 5
            tentInInventory = store.CheckInventory(ProductTypeEnum.Tent);
            Assert.AreEqual(tentInInventory, 5);
        }