Ejemplo n.º 1
0
        public void MoneyIsExchangedBetweenAccounts_WhenUserTransfers()
        {
            int accountFromId = 20;
            int accountToId   = 30;

            decimal balanceFromBefore = accountQueriesHandler.GetAccount(accountFromId).Balance;
            decimal balanceToBefore   = accountQueriesHandler.GetAccount(accountToId).Balance;
            decimal transferAmount    = 100;

            accountCommandHandler.Transfer(accountFromId, accountToId, transferAmount);

            decimal balanceFromAfter = accountQueriesHandler.GetAccount(accountFromId).Balance;
            decimal balanceToAfter   = accountQueriesHandler.GetAccount(accountToId).Balance;

            Assert.Less(balanceFromAfter, balanceFromBefore);
            Assert.Greater(balanceToAfter, balanceToBefore);
        }
Ejemplo n.º 2
0
        public IActionResult Transfer(int accountFromId, int accountToId, decimal amount)
        {
            if (ModelState.IsValid)
            {
                int result = accountHandler.Transfer(accountFromId, accountToId, amount);

                if (result == 1)
                {
                    TempData["success"] = "Transfer executed successfully.";

                    return(View());
                }
            }

            TempData["error"] = "Transfer was unsuccessful. Please check that amount and account Id are correct.";


            return(View());
        }