Exemplo n.º 1
0
        static void Main(string[] args)
        {
            List <string> accntNumbers = new List <string> {
                "CITI-456",
                "NATIONAL-987",
                "CHASE-222"
            };

            for (int i = 0; i < accntNumbers.Count; i++)
            {
                ICreditUnionFactory anAbstractFactory = CreditUnionFactoryProvider.
                                                        GetCreditUnionFactory(accntNumbers[i]);

                if (anAbstractFactory == null)
                {
                    Console.WriteLine("Sorry, This credit union w/ account number "
                                      + $"{accntNumbers[i]} is invalid.");
                }

                else
                {
                    ILoanAccount    loan    = anAbstractFactory.CreateLoanAccount();
                    ISavingsAccount savings = anAbstractFactory.CreateSavingsAccount();
                }
            }
        }
Exemplo n.º 2
0
        public void CitiSavingsAccount_Balance_Returns1000()
        {
            ICreditUnionFactory abstractFactory = CreditUnionFactoryProvider.GetCreditUnionFactory(AccountType.Citi);

            ISavingsAccount savingsAccount = abstractFactory.CreateSavingsAccount();

            Assert.Equal(1000, savingsAccount.Balance);
        }
Exemplo n.º 3
0
        public void CitiSavingsAccount_Test()
        {
            abstractFactory = CreditUnionFactoryProvider.GetCreditUnionFactory(accounts[0]);
            var savingsAccount = abstractFactory.CreateSavingsAccount();

            var expected = typeof(CitiSavingsAccount);

            Assert.IsType(expected, savingsAccount);
        }
Exemplo n.º 4
0
        public void CheckAllAccounts_ReturnsCorrectBalanceAndInterestRate(AccountType accountType, int balance, int interestRate)
        {
            ICreditUnionFactory abstractFactory = CreditUnionFactoryProvider.GetCreditUnionFactory(accountType);

            ISavingsAccount savingsAccount = abstractFactory.CreateSavingsAccount();
            ILoanAccount    loanAccount    = abstractFactory.CreateLoanAccount();

            Assert.Equal(balance, savingsAccount.Balance);
            Assert.Equal(interestRate, loanAccount.InterestRate);
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            List <string> accounts = new List <string>();

            accounts.Add("CITI-32424");
            accounts.Add("OTHE-61158");
            accounts.Add("NATI-67356");

            foreach (var item in accounts)
            {
                ICreditUnionFactory concreteFactory = FactoryProvider.GetConcreteFactory(item);
                if (concreteFactory != null)
                {
                    concreteFactory.CreateLoanAccount();
                    concreteFactory.CreateSavingsAccount();
                }
                else
                {
                    Console.WriteLine("No known bank.");
                }
            }

            Console.ReadLine();
        }