public void TestBookPaymentStrategy() { //TESTING A NEGATIVE SCENARIO ONCE THE TYPE IS CHANGED TO "BookProductPaymentStrategy" IT WILL WORK IPaymentStatergy paymentStatergy = Program.GetPaymentLogic(producttypeBook); Assert.AreEqual(typeof(PhysicalProductPaymentStrategy), (paymentStatergy).GetType()); }
public static IPaymentStatergy GetPaymentLogic(Product product) { ProductFactory pFactory = null; //This object creation process will be moved to a DI framework(Unity,AutoFac) in futute switch (product.ProductType.ToUpper()) { case "BOOK": pFactory = new BookProductFactory(product); break; case "VIDEO": pFactory = new VideoProductFactory(product); break; case "MEMBERSHIP": pFactory = new MembershipProductFactory(product); break; case "PHYSICAL": pFactory = new MembershipProductFactory(product); break; default: break; } Product productC = pFactory.GetProduct(); Console.WriteLine("\nYour product details are below : \n"); Console.WriteLine("Product Name: {0}\nProductType: {1}\nProductCost: {2}", product.ProductName, product.ProductType, product.ProductCost); IPaymentStatergy paymentStrategy = pFactory.GetPaymentStatergy(); paymentStrategy.ProcessPayment(); return(paymentStrategy); }
public void TestMembershipPaymentStrategy() { IPaymentStatergy paymentStatergy = Program.GetPaymentLogic(producttypeMembership); Assert.AreEqual(typeof(MembershipProductPaymentStrategy), (paymentStatergy).GetType()); }
public void TestVideoPaymentStrategy() { IPaymentStatergy paymentStatergy = Program.GetPaymentLogic(producttypeVideo); Assert.AreEqual(typeof(VideoProductPaymentStrategy), (paymentStatergy).GetType()); }
public void TestPhysicalPaymentStrategy() { IPaymentStatergy paymentStatergy = Program.GetPaymentLogic(producttypePhysical); Assert.AreEqual(typeof(PhysicalProductPaymentStrategy), (paymentStatergy).GetType()); }