Ejemplo n.º 1
0
        public void CreateTransaction()
        {
            KISSBankingPresenter KISSPresenter = new KISSBankingPresenter(this);
            string user = RandomString(5);

            AddUser(user);
            var loginTest = LoginEventRaised.Invoke(user, "testPass");

            loginTest.Wait();
            var tranaction = TransactionEventRaised.Invoke(new Transaction
            {
                Amount          = new Money(1000),
                TransactionType = Transaction.Type.DEPOSIT,
                UserId          = 0
            });

            tranaction.Wait();
            Assert.AreEqual(tranaction.Result, true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles new transactions
        /// </summary>
        private void MakeTransaction()
        {
            const int WITHDRAW = 1;
            const int DEPOSIT  = 2;

            Transaction newTransaction = new Transaction();
            int         selection;
            decimal     transferAmount;
            bool        bValidDecimal = true;
            List <int>  rules         = new List <int> {
                WITHDRAW, DEPOSIT
            };

            Console.Clear();
            AccountView.AccountAmount(mcAccount.mcAccountBalance.mBalance.ToString());

            selection = ConsoleHelper.ValidateSelection(AccountView.TransactionTypeMenu, rules);

            if (selection == WITHDRAW)
            {
                newTransaction.TransactionType = Transaction.Type.WITHDRAW;
            }
            else
            {
                newTransaction.TransactionType = Transaction.Type.DEPOSIT;
            }

            do
            {
                Console.Clear();
                if (!bValidDecimal)
                {
                    ConsoleHelper.ConsoleWriteColor(ConsoleColor.Red, "Invalid Amount, must be a decimal number", true);
                }
                AccountView.TransactionAmount();
            } while (!(bValidDecimal = decimal.TryParse(Console.ReadLine(), out transferAmount)));

            newTransaction.Amount = new Money(transferAmount);
            Task.Run(() => TransactionEventRaised.Invoke(newTransaction)).Wait();
        }