public void StopIcedTeaWithMilkOrder() { DrinkBuilder drinkBuilder = new DrinkBuilder(); Barista helen = new Barista(drinkBuilder); var tea = new DrinkType("Tea", 1.5); var icedTea = new DrinkType("Iced Tea", 1.5); var milk = new Topping("Milk", 0.5); var sugar = new Topping("Sugar", 0.5); var jonsToppings = new List <Topping>() { milk, sugar }; var jonsDrinkTea = helen.OrderDrink(tea, jonsToppings); var robisToppings = new List <Topping>() { milk }; var robisDrinkIcedTea = helen.OrderDrink(icedTea, robisToppings); helen.PrepareDrink(jonsDrinkTea); helen.PrepareDrink(robisDrinkIcedTea); helen.StopOrder(robisDrinkIcedTea); var completeDrinks = helen.ServeDrinkOrders(); Assert.IsFalse(completeDrinks.Contains(robisDrinkIcedTea)); }
/// <summary> /// Создание напитка /// </summary> /// <param name="drinkBuilder">Строитель напитка(тип напитка)</param> /// <param name="nameDrink">Наименование напитка</param> /// <param name="qSugar">Количество едениц сахара</param> /// <param name="addMilk">Наличие молока</param> /// <param name="addSyrup">Наличие сиропа</param> /// <param name="addCappuccinoFoam">Наличие молочной пенки</param> /// <returns>Напиток(Drink)</returns> public Drink CreateDrink(DrinkBuilder drinkBuilder, string nameDrink, int qSugar, bool addMilk, bool addSyrup, bool addCappuccinoFoam) { drinkBuilder.CreateDrink(nameDrink); drinkBuilder.AddCoffee(); drinkBuilder.AddTea(); drinkBuilder.AddWater(); drinkBuilder.AddMilk(addMilk); drinkBuilder.AddSyrup(addSyrup); drinkBuilder.AddSugar(qSugar); drinkBuilder.AddCappuccinoFoam(addCappuccinoFoam); return(drinkBuilder.Drink); }
public Drink MakeDrink(DrinkBuilder builder) { if (!BarOpen) { return(null); } Drink drink = DrinkBuilder.GetDrink(builder); Notify(drink.Price); return(drink); }
public void GivenBadAmountForChocolateShouldIndicateAmountIsInsufficient() { // Arrange var drinkBuilder = new DrinkBuilder(new SugarService(), new MoneyAmountService()); drinkBuilder.SelectDrink(new Chocolate()); drinkBuilder.InsertMoney(0.3); // Act bool result = drinkBuilder.IsAmountIsEnough; // Assert Assert.False(result); }
public void GivenBadAmountForChocolateShouldGetMissingAMountMessage() { // Arrange var drinkBuilder = new DrinkBuilder(new SugarService(), new MoneyAmountService()); drinkBuilder.SelectDrink(new Chocolate()); drinkBuilder.InsertMoney(0.3); // Act string result = drinkBuilder.SendMessageToUi(); // Assert Assert.False(drinkBuilder.IsAmountIsEnough); Assert.Equal("0,2€ missing", result); }
public Drink CreateDrink(string name, Type type) { IDrinkBuilder builder = new DrinkBuilder(name); switch (type) { case Type.Hot: ConcreteDrinkBuilder hot = new ConcreteDrinkBuilder(); hot.Hot(builder); return(builder.BuildDrink()); case Type.Cold: ConcreteDrinkBuilder cold = new ConcreteDrinkBuilder(); cold.Cold(builder); return(builder.BuildDrink()); } return(null); }
public void AddChocolateToppingToExpresso() { DrinkBuilder drinkBuilder = new DrinkBuilder(); Barista helen = new Barista(drinkBuilder); var expresso = new DrinkType("Expresso", 1.5); var chocolate = new Topping("Chocolate", 0.5); var chocExpressoToppings = new List <Topping>() { chocolate }; // should add method overloads so that list and single topping can be accepted var chocExpressoDrink = helen.OrderDrink(expresso, chocExpressoToppings); Assert.AreEqual(chocExpressoDrink.ToString(), "Drink: Expresso with Toppings: Chocolate"); }
public static void Main(string[] args) { // needs to consider if Type/Topping price changes i.e. tea becomes 2.0 // might want to mislabel a customers name later on // was goinng to restrict to only one topping of type milk but users can order extra milk // would have typed Toppings and Drinks as Enum but we need to have flexibility adding and // removing, stringly typed it is // would also wrap statements in tryc / finally or using blocks and add exception handling DrinkBuilder drinkBuilder = new DrinkBuilder(); Barista helen = new Barista(drinkBuilder); var tea = new DrinkType("Tea", 1.5); var milk = new Topping("Milk", 0.5); var sugar = new Topping("Sugar", 0.5); var jonsToppings = new List <Topping>() { milk, sugar }; var jonsDrink = helen.OrderDrink(tea, jonsToppings); var robisToppings = new List <Topping>() { milk }; var robisDrink = helen.OrderDrink(tea, robisToppings); helen.PrepareDrink(jonsDrink); helen.PrepareDrink(robisDrink); helen.StopOrder(jonsDrink); helen.ServeDrinkOrders(); Console.ReadLine(); }
public Sugar() { _drinkBuilder = new DrinkBuilder(new SugarService(), new MoneyAmountService()); }