Esempio n. 1
0
        public void ShouldThrowIfWithdrawOverCurrentBalance()
        {
            double balance = 400;
            Atm    atm     = new Atm(balance);

            Assert.Throws <Exception>(() => atm.WithdrawMoney(500));
        }
Esempio n. 2
0
        public void ShouldWithdraw()
        {
            double balance         = 1000;
            double expectedBalance = 500;
            Atm    atm             = new Atm(balance);

            atm.WithdrawMoney(500);

            Assert.Equal(expectedBalance, atm.ViewBalance());
        }
Esempio n. 3
0
        public static void WithdrawMoney()
        {
            bool loop = true;

            while (loop)
            {
                Console.WriteLine("Please enter the amount you want to withdraw");
                try
                {
                    double amount = double.Parse(Console.ReadLine());
                    atm.WithdrawMoney(amount);
                    loop = false;
                }
                catch
                {
                    Console.WriteLine("Please enter a valid amount");
                }
                finally
                {
                    Console.WriteLine("Your Current Balance is " + atm.ViewBalance());
                }
            }
        }