static void Main(string[] args) { IDuck duck = new MallardDuck(); duck.Fly(); duck.Quack(); Console.WriteLine(); ITurkey turkey = new WildTurkey(); turkey.Fly(); turkey.Gobble(); Console.WriteLine(); IDuck adapterDuck = new TurkeyAdapter(turkey); adapterDuck.Fly(); adapterDuck.Quack(); Console.WriteLine(); ITurkey adapterTurkey = new DuckAdapter(duck); adapterTurkey.Fly(); adapterTurkey.Gobble(); Console.ReadKey(); }
public void TestDuckAdapter() { Duck mallard = new MallardDuck(); Turkey duckAdapter = new DuckAdapter(mallard); Assert.AreEqual("Quack", duckAdapter.Gobble()); Assert.AreEqual("I'm flying", duckAdapter.Fly()); }
public void DuckAdapterTest() { MallardDuck duck = new MallardDuck(); ITurkey duckAdapter = new DuckAdapter(duck); for (int i = 0; i < 10; i++) { Console.WriteLine("The DuckAdapter says..."); duckAdapter.Gobble(); duckAdapter.Fly(); } }