예제 #1
0
        private void Test_PizzaGetTotalCost()
        {
            var pizza = new Pizza();

            var topping1 = APizzaPartFactory.MakeTopping("cheese");
            var topping2 = APizzaPartFactory.MakeTopping("sauce");
            var crust    = APizzaPartFactory.MakeCrust("regular");
            var size     = APizzaPartFactory.MakeSize("medium");
            var amount   = 1d + topping1.Price + topping2.Price + crust.Price + size.Price;

            pizza.AddTopping(topping1);
            pizza.AddTopping(topping2);
            pizza.Crust = crust;
            pizza.Size  = size;
            Assert.True(pizza.GetTotalCost() == amount);
        }
예제 #2
0
        private static void Test_OrderGetTotalAmount()
        {
            var order    = new Order();
            var pizza    = new Pizza();
            var topping1 = APizzaPartFactory.MakeTopping("cheese");
            var topping2 = APizzaPartFactory.MakeTopping("sauce");

            pizza.Crust = APizzaPartFactory.MakeCrust("regular");
            pizza.Size  = APizzaPartFactory.MakeSize("large");
            pizza.AddTopping(topping1);
            pizza.AddTopping(topping2);
            order.AddPizza(pizza);

            var total = 1d + pizza.Crust.Price + pizza.Size.Price + topping1.Price + topping2.Price;

            Assert.True(order.GetTotalAmount() == total);
        }
예제 #3
0
        private void Test_OrderAddPizza()
        {
            var order1 = new Order();
            var order2 = new Order();

            var pizza  = new Pizza();
            var pizza2 = new Pizza();

            pizza2.Crust = APizzaPartFactory.MakeCrust("regular");
            pizza2.Size  = APizzaPartFactory.MakeSize("large");

            Assert.True(pizza2.GetTotalCost() == 5d);
            Assert.False(order1.AddPizza(null));
            for (int amount = 0; amount < 50; amount++)
            {
                Assert.True(order1.AddPizza(pizza));
            }
            Assert.False(order1.AddPizza(pizza));
            for (int amount = 0; amount < 50; amount++)
            {
                Assert.True(order2.AddPizza(pizza2));
            }
            Assert.False(order2.AddPizza(pizza2));
        }