Example #1
0
        public void WithdrawWithBalancePositive()
        {
            var depositValue  = 50.5m;
            var withdrawValue = 10.2m;

            var expectedBalance = depositValue - withdrawValue;

            var hardwareMock = new HardwareMock(number, depositValue, withdrawValue);
            var serviceMock  = new RemoteServiceMock(account);

            var cashMachine = new cashMachine.CashMachine(hardwareMock, serviceMock);

            cashMachine.Login();
            cashMachine.Deposit();

            var result = cashMachine.Withdraw();

            var balance = cashMachine.AccountBalance();

            hardwareMock.VerifyCalledMethod(HardwareMock.MethodGetValueToWithdraw, null, withdrawValue);
            serviceMock.VerifyCalledMethod(RemoteServiceMock.MethodPersitAccount, new object[] { account }, null, 2);

            Assert.AreEqual(string.Format(CourseraTDD.CashMachine.CashMachine.SuccessBalanceMessage, expectedBalance), balance);
            Assert.AreEqual(CourseraTDD.CashMachine.CashMachine.SuccessWithdrawMessage, result);
        }
Example #2
0
        public void LoginWithAccountNumberInvalid()
        {
            var hardwareMock = new HardwareMock(number);
            var serviceMock  = new RemoteServiceMock(account, RemoteServiceMock.Error.FindAccountNotExists);

            var cashMachine = new cashMachine.CashMachine(hardwareMock, serviceMock);
            var result      = cashMachine.Login();

            hardwareMock.VerifyCalledMethod(HardwareMock.MethodGetCardNumber, null, number);
            serviceMock.VerifyCalledMethod(RemoteServiceMock.MethodFindAccount, new object[] { number });

            Assert.AreEqual(CourseraTDD.CashMachine.CashMachine.InvalidLoginMessage, result);
        }
Example #3
0
        public void LoginWithAccountNumberValid()
        {
            var hardwareMock = new HardwareMock(number);
            var serviceMock  = new RemoteServiceMock(account);

            var machine = new cashMachine.CashMachine(hardwareMock, serviceMock);

            var result = machine.Login();

            hardwareMock.VerifyCalledMethod(HardwareMock.MethodGetCardNumber, null, number);
            serviceMock.VerifyCalledMethod(RemoteServiceMock.MethodFindAccount, new object[] { number }, account);

            Assert.AreEqual(cashMachine.CashMachine.SuccessLoginMessage, result);
        }
Example #4
0
        public void DepositAuthenticated()
        {
            var valueToDeposit = 100.5m;

            var hardwareMock = new HardwareMock(number, valueToDeposit);
            var serviceMock  = new RemoteServiceMock(account);

            var cashMachine = new cashMachine.CashMachine(hardwareMock, serviceMock);

            cashMachine.Login();

            var result = cashMachine.Deposit();

            hardwareMock.VerifyCalledMethod(HardwareMock.MethodGetValueToDeposit, null, valueToDeposit);
            serviceMock.VerifyCalledMethod(RemoteServiceMock.MethodPersitAccount, new object[] { account });

            Assert.AreEqual(CourseraTDD.CashMachine.CashMachine.SuccessDepositMessage, result);
        }