Пример #1
0
        public void CustomerCannotPlaceMoreTwoOrdersFromSameLocationWithinTwoHours()
        {
            //Arrange
            PizzaStore newPizzaStore      = new PizzaStore();
            Customer   newCustomer        = new Customer();
            Pizza      cheesePizza        = new Pizza();
            Dictionary <Pizza, int> order = new Dictionary <Pizza, int>()
            {
                { cheesePizza, 1 }
            };
            Dictionary <Pizza, int> order2 = new Dictionary <Pizza, int>()
            {
                { cheesePizza, 1 }
            };

            //Act
            newPizzaStore.PlacedOrder(newCustomer, order);

            //Assert
            Assert.Throws <Exception>(() => newPizzaStore.PlacedOrder(newCustomer, order));
        }
Пример #2
0
        public void NewOrderShouldRejectAmountGreaterThanInventory(int amount) //* rejects orders that cannot be fulfilled with remaining inventory
        {
            //Arrange
            PizzaStore newPizzaStore      = new PizzaStore();
            Customer   newCustomer        = new Customer();
            Pizza      cheesePizza        = new Pizza();
            Dictionary <Pizza, int> order = new Dictionary <Pizza, int>()
            {
                { cheesePizza, amount }
            };

            //Act
            Assert.Throws <ArgumentException>(() => newPizzaStore.PlacedOrder(newCustomer, order));
        }
Пример #3
0
        public void PlacedOrderShouldRejectNegativeAmountOrZero(int amount)
        {
            //Arrange
            PizzaStore newPizzaStore      = new PizzaStore();
            Customer   newCustomer        = new Customer();
            Pizza      cheesePizza        = new Pizza();
            Dictionary <Pizza, int> order = new Dictionary <Pizza, int>()
            {
                { cheesePizza, amount }
            };

            //Act and Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => newPizzaStore.PlacedOrder(newCustomer, order));
        }
Пример #4
0
        public void NewOrderShouldDecreaseStoreInventoryByPositiveAmount(int amount) //* inventory decreases when orders are accepted
        {
            //Arrange
            PizzaStore newPizzaStore      = new PizzaStore();
            Customer   newCustomer        = new Customer();
            Pizza      cheesePizza        = new Pizza();
            Dictionary <Pizza, int> order = new Dictionary <Pizza, int>()
            {
                { cheesePizza, amount }
            };
            var originalInventory = new Dictionary <string, int> (newPizzaStore.Inventory);

            //Act
            newPizzaStore.PlacedOrder(newCustomer, order);
            var decreasedInventory = new Dictionary <string, int>(newPizzaStore.Inventory);

            foreach (var item in cheesePizza.Items)
            {
                Assert.Equal(originalInventory[item.Key], decreasedInventory[item.Key] + (amount * item.Value));
            }
        }