Ejemplo n.º 1
0
        public void ATMMachine_IfWitdrawalIsMoreThanATMHolds_ShouldReturnExpectedErrorCode(decimal openingBalance, Int32 accountNumber)
        {
            ATMMachine cashpoint = new ATMMachine(openingBalance);
            CustomerAccount customerAccount = new CustomerAccount(100m, accountNumber, 1234, 100);
            var amountToWithdraw = openingBalance + 1;
            decimal customerBalance;
            ATMResponse result = cashpoint.WithdrawFunds(amountToWithdraw, customerAccount, 1234, out customerBalance);

            Assert.That(result, Is.EqualTo(ATMResponse.ATM_ERR));
            //also check that the opening balance is still the same ie no money has been removed
            Assert.That(cashpoint.MachineBalance, Is.EqualTo(openingBalance));
        }
Ejemplo n.º 2
0
        public void ATMMachine_WhenPinNumberIncorrect_ShouldReturndExpectedAccountErrorCode(decimal machineBalance,
            Int32 accountNumber,
            decimal accountBalance,
            decimal overDraft,
            Int32 realPinNumber,
            Int32 testPinNumber)
        {
            var cashPoint = new ATMMachine(machineBalance);
            var account = new CustomerAccount(accountBalance, accountNumber, realPinNumber, overDraft);

            decimal actualBalance;
            ATMResponse result = cashPoint.GetAccountBalance(account, testPinNumber, out actualBalance);

            Assert.That(result, Is.EqualTo(ATMResponse.ACCOUNT_ERR));
        }
Ejemplo n.º 3
0
        public void ATMMachine_WhenUserTriesToWithdrawMoreThantheirAccountTotal_ReturnsFundsError(decimal machineBalance,
            Int32 accountNumber,
            decimal initialAccountBalance,
            decimal overDraft,
            Int32 pinNumber)
        {
            var cashPoint = new ATMMachine(machineBalance);
            var account = new CustomerAccount(initialAccountBalance, accountNumber, pinNumber, overDraft);
            decimal excessiveWithdrawalAmount = initialAccountBalance + overDraft + 1;

            decimal customerBalance;
            ATMResponse result = cashPoint.WithdrawFunds(excessiveWithdrawalAmount, account, pinNumber, out customerBalance);

            Assert.That(result, Is.EqualTo(ATMResponse.FUNDS_ERR));
            Assert.That(account.GetWithdrawalBalance(), Is.EqualTo(initialAccountBalance + overDraft));
        }
Ejemplo n.º 4
0
        public void ATMMachine_TestData_ProducesExpectedOutcome(Int32 accountNumber,
            decimal initialAccountBalance,
            decimal overDraft,
            Int32 pinNumber,
            decimal withdrawalAmount)
        {
            var cashPoint = new ATMMachine(8000m);
            var customerAccount = new CustomerAccount(initialAccountBalance, accountNumber, pinNumber, overDraft);

            decimal customerBalance;
            ATMResponse balanceResponse = cashPoint.GetAccountBalance(customerAccount, pinNumber, out customerBalance);

            Assert.That(customerBalance, Is.EqualTo(initialAccountBalance));
            Console.WriteLine(string.Format("InitialBalance: {0}", customerBalance));
            Console.WriteLine(String.Format("ResultCode {0}", balanceResponse));

            ATMResponse withdrawalResponse = cashPoint.WithdrawFunds(withdrawalAmount, customerAccount, pinNumber,out customerBalance);
            Console.WriteLine(String.Format("Withdrawawl Amount: {0}", withdrawalAmount));
            Console.WriteLine(String.Format("Balance AfterWithdrawal {0}", customerBalance));
            Console.WriteLine(String.Format("ResultCode: {0}", withdrawalResponse));
        }