Esempio n. 1
0
        static void AbstractFactoryPatternTest()
        {
            CreditCardFactory abstractFactory = CreditCardFactory.GetCreditCardFactory(600);
            CreditCard        creditCard      = abstractFactory.GetCreditCard(CardType.GOLD);

            Console.WriteLine(creditCard.GetType());

            abstractFactory = CreditCardFactory.GetCreditCardFactory(700);
            creditCard      = abstractFactory.GetCreditCard(CardType.PLATINUM);
            Console.WriteLine(creditCard.GetType());
        }
        public void TestVersion05()
        {
            CreditCardFactory abstractFactory = CreditCardFactory.GetCreditCardFactory(775);

            CreditCard card = abstractFactory.GetCreditCard(CardType.PLATINUM);

            Debug.WriteLine(card.GetType());

            abstractFactory = CreditCardFactory.GetCreditCardFactory(600);

            CreditCard card2 = abstractFactory.GetCreditCard(CardType.GOLD);

            Debug.WriteLine(card2.GetType());
        }
        public void test_credit_card()
        {
            // MoneyBack card
            {
                CreditCard creditCard = CreditCardFactory.GetCreditCard(CreditCardType.MoneyBack);

                Assert.That(creditCard.GetCardType() == CreditCardType.MoneyBack);
                Assert.That(creditCard.GetAnnualCharge() == 20000);
                Assert.That(creditCard.GetCreditLimit() == 1000);
            }

            // Platium card
            {
                CreditCard creditCard = CreditCardFactory.GetCreditCard(CreditCardType.Platium);

                Assert.That(creditCard.GetCardType() == CreditCardType.Platium);
                Assert.That(creditCard.GetAnnualCharge() == 30000);
                Assert.That(creditCard.GetCreditLimit() == 1500);
            }

            // Titanium card
            {
                CreditCard creditCard = CreditCardFactory.GetCreditCard(CreditCardType.Titanium);

                Assert.That(creditCard.GetCardType() == CreditCardType.Titanium);
                Assert.That(creditCard.GetAnnualCharge() == 35000);
                Assert.That(creditCard.GetCreditLimit() == 2000);
            }
        }
        public override IWallet GetWallet(params ICardType[] cardTypes)
        {
            var wallet = new MockWallet();

            foreach (var cardType in cardTypes)
            {
                var card = CreditCardFactory.GetCreditCard(cardType);
                wallet.CreditCards.Add(card);
            }

            return(wallet);
        }
Esempio n. 5
0
        public void Test2(string cardType)
        {
            var cardDetails = CreditCardFactory.GetCreditCard(cardType);

            if (string.IsNullOrEmpty(cardType))
            {
                Assert.True(cardDetails is null);
            }
            else
            {
                Assert.False(cardDetails is null);
                Assert.Contains(cardType.ToLower(), cardDetails.GetCardType().ToLower());
            }
        }
        static void Main(string[] args)
        {
            CreditCard cardDetails = CreditCardFactory.GetCreditCard("Platinum");

            if (cardDetails != null)
            {
                Console.WriteLine("CardType : " + cardDetails.GetCardType());
                Console.WriteLine("CreditLimit : " + cardDetails.GetCreditLimit());
                Console.WriteLine("AnnualCharge :" + cardDetails.GetAnnualCharge());
            }
            else
            {
                Console.Write("Invalid Card Type");
            }
            Console.ReadLine();
        }
Esempio n. 7
0
        internal static void Call()
        {
            Console.WriteLine("Factory Pattern");

            CreditCard cardDetails = CreditCardFactory.GetCreditCard(CreditCardType.MoneyBack);

            if (cardDetails != null)
            {
                Console.WriteLine("CardType : " + cardDetails.GetCardType());
                Console.WriteLine("CreditLimit : " + cardDetails.GetCreditLimit());
                Console.WriteLine("AnnualCharge :" + cardDetails.GetAnnualCharge());
            }
            else
            {
                Console.Write("Invalid Card Type");
            }
        }