public void TestDepositCurrent()
        {
            CurrentAccount acc = new CurrentAccount(1120002895, Convert.ToDecimal(1000.000000000), "Nmae", DateTime.Now);

            decimal amount = 1000;

            decimal expected = acc.AvailableBalance + amount;

            acc.CreditAccount(amount);

            decimal actual = acc.AvailableBalance;

            Assert.AreEqual(actual, expected);
        }
示例#2
0
        /// <summary>
        /// Creates a New Account and Add the Account to the BankDatabase
        /// </summary>
        /// <returns>The Account Number for the New Account</returns>
        public static long CreateAccount()
        {
            string customerLastName;
            string customerFirstName;
            string customerPhoneNumber;
            string customerEmailAddress;
            string customerHomeAddress;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Yellow;
            UserInterface.DisplayMessageLine("\n\t\t\t\t      ***Account Creation***\n");
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Cyan;
            UserInterface.DisplayMessageLine("\n\t\t\t\t---------Customer Details-------");
            Console.ResetColor();

            Console.ForegroundColor = ConsoleColor.Blue ;
            UserInterface.DisplayMessageLine("\n\t\t\t\t         Enter Last Name       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerLastName = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t        Enter First Name       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerFirstName = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t       Enter Phone Number       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerPhoneNumber = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t      Enter Email Address       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();

            customerEmailAddress = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\n\t\t\t\t      Enter Home Address       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();
            customerHomeAddress = UserInterface.GetInput();

            Console.ForegroundColor = ConsoleColor.Blue;
            UserInterface.DisplayMessageLine("\t\tEnter Account Type, 0 For Savings Account , 1 For Current Account       ");
            UserInterface.DisplayMessage("\n\t\t\t\t\t  ");
            Console.ResetColor();
            int accountType = int.Parse(UserInterface.GetInput());

            long customerNewAccountNumber = GenerateAccountNumber();//Generates A new Account Number For The Customer

            string fullCustomerName = customerLastName +"  " + customerLastName;

            BankDatabase bankdatabase = BankDatabase.GetInstance();

            Account newAccount = null;

               switch(accountType){
               case (int)AccountType.Savings:
                   newAccount = new SavingsAccount(customerNewAccountNumber, Convert.ToDecimal(0.00), fullCustomerName, DateTime.Now);
                   break;
              case (int)AccountType.Current:
                   newAccount = new CurrentAccount(customerNewAccountNumber, Convert.ToDecimal(0.00), fullCustomerName, DateTime.Now);
                   break;

               }

               bankdatabase.AddNewAccount(newAccount);

            Customer newCustomer = new Customer(customerNewAccountNumber, customerLastName, customerFirstName,customerPhoneNumber, customerEmailAddress, customerEmailAddress);
            bankdatabase.AddNewCustomer(newCustomer);

            return customerNewAccountNumber;
        }