Exemple #1
0
        public override bool Execute(WithdrawInput input)
        {
            try
            {
                _useCase.WithdrawFrom(input.AccountNumber,
                                      input.Amount,
                                      input.Currency);
            }
            catch (AccountNotFoundException)
            {
                System.Console.Error.WriteLine("Failed to withdraw: Account number does not exist as a checking account");
                return(false);
            }
            catch (AuthorisationFailedException)
            {
                System.Console.Error.WriteLine("Failed to withdraw: Authorisation failed");
                return(false);
            }
            catch (InsufficientBalanceException ibx)
            {
                System.Console.Error.WriteLine($"Failed to withdraw: {ibx.Message}");
                return(false);
            }

            return(true);
        }
        public void GivenAccountDoesNotExist_AccountNotFoundExceptionIsThrown()
        {
            Action action = () => _useCase.WithdrawFrom("DOESNTEXIST", 10, "EUR");

            action
            .Should()
            .Throw <AccountNotFoundException>();
        }