示例#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 MakeOrderByTimeOfDayTest()
 {
     DinerOrderBuilding builder = new DinerOrderBuilding();
     Order testOrder = builder.MakeOrderByTimeOfDay("morning");
     OrderFactory  morningOrderFactory = new MorningOrderFactory();
     MorningOrder morningOrder = new MorningOrder(morningOrderFactory, 1, 1, 99, 1);
     Assert.AreEqual(testOrder.GetType(), morningOrder.GetType());
 }
示例#3
0
 public void AddSideTest()
 {
     OrderFactory orderFactory = new MorningOrderFactory();
     Dish side = orderFactory.AddSide();
     Assert.AreEqual(side.GetType(), new Toast().GetType());
 }
示例#4
0
 public void AddInvalidDishTest()
 {
     OrderFactory orderFactory = new MorningOrderFactory();
     Dish invalid = orderFactory.AddInvalidDish();
     Assert.AreEqual(invalid.Name, "error");
 }
示例#5
0
 public void AddEntreeTest()
 {
     OrderFactory orderFactory = new MorningOrderFactory();
     Dish entree = orderFactory.AddEntree();
     Assert.AreEqual(entree.GetType(), new Eggs().GetType());
 }
示例#6
0
 public void AddDrinkTest()
 {
     OrderFactory orderFactory = new MorningOrderFactory();
     Dish drink = orderFactory.AddDrink();
     Assert.AreEqual(drink.GetType(), new Coffee().GetType());
 }
示例#7
0
 public void AddDesertTest()
 {
     OrderFactory orderFactory = new MorningOrderFactory();
     Dish desert = orderFactory.AddDesert();
     Assert.AreEqual(desert.Name, "error");
 }