Exemplo n.º 1
0
        public void TestCall()
        {
            AbstractFactory samsung = new SamsungFactory();
            IPhone          phone   = samsung.createPhone();
            IPhablet        phablet = samsung.createPhablet();
            SoundPlayer     sp      = new SoundPlayer();

            Assert.AreSame(phone.Call().GetType(), sp.GetType());
            Assert.AreSame(phablet.Call().GetType(), sp.GetType());

            AbstractFactory nokia        = new SamsungFactory();
            IPhone          nokiaphone   = nokia.createPhone();
            IPhablet        nokiaphablet = nokia.createPhablet();

            Assert.AreSame(nokiaphone.Call().GetType(), sp.GetType());
            Assert.AreSame(nokiaphablet.Call().GetType(), sp.GetType());

            AbstractFactory apple        = new SamsungFactory();
            IPhone          applephone   = apple.createPhone();
            IPhablet        applephablet = apple.createPhablet();

            Assert.AreSame(applephone.Call().GetType(), sp.GetType());
            Assert.AreSame(applephablet.Call().GetType(), sp.GetType());
        }