public IActionResult Index(DrinksSelectionViewModel drinksSelectionViewModel) { var selectedDrink = drinksSelectionViewModel.SelectedDrink; var builder = GetBuilderForSelectedHotDrink(selectedDrink); if (builder == null) { //TODO: UI error handling ViewBag.Errors = new List <string>(new List <string> { "can not handle the creation of selected hot drink" }); return(View(new DrinksSelectionViewModel())); } var hotDrinksMachine = new HotDrinksMachine(builder); hotDrinksMachine.MakeDrink(); var drink = hotDrinksMachine.GetDrink(); ViewBag.ActionsPerformedDuringOperation = drink.GetActionsPerformedDuringOperation(); return(View(new DrinksSelectionViewModel { SelectedDrink = drinksSelectionViewModel.SelectedDrink, })); }
public void Verify_Actions_When_Building_Coffee() { var hotDrinksMachine = new HotDrinksMachine(new CoffeeBuilder()); hotDrinksMachine.MakeDrink(); var drink = hotDrinksMachine.GetDrink(); var actions = drink.GetActionsPerformedDuringOperation(); Assert.That(actions.Count, Is.EqualTo(4)); Assert.That(actions[0], Is.EqualTo("Boil some water")); Assert.That(actions[1], Is.EqualTo("Brew the coffee grounds")); Assert.That(actions[2], Is.EqualTo("Pour coffee in the cup")); Assert.That(actions[3], Is.EqualTo("Add sugar and milk")); }
public void Verify_Actions_When_Building_Hot_Chocolate() { var hotDrinksMachine = new HotDrinksMachine(new ChocolateBuilder()); hotDrinksMachine.MakeDrink(); var drink = hotDrinksMachine.GetDrink(); var actions = drink.GetActionsPerformedDuringOperation(); // More than one assert is acceptable as we are testing the result of one method Assert.That(actions.Count, Is.EqualTo(3)); Assert.That(actions[0], Is.EqualTo("Boil some water")); Assert.That(actions[1], Is.EqualTo("Add drinking chocolate powder to the water")); Assert.That(actions[2], Is.EqualTo("Pour chocolate in the cup")); }
public void Verify_Actions_When_Building_Lemon_Tea() { var hotDrinksMachine = new HotDrinksMachine(new LemonTeaBuilder()); hotDrinksMachine.MakeDrink(); var drink = hotDrinksMachine.GetDrink(); var actions = drink.GetActionsPerformedDuringOperation(); Assert.That(actions.Count, Is.EqualTo(4)); Assert.That(actions[0], Is.EqualTo("Boil some water")); Assert.That(actions[1], Is.EqualTo("Steep the water in the tea")); Assert.That(actions[2], Is.EqualTo("Pour tea in the cup")); Assert.That(actions[3], Is.EqualTo("Add lemon")); }