public void TestCreatePhone() { GalaxyMini phone = new GalaxyMini(); AbstractFactory samsung = new SamsungFactory(); Assert.AreSame(phone.GetType(), samsung.createPhone().GetType()); iPhone applephone = new iPhone(); AbstractFactory apple = new AppleFactory(); Assert.AreSame(applephone.GetType(), apple.createPhone().GetType()); Lumia nokiaphone = new Lumia(); AbstractFactory nokia = new NokiaFactory(); Assert.AreSame(nokiaphone.GetType(), nokia.createPhone().GetType()); }
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()); }