public void GetSavingsAccount_CitiType_ReturnsCitiSavingsAccount()
        {
            ICreditUnionFactory factory     = new SavingsAccountFactory();
            ISavingsAccount     citiAccount = factory.GetSavingsAccount(AccountType.Citi);

            Assert.IsType <CitiSavingsAccount>(citiAccount);
        }
        public void GetSavingsAccount_NationalType_ReturnsCitiSavingsAccount()
        {
            ICreditUnionFactory factory = new SavingsAccountFactory();

            ISavingsAccount nationalAccount = factory.GetSavingsAccount(AccountType.National);

            Assert.IsType <NationalSavingsAccount>(nationalAccount);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            var factory      = new SavingsAccountFactory() as ICreditUnionFactory;
            var citiAcct     = factory.GetSavingsAccount("CITI-321");
            var nationalAcct = factory.GetSavingsAccount("NATIONAL-987");

            Console.WriteLine($"My Citi Balance is {citiAcct.Balance.ToString("C")} " +
                              $"and National Balance is {nationalAcct.Balance.ToString("C")}");
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var factory      = new SavingsAccountFactory() as ICreditUnionFactory;
            var citiAcct     = factory.GetSavingAccount("CITI-321");
            var nationalAcct = factory.GetSavingAccount("NATIONAL-987");

            Console.WriteLine($"My citi balance is ${citiAcct.Balance}" +
                              $" and national balance is ${nationalAcct.Balance}");
        }
        public void NationalSavingsAccount_Balance_Returns2000()
        {
            // Arrange
            ICreditUnionFactory factory = new SavingsAccountFactory();

            // Act
            ISavingsAccount nationalAccount = factory.GetSavingsAccount(AccountType.National);

            // Assert
            Assert.Equal(2000, nationalAccount.Balance);
        }
        public void CitiSavingsAccount_Balance_Returns5000()
        {
            // Arrange
            ICreditUnionFactory factory = new SavingsAccountFactory();

            // Act
            ISavingsAccount citiAccount = factory.GetSavingsAccount(AccountType.Citi);

            // Assert
            Assert.Equal(5000, citiAccount.Balance);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //This pattern is simply about requesting objects that are created behind
            //the scenes and having the correct type of the object returned to you.

            /*Story
             * Suppose two Credit Union merge and they share an API to pull account information
             * from each company that merged, one called CityCreditUnion and other National Credit
             * Union. The api returns an Savings account object depending on the a/c passed in to it
             */
            var factory         = new SavingsAccountFactory() as ICreditUnionFactory;
            var cityAccount     = factory.GetSavingsAccount("CITY-01245");
            var nationalAccount = factory.GetSavingsAccount("NAT-12345");

            Console.WriteLine($"My city balance is {cityAccount.Balance}");
            Console.WriteLine($"My National account balance is {nationalAccount.Balance}");
            Console.ReadLine();
        }