public void MakeBeverage(BeverageBuilder builder) { builder.AddCoffee(); builder.AddMilk(); builder.AddPearl(); builder.AddSugar(); builder.AddWater(); builder.AddTea(); }
public Beverage MakeBeverage(BeverageBuilder beverageBuilder) { beverageBuilder.CreateBeverage(); beverageBuilder.SetBeverageType(); beverageBuilder.SetWater(); beverageBuilder.SetMilk(); beverageBuilder.SetSugar(); beverageBuilder.SetPowderQuantity(); return(beverageBuilder.GetBeverage()); }
public void CupTypeFalse() { var cupTypeFail = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Latte) .SelectCup(CupTypes.CupType.Small) .ChooseBeans(BeanTypes.BeanType.Arabica) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.IsFalse(CupTypes.CupType.Medium == cupTypeFail.CupSize); }
public void BoiledWaterAmericanoFalse() { var water = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Americano) .SelectCup(CupTypes.CupType.Small) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.IsFalse(0 == water.Water); }
public void BoiledWaterLargeCupAmericano() { var water = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Americano) .SelectCup(CupTypes.CupType.Large) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.AreEqual(24, water.Water); }
public void CupTypeLarge() { var cupType = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Latte) .SelectCup(CupTypes.CupType.Large) .ChooseBeans(BeanTypes.BeanType.Arabica) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.AreEqual(CupTypes.CupType.Large, cupType.CupSize); }
public void BoiledWaterMediumCup() { var water = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Mocha) .SelectCup(CupTypes.CupType.Medium) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.AreEqual(12, water.Water); }
public void BeanAmountFalse() { var bean = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Espresso) .SelectCup(CupTypes.CupType.Small) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.IsFalse(100 == bean.BeanAmount); }
public void BeanAmountLarge() { var bean = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Espresso) .SelectCup(CupTypes.CupType.Large) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.AreEqual(8, bean.BeanAmount); }
public void BeanTypeFalse() { var bean = BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Macchiato) .SelectCup(CupTypes.CupType.Small) .ChooseBeans(BeanTypes.BeanType.Arabica) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.IsFalse(BeanTypes.BeanType.Robusta == bean.Bean); }
public void CheckIngredientsMocha() { var ingredient = (Mocha)BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Mocha) .SelectCup(CupTypes.CupType.Medium) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.AreEqual(ingredient.Milk, 24); Assert.AreEqual(ingredient.ChocolateSyrup, 12); }
//Checking parent public void InstanceTest() { var cappuccino = BeverageBuilder. StartBrew() .CoffeeType(BeverageTypes.BeverageType.Cappuccino) .SelectCup(CupTypes.CupType.Large) .ChooseBeans(BeanTypes.BeanType.Arabica) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); Assert.IsInstanceOfType(cappuccino, typeof(Espresso)); }
public void CheckIngredientsCustom() { var ingredient = (Custom)BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Custom) .SelectCup(CupTypes.CupType.Small) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() .AddIngredient(10, 20, 30) .ToBeverage(); Assert.AreEqual(ingredient.Milk, 10); Assert.AreEqual(ingredient.MilkFoam, 20); Assert.AreEqual(ingredient.ChocolateSyrup, 30); }
//Checking child public void InstanceTest2() { var cappuccino = BeverageBuilder. StartBrew() .CoffeeType(BeverageTypes.BeverageType.Cappuccino) .SelectCup(CupTypes.CupType.Large) .ChooseBeans(BeanTypes.BeanType.Arabica) .GrindBean() .BoilWater() .AddIngredient() .ToBeverage(); //If you change typeof below to Macchiato, test will fail. Assert.IsInstanceOfType(cappuccino, typeof(Capuccino)); }
public void Check_Ingredients_Macchiato_Ignoring_Parameters() { var ingredient = (Macchiato)BeverageBuilder.StartBrew() .CoffeeType(BeverageTypes.BeverageType.Macchiato) .SelectCup(CupTypes.CupType.Medium) .ChooseBeans(BeanTypes.BeanType.Robusta) .GrindBean() .BoilWater() //The only beverage that actually can take parameters is Custom. //This Assert will pass, because a Macchiato has its predefined ingredients based on cupsize. //Therefore our program will ignore the parameter values below. .AddIngredient(100, 100, 100) .ToBeverage(); Assert.AreEqual(ingredient.MilkFoam, 36); }
private void AddBeverage(object sender, RoutedEventArgs e) { if (FieldsAreValid()) { Beverage beverage = builder.Build(); if (AlreadyAddedSimilar(beverage)) { MessageUtils.ShowError($"O acompanhamento {beverage} já foi adicionado ao pedido"); } else { beverages.Add(builder.Build()); builder = new BeverageBuilder().WithQuantity(Int32.Parse(txtQuantity.Text)); ResetForm(); } } }
public Beverage Get(string beverage, [FromQuery] string name = "", [FromQuery] bool withExtraShot = false) { var beverageBuilder = (beverage.ToLower()) switch { "americano" => BeverageBuilder.Americano(name), "cappuccino" => BeverageBuilder.Cappuccino(name), "conpanna" => BeverageBuilder.ConPanna(name), "coffee" => BeverageBuilder.Coffee(name), "doppio" => BeverageBuilder.Doppio(name), "espresso" => BeverageBuilder.Espresso(name), "mocha" => BeverageBuilder.Mocha(name), _ => throw new ArgumentException("That's not on the menu."), }; if (withExtraShot) { beverageBuilder.AddIngredient(Ingredient.EspressoShot); } return(beverageBuilder.Build()); }