コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: kbussert/Visual_Studio
        public void DecafWithMochaPriceTest()
        {
            //Arrange
            Beverage bev = new Decaf();

            bev = new SteamedMilk(bev);
            decimal price;

            //Act
            price = bev.GetPrice();
            //Assert
            Assert.AreEqual(price, 1.15m);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** Decorator Pattern ***");

            Beverage beverage = new SteamedMilk(
                new Whip(
                    new Whip(
                        new Espresso())));

            Console.WriteLine(beverage.Description + " $" + beverage.Cost);

            Beverage beverage1 = new HouseBlend();

            beverage1 = new Mocha(beverage1);
            beverage1 = new Soy(beverage1);

            Console.WriteLine(beverage1.Description + " $" + beverage1.Cost);

            Console.ReadLine();
        }