コード例 #1
0
        private List <string> GetWithdrawOutput(string command)
        {
            var           amount        = 0;
            List <string> commandResult = new List <string>();

            if (int.TryParse(command, out amount))
            {
                if (amount == 0)
                {
                    commandResult.Add($"Cannot withdraw {amount}");
                    return(commandResult);
                }
                if (_atmService.Withdraw(amount))
                {
                    commandResult.Add($"Success: Dispensed ${amount}");
                    commandResult.AddRange(_atmService.BuildBalanceOutput());
                }
                else
                {
                    commandResult.Add("Failure: Insufficient funds");
                }
            }
            else
            {
                commandResult.Add("Failure: Invalid Command");
            }
            return(commandResult);
        }
コード例 #2
0
        public void Withdraw_Failure_Insufficient(int amount)
        {
            var atmService = new AtmService();

            Assert.True(atmService.Withdraw(amount));
        }
コード例 #3
0
        public void Withdraw_Success(int amount)
        {
            var atmService = new AtmService();

            Assert.True(atmService.Withdraw(amount));
        }