Exemplo n.º 1
0
        private static void ProcessDecision(int number, BankLogic bankLogic)
        {
            switch (number)
            {
            case 1:
                Console.WriteLine("Enter owner");
                var owner = Console.ReadLine();
                bankLogic.CreateAccount(owner);
                break;

            case 2:
                var data = bankLogic.GetAccountData();
                Console.WriteLine(data);
                break;

            case 3:
                Console.WriteLine("Enter amount to deposit");
                var     depositText = Console.ReadLine();
                decimal deposit     = 0;
                if (Decimal.TryParse(depositText, out deposit))
                {
                    bankLogic.DepositAmount(deposit);
                }
                else
                {
                    Console.WriteLine("Not a number");
                }
                break;

            case 4:
                Console.WriteLine("Enter amount to withdrow");
                var     withdrowText = Console.ReadLine();
                decimal withdrow     = 0;
                if (decimal.TryParse(withdrowText, out withdrow))
                {
                    Console.WriteLine(bankLogic.WithrowAmount(withdrow) ? "Success!" : "Failure!");
                }
                else
                {
                    Console.WriteLine("Not a number");
                }
                break;

            case 0:
                Console.WriteLine("Thanks");
                break;

            default:
                Console.WriteLine("Wrong number");
                break;
            }
        }
Exemplo n.º 2
0
        public void DepositAmountAmountShouldBeGreaterThan0()
        {
            //Given (arrange)
            var dataAccessMock = new Mock <IDataAccess>();

            dataAccessMock.Setup(p => p.LoadBankAccount(It.IsAny <int>())).Returns <int>(p => new BankAccount());
            var sut = new BankLogic(dataAccessMock.Object);

            //When (act)
            sut.DepositAmount(0);

            //Then (assert)
        }