Exemplo n.º 1
0
 public ActionResult Create(BankCollection collection)
 {
     try
     {
         collection.DocumentType = "Bank";
         _bankContext.Create(collection);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public void WithdrawalFromAccount_Calculated()
        {
            // Arrange
            BankContext.Create();
            var     customers        = BankContext.GetCustomers();
            var     account          = customers.FirstOrDefault(m => m.Id == 1)?.Account;
            decimal withdrawalAmount = 100;
            var     result           = account.Balance - withdrawalAmount;

            // Act
            BankRepository.Withdrawal(account.Id, withdrawalAmount);

            //Assert
            Assert.Equal(result, account.Balance);
        }
Exemplo n.º 3
0
        public void DepositToAccount_Calculated()
        {
            // Arrange
            BankContext.Create();
            var     customers     = BankContext.GetCustomers();
            var     account       = customers.FirstOrDefault(m => m.Id == 1)?.Account;
            decimal depositAmount = 100;
            var     result        = account.Balance + depositAmount;

            // Act
            BankRepository.Deposit(account.Id, depositAmount);

            //Assert
            Assert.Equal(result, account.Balance);
        }
        public void WithdrawalFromAccount_NotCalculated()
        {
            // Arrange
            BankContext.Create();
            var     customers = BankContext.GetCustomers();
            var     account   = customers.FirstOrDefault(m => m.Id == 2)?.Account;
            var     balanaceBeforeAttemptWithdrawal = account.Balance;
            decimal withdrawalAmount = 1700;
            var     result           = account.Balance - withdrawalAmount;

            // Act
            BankRepository.Withdrawal(account.Id, withdrawalAmount);

            //Assert
            Assert.NotEqual(result, account.Balance);
            Assert.Equal(balanaceBeforeAttemptWithdrawal, account.Balance);
        }