public void IsSmartphoneDetailsCorrect() { Mock <ILogger> mock = new Mock <ILogger>(); var logger = mock.Object; ISmartphoneFactory appleFactory = SmartphoneProducer.GetSmartphoneFactory( SmartphoneFactoryType.AppleFactory, logger); var phone = appleFactory.Create("8", 4.7, "IOS", 12, "gray", 700); var message = phone.GetPhoneDetails(); logger.PrintLog(message); mock.Verify(log => log.PrintLog(It.IsAny <string>())); var expected1 = "8"; var expected2 = 4.7; var expected3 = "IOS"; var expected4 = 12; var expected5 = "gray"; var expected6 = 700; Assert.AreEqual(expected1, phone.Model); Assert.AreEqual(expected2, phone.Display); Assert.AreEqual(expected3, phone.Platform); Assert.AreEqual(expected4, phone.Camera); Assert.AreEqual(expected5, phone.Color); Assert.AreEqual(expected6, phone.Price); }
private static void CreateAllSmartphones(ISmartphoneFactory smartphoneFactory) { var lowCostSmartphone = smartphoneFactory.CreateLowCost(); PrintSmartphoneInfo(lowCostSmartphone); var hypedSmartphone = smartphoneFactory.CreateHyped(); PrintSmartphoneInfo(hypedSmartphone); var luxuriousSmartphone = smartphoneFactory.CreateLuxurious(); PrintSmartphoneInfo(luxuriousSmartphone); }
public void IsSmartphoneTypeCorrect() { Mock <ILogger> mock = new Mock <ILogger>(); var logger = mock.Object; ISmartphoneFactory appleFactory = SmartphoneProducer.GetSmartphoneFactory( SmartphoneFactoryType.AppleFactory, logger); var phone = appleFactory.Create("8", 4.7, "IOS", 12, "gray", 700); var message = phone.GetPhoneDetails(); logger.PrintLog(message); mock.Verify(log => log.PrintLog(It.IsAny <string>())); Assert.That(phone, Is.InstanceOf <Smartphone>()); }
public static ISmartphoneFactory GetSmartphoneFactory(SmartphoneFactoryType type, ILogger logger) { ISmartphoneFactory factory = null; switch (type) { case SmartphoneFactoryType.AppleFactory: factory = new AppleFactory(logger); break; case SmartphoneFactoryType.SamsungFactory: factory = new SamsungFactory(logger); break; case SmartphoneFactoryType.XiaomiFactory: factory = new XiaomiFactory(logger); break; default: break; } return(factory); }