예제 #1
0
        [TestCase("66666", "Basic Account", 100, AccountType.Premium, -750, -660, true)]    //(success, overdraft fee)

        public void PremiumAccountWithdrawRuleTests(string accountNumber,
                                                    string name,
                                                    decimal balance,
                                                    AccountType accountType,
                                                    decimal amount,
                                                    decimal newBalance,
                                                    bool expectedResult)
        {
            IWithdraw withdraw = new PremiumAccountWithdrawRule();
            Account   account  = new Account
            {
                AccountNumber = accountNumber,
                Name          = name,
                Balance       = balance,
                Type          = accountType
            };

            AccountWithdrawResponse response = withdraw.Withdraw(account, amount);

            Assert.AreEqual(expectedResult, response.Success);

            if (response.Success == true)
            {
                Assert.AreEqual(newBalance, response.Account.Balance);
            }
        }
        public void PremiumAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal newBalance, bool expectedResult)
        {
            IWithdraw withdrawal      = new PremiumAccountWithdrawRule();
            Account   accountWithdraw = new Account()
            {
                AccountNumber = accountNumber, Type = accountType, Balance = balance
            };
            AccountWithdrawResponse response = withdrawal.Withdraw(accountWithdraw, amount);

            Assert.AreEqual(expectedResult, response.Success);
        }
        [TestCase("55555", "Premium Account", 100, AccountType.Premium, -150, -50, true)] //no overdraft fee
        public void PremiumAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal newBalance, bool expectedResult)
        {
            IWithdraw withdrawRule = new PremiumAccountWithdrawRule();
            Account   account      = new Account();

            account.AccountNumber = accountNumber;
            account.Name          = name;
            account.Balance       = balance;
            account.Type          = accountType;
            AccountWithdrawResponse response = withdrawRule.Withdraw(account, amount);

            Assert.AreEqual(response.Success, expectedResult);
        }
예제 #4
0
        public void PremiumAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal expectedBalance, bool expectedResult)
        {
            IWithdraw withdrawResponse = new PremiumAccountWithdrawRule();

            Account accountVariable = new Account()
            {
                AccountNumber = accountNumber,
                Name          = name,
                Balance       = balance,
                Type          = accountType
            };
            AccountWithdrawResponse accountWithdrawResponse = withdrawResponse.Withdraw(accountVariable, amount);

            Assert.AreEqual(expectedResult, accountWithdrawResponse.Success);
            Assert.AreEqual(expectedBalance, accountWithdrawResponse.Account.Balance);
        }
예제 #5
0
        public void PremiumAccountWithdrawTests(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal newBalance, bool expectedResult)
        {
            IWithdraw premiumWithdraw = new PremiumAccountWithdrawRule();

            Account account = new Account()
            {
                AccountNumber = accountNumber, Name = name, Balance = balance, Type = accountType
            };

            AccountWithdrawResponse result = premiumWithdraw.Withdraw(account, amount);

            var actual  = result.Success;
            var actual2 = account.Balance;

            Assert.AreEqual(expectedResult, actual);
            Assert.AreEqual(newBalance, actual2);
        }
        public void BasicAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal newBalance, bool expectedResult)
        {
            var rule    = new PremiumAccountWithdrawRule();
            var account = new Account()
            {
                AccountNumber = accountNumber,
                Name          = name,
                Balance       = balance,
                Type          = accountType
            };
            var response = rule.Withdraw(account, amount);

            Assert.AreEqual(expectedResult, response.Success);
            if (response.Success)
            {
                Assert.AreEqual(newBalance, response.Account.Balance);
            }
        }
예제 #7
0
        public static void CorrectAmountDepositedWithdrawPremium(string accountNumber)
        {
            //after this files are in arraylist
            FileAccountRepository TestFileRepo =
                new FileAccountRepository("C:/Users/Jeremy/source/repos/SGBank052020/SGBank.Data/AccountsForTestingDeposit.txt");
            Account  a = TestFileRepo.LoadAccount(accountNumber);
            decimal  beginningBalance = a.Balance; //100
            IDeposit deposit          = new NoLimitDepositRule();

            deposit.Deposit(a, 10); //stores new balance in account
            TestFileRepo.SaveAccount(a);
            Assert.AreEqual(a.Balance, 110);

            IWithdraw withdraw = new PremiumAccountWithdrawRule();

            withdraw.Withdraw(a, -10);
            TestFileRepo.SaveAccount(a);
            Assert.AreEqual(a.Balance, 100);
        }
예제 #8
0
        public void BasicAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType, decimal amount, decimal newBalance, bool expectedResult)
        {
            IWithdraw withdraw;

            PremiumAccountWithdrawRule premiumAccountWithdrawRule = new PremiumAccountWithdrawRule();

            withdraw = premiumAccountWithdrawRule;

            Account account = new Account
            {
                Name          = name,
                Balance       = balance,
                AccountNumber = accountNumber,
                Type          = accountType
            };

            AccountWithdrawResponse actualResult = withdraw.Withdraw(account, amount);

            Assert.AreEqual(expectedResult, actualResult.Success);
        }
예제 #9
0
        public void PremiumAccountWithdrawRuleTest(string accountNumber, string name, decimal balance, AccountType accountType,
                                                   decimal amount, decimal newBalence, bool expectedResult)
        {
            Account account = new Account();

            account.AccountNumber = accountNumber;
            account.Name          = name;
            account.Balance       = balance;
            account.Type          = accountType;

            IWithdraw manager = new PremiumAccountWithdrawRule();

            AccountWithdrawResponse response = manager.Withdraw(account, amount);

            Assert.AreEqual(expectedResult, response.Success);
            if (response.Success)
            {
                Assert.AreEqual(newBalence, account.Balance);
            }
        }