示例#1
0
        public void test_coffee()
        {
            {
                ICoffee coffee = new Espresso();

                Chocolate decoratorChocolate = new Chocolate(coffee);
                decoratorChocolate.AddCondiment();

                Assert.That(coffee.GetPrice() == 3.98);

                Milk decoratorMilk = new Milk(coffee);
                decoratorMilk.AddCondiment();

                Assert.That(coffee.GetPrice() == 5.97);
            }

            {
                ICoffee coffee = new Espresso();

                Chocolate decoratorChocolate = new Chocolate(coffee);
                decoratorChocolate.AddCondiment();

                Milk decoratorMilk = new Milk(decoratorChocolate);
                decoratorMilk.AddCondiment();

                Assert.That(coffee.GetPrice() == 5.97);
            }
        }