Пример #1
0
        private string TransferAmount(BankTransaction trans)
        {
            BankAccount sourceAcct = _lib.GetBankAccountByAccountNumber(trans.SourceAccountNumber);
            BankAccount targetAcct = _lib.GetBankAccountByAccountNumber(trans.TargetAccountNumber);

            if (sourceAcct != null && targetAcct != null && trans.TransactionAmount < 0)
            {
                return("Transaction Amount cannot be negative or less than zero");
            }
            else if (sourceAcct != null && targetAcct != null && sourceAcct.Balance > trans.TransactionAmount)
            {
                //sourceAcct.Balance = sourceAcct.Balance - trans.TransactionAmount;

                //targetAcct.Balance = targetAcct.Balance + trans.TransactionAmount;

                _lib.UpdateBankAccount(sourceAcct, targetAcct, trans.TransactionType, trans.TransactionAmount);
            }
            else if (sourceAcct != null && targetAcct != null && sourceAcct.Balance < trans.TransactionAmount)
            {
                return("Transaction Amount must be less than Balance Amount.");
            }
            else if (sourceAcct != null && targetAcct == null)
            {
                return("Target Account Number does not exist.");
            }
            else if (sourceAcct == null && targetAcct != null)
            {
                return("Source Account Number does not exists.");
            }

            return("Bank Transaction Successfull");
        }
        public void TestGetBankAccountByAccountNumber()
        {
            string expectedAccountNumber = "20191000500201";
            string expectedLoginName     = "testme";

            BankAccount acct = _dataLib.GetBankAccountByAccountNumber(expectedAccountNumber);

            Assert.IsNotNull(acct);
            Assert.AreEqual(expectedLoginName, acct.LoginName);
            Assert.AreEqual(expectedAccountNumber, acct.AccountNumber);
        }