コード例 #1
0
        public override Order MakeOrderByTimeOfDay(string timeOfDay)
        {
            Order currentOrder = null;
            if (timeOfDay.ToLower() == "morning")
            {
                OrderFactory morningOrderFactory = new MorningOrderFactory();
                //Creating a morning order with the following limits
                //1 Entree
                //1 Side
                //Unlimited drinks
                //No deserts
                currentOrder = new MorningOrder(morningOrderFactory,1,1,99,0);
            }
            else if (timeOfDay.ToLower() == "night")
            {
                OrderFactory nightOrderFactory = new NightOrderFactory();
                //Creating a night order with the following limits
                //1 Entree
                //Unlimited Sides
                //1 drink
                //1 deserts
                currentOrder = new NightOrder(nightOrderFactory,1,99,1,1);
            }

            return currentOrder;
        }
コード例 #2
0
 public void MakeOrderByTimeOfDayTest1()
 {
     DinerOrderBuilding builder = new DinerOrderBuilding();
     Order testOrder = builder.MakeOrderByTimeOfDay("night");
     OrderFactory  nightOrderFactory = new NightOrderFactory();
     NightOrder nightOrder = new NightOrder(nightOrderFactory, 1, 99, 1, 1);
     Assert.AreEqual(testOrder.GetType(), nightOrder.GetType());
 }
コード例 #3
0
 public void AddSideTest()
 {
     OrderFactory orderFactory = new NightOrderFactory();
     Dish side = orderFactory.AddSide();
     Assert.AreEqual(side.GetType(), new Potato().GetType());
 }
コード例 #4
0
 public void AddInvalidDishTest()
 {
     OrderFactory orderFactory = new NightOrderFactory();
     Dish invalid = orderFactory.AddInvalidDish();
     Assert.AreEqual(invalid.Name, "error");
 }
コード例 #5
0
 public void AddEntreeTest()
 {
     OrderFactory orderFactory = new NightOrderFactory();
     Dish entree = orderFactory.AddEntree();
     Assert.AreEqual(entree.GetType(), new Steak().GetType());
 }
コード例 #6
0
 public void AddDrinkTest()
 {
     OrderFactory orderFactory = new NightOrderFactory();
     Dish drink = orderFactory.AddDrink();
     Assert.AreEqual(drink.GetType(), new Wine().GetType());
 }
コード例 #7
0
 public void AddDesertTest()
 {
     OrderFactory orderFactory = new NightOrderFactory();
     Dish desert = orderFactory.AddDesert();
     Assert.AreEqual(desert.GetType(), new Cake().GetType());
 }