public void DecoratorTest() { IOrderable pizza = new Margerita(); IOrderable ham = new Ham(pizza); IOrderable kebab = new Kebab(ham); IOrderable onion = new Onion(kebab); var expectedPizza = $"Margerita{Environment.NewLine} with ham{Environment.NewLine} with kebab{Environment.NewLine} with onion"; var expectedPrice = 125; var actualPizza = onion.GetName(); var actualPrice = onion.GetPrice(); Assert.AreEqual(expectedPizza, actualPizza); Assert.IsTrue(expectedPrice == actualPrice); }
private static void DecoratorDosa() { IDosa plainDosa = new PlainDosa(); //Console.WriteLine("Description : {0} - Price {1}", plainDosa.GetDescription(), plainDosa.GetPrice()); Ghee ghee = new Ghee(plainDosa); Onion onion = new Onion(ghee); Console.WriteLine("Description : {0} - Total Price : Rs. {1}", onion.GetDescription(), onion.GetPrice()); Powder powder = new Powder(onion); Console.WriteLine("Description : {0} - Total Price : Rs. {1}", powder.GetDescription(), powder.GetPrice()); }