Ejemplo n.º 1
0
        public void Withdraw_GivenInvalidAmount_ShouldThrowException()
        {
            // Arrange
            double startingBalance   = 10000;
            double exceedingAmount   = 12000;
            double negativeAmount    = -100;
            var    investmentAccount = new InvestmentAccount(owner: "Mike Schwartz",
                                                             balance: startingBalance);

            // Act, Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => investmentAccount.Withdraw(negativeAmount));
            Assert.Throws <ArgumentOutOfRangeException>(() => investmentAccount.Withdraw(exceedingAmount));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var savingsAccount = new SavingsAccount(owner: "Joe Decker",
                                                    balance: 200);

            savingsAccount.ShowAccountDetails();
            savingsAccount.Withdraw(20);
            savingsAccount.CheckRemainingBalance();
            savingsAccount.Deposit(100);
            savingsAccount.CheckRemainingBalance();

            var loanAccount = new LoanAccount(owner: "John Wright",
                                              balance: -1200);

            loanAccount.ShowAccountDetails();
            loanAccount.Deposit(200);
            loanAccount.CheckRemainingBalance();

            var investmentAccount = new InvestmentAccount(owner: "Mike Schwartz",
                                                          balance: 10000);

            investmentAccount.ShowAccountDetails();
            investmentAccount.Withdraw(2000);
            investmentAccount.CheckRemainingBalance();
            investmentAccount.Deposit(1200);
            investmentAccount.CheckRemainingBalance();
        }
Ejemplo n.º 3
0
        public void WithdrawWithValidAmountInvestment()
        {
            float initialBalance = 200;
            float withdrawAmount = 50;
            float expected       = 150;

            Customer          customer          = new Customer(4, "Allen", "02222222");
            InvestmentAccount investmentAccount = new InvestmentAccount(customer, 5, initialBalance, 5, 20);

            float actual = investmentAccount.Withdraw(withdrawAmount);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 4
0
        public void Withdraw_GivenValidAmount_ShouldUpdateBalance()
        {
            // Arrange
            double startingBalance   = 10000;
            double withdrawalAmount  = 2000;
            double expected          = startingBalance - (withdrawalAmount + (withdrawalAmount * InvestmentAccount.MANAGEMENT_FEE));
            var    investmentAccount = new InvestmentAccount(owner: "Mike Schwartz",
                                                             balance: startingBalance);

            // Act
            investmentAccount.Withdraw(withdrawalAmount);

            // Assert
            double actual = investmentAccount.Balance;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
        public void WithdrawWithLessThanZeroInvestment()
        {
            float initialBalance = 200;
            float withdrawAmount = -10;

            Customer          customer          = new Customer(4, "Allen", "02222222");
            InvestmentAccount investmentAccount = new InvestmentAccount(customer, 5, initialBalance, 5, 20);

            try
            {
                investmentAccount.Withdraw(withdrawAmount);
            }
            catch (ArgumentOutOfRangeException)
            {
                return;
            }
            Assert.Fail();
        }