public void ShouldSimpleSalad_Cost7() { _saladDecorator = new SaladDecorator(); _saladDecorator.ChooseSalad(new Batavia()); _saladDecorator.AddTopping(new ChickPeas()); var salad = _saladDecorator.GetSalad(); Assert.AreEqual(8, salad.GetPrice()); }
public IIngredient GetSalad() { var _saladDecorator = new SaladDecorator(); _saladDecorator = new SaladDecorator(); _saladDecorator.ChooseSalad(new Batavia()); _saladDecorator.AddTopping(new ChickPeas()); return(_saladDecorator.GetSalad()); }
public void ShouldComplexSalad_Cost13() { _saladDecorator = new SaladDecorator(); _saladDecorator.ChooseSalad(new Iceberg()); _saladDecorator.AddTopping(new ChickPeas()); _saladDecorator.AddTopping(new Avocado()); _saladDecorator.AddTopping(new Chicken()); var salad = _saladDecorator.GetSalad(); Assert.AreEqual(13, salad.GetPrice()); }
public void Pay(IPaymentStrategy strategy) { _orderBuilder.SetSalad(_saladDecorator.GetSalad()); var order = _orderBuilder.Build(); order.Pay(strategy); if (Math.Abs(order.AmountPaid) > 0.000001) { _counter.AssignOrder(order); } else { Console.WriteLine("Payment has failed... try again !"); } }