예제 #1
0
        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);
        }
예제 #2
0
        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());
        }