Example #1
0
        public void UpdateQuantityTest()
        {
            int totalPrice = 0;

            totalPrice += _itemInfo.GetItemPrice("item0");
            _itemOrder.AddToOrder("item0");
            Assert.AreEqual(totalPrice, _itemOrder.GetTotalPrice());

            Assert.AreEqual(10, _itemOrder.UpdateQuantity(0, 10));
            Assert.AreEqual(totalPrice * 10, _itemOrder.GetTotalPrice());

            Assert.AreEqual(10, _itemOrder.UpdateQuantity(0, 20));
            Assert.AreEqual(totalPrice * 10, _itemOrder.GetTotalPrice());

            Assert.AreEqual(1, _itemOrder.UpdateQuantity(0, 1));
            Assert.AreEqual(totalPrice, _itemOrder.GetTotalPrice());

            Assert.AreEqual(0, _itemOrder.UpdateQuantity(-1, 10));
            Assert.AreEqual(totalPrice, _itemOrder.GetTotalPrice());

            Assert.AreEqual(0, _itemOrder.UpdateQuantity(1, 10));
            Assert.AreEqual(totalPrice, _itemOrder.GetTotalPrice());
        }