public void DuckAdapterTest()
        {
            IDuck duck = new MallardDuck();
            DuckAdapter duckAdapter = new DuckAdapter(duck);

            Assert.AreEqual("Quack! Quack!", duckAdapter.Gobble());
        }
예제 #2
0
        public static void Main(string[] args)
        {
            IDuck mallardDuck = new MallardDuck();
            ITurkey wildTurkey = new WildTurkey();

            DuckAdapter duckAdapter = new DuckAdapter(mallardDuck);
            TurkeyAdapter turkeyAdapter = new TurkeyAdapter(wildTurkey);

            Console.WriteLine("-------Duck------------");
            DuckClient(mallardDuck);
            Console.WriteLine("-------Turkey----------");
            TurkeyClient(wildTurkey);
            Console.WriteLine("-------Duck Adapter----");
            TurkeyClient(duckAdapter);
            Console.WriteLine("-------Turkey Adapter--");
            DuckClient(turkeyAdapter);
            Console.ReadLine();
        }