示例#1
0
 public void SetupFactories()
 {
     _drinkFactory           = new DrinkFactory();
     _drinkIngredientFactory = new DrinkIngredientFactory();
     _baristaInformer        = new TestBaristaInformer();
     _logger = new TestLogger();
 }
示例#2
0
 public static void Prepare(IDrink drink, IBaristaInformer informer)
 {
     if (drink.IsValid)
     {
         string message = "We are preparing the following drink for you: " + drink.Description;
         informer.Inform(message);
     }
     else
     {
         throw new Exception("We could not prepare the following drink: " + drink.Description);
     }
 }
示例#3
0
        public AcuCafe(IDrinkFactory df, IDrinkIngredientFactory dif, IBaristaInformer bi, ILogger logger)
        {
            _drinkFactory           = df;
            _drinkIngredientFactory = dif;
            _informer = bi;
            _logger   = logger;

            // Ideally this would be done somewhere else, but we don't have time to build that somewhere else
            _drinkFactory.RegisterDrink("Espresso", typeof(Espresso));
            _drinkFactory.RegisterDrink("HotTea", typeof(Tea));
            _drinkFactory.RegisterDrink("IceTea", typeof(IceTea));

            // Likewise for the ingredients, we register them here, but it really needs to be moved
            _drinkIngredientFactory.RegisterDrinkIngredient("milk", typeof(MilkIngredient));
            _drinkIngredientFactory.RegisterDrinkIngredient("sugar", typeof(SugarIngredient));
            _drinkIngredientFactory.RegisterDrinkIngredient("chocolate topping", typeof(ChocolateTopping));
        }