static void Main(string[] args) { CreditCard creditCard = new PlatinumFactory().CreateProduct(); if (creditCard != null) { Console.WriteLine("Card Type : " + creditCard.GetCardType()); Console.WriteLine("Credit Limit : " + creditCard.GetCreditLimit()); Console.WriteLine("Annual Charge :" + creditCard.GetAnnualCharge()); } else { Console.Write("Invalid Card Type"); } Console.WriteLine("---------------------------------"); creditCard = new TitaniumFactory().CreateProduct(); if (creditCard != null) { Console.WriteLine("Card Type : " + creditCard.GetCardType()); Console.WriteLine("Credit Limit : " + creditCard.GetCreditLimit()); Console.WriteLine("Annual Charge :" + creditCard.GetAnnualCharge()); } else { Console.Write("Invalid Card Type"); } Console.ReadKey(); }
public void test_credit_card() { // MoneyBack card { ICreditCard creditCard = new MoneyBackFactory().CreateProduct(); Assert.That(creditCard.GetCardType() == CreditCardType.MoneyBack); Assert.That(creditCard.GetAnnualCharge() == 500); Assert.That(creditCard.GetCreditLimit() == 15000); } // Platium card { ICreditCard creditCard = new PlatiumFactory().CreateProduct(); Assert.That(creditCard.GetCardType() == CreditCardType.Platium); Assert.That(creditCard.GetAnnualCharge() == 2000); Assert.That(creditCard.GetCreditLimit() == 35000); } // Titanium card { ICreditCard creditCard = new TitaniumFactory().CreateProduct(); Assert.That(creditCard.GetCardType() == CreditCardType.Titanium); Assert.That(creditCard.GetAnnualCharge() == 1500); Assert.That(creditCard.GetCreditLimit() == 25000); } }