Пример #1
0
 /// <summary>
 /// Method to show a list of unverified transactions in the system
 /// </summary>
 /// <returns></returns>
 public ActionResult ViewUnverifiedTransactions()
 {
     try
     {
         List <MobileTransactionsViewModel> model = new List <MobileTransactionsViewModel>();
         foreach (var item in MobileAccountTransactionLog.GetAllUnverifiedMobileAccountTransactions())
         {
             model.Add(new MobileTransactionsViewModel
             {
                 Id              = item.TransactionId,
                 Amount          = item.Amount,
                 DriverName      = item.Driver.FullName.FirstName + " " + item.Driver.FullName.LastName,
                 IsVerified      = item.IsVerified,
                 ReferenceNumber = item.ReferenceNumber,
                 ServiceName     = item.MobileAccountServiceProviderName,
                 Time            = UISupportiveFunctions.GetPassedTimeSpanFromNow(item.TransactionRegisteredTime)
             });
         }
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("ErrorPage", "Error", ex));
     }
 }
        public void GetAllUnverifiedTransactions_Test()
        {
            //arrange

            //act

            //assert
            Assert.IsType <List <MobileAccountTransactionLog> >(MobileAccountTransactionLog.GetAllUnverifiedMobileAccountTransactions());
        }
        public void VerifyTransaction_TestForAlreadyVerified()
        {
            //arrange

            //act
            MobileAccountTransactionLog mobileLog = new MobileAccountTransactionLog(1);

            //assert
            Assert.Throws <NotAuthorizedToChangeValueExeption>(() => mobileLog.IsVerified = true);
        }
Пример #4
0
 public void VerifyTransaction(long id)
 {
     try
     {
         MobileAccountTransactionLog log = new MobileAccountTransactionLog(id);
         log.IsVerified = true;
     }
     catch (Exception)
     {
     }
 }
Пример #5
0
        /// <summary>
        /// Method to be called by using AJAX to getting UI updated
        /// </summary>
        /// <returns></returns>
        public int GetUnverifiedTransactionsCount()
        {
            int i = 0;

            try
            {
                i = MobileAccountTransactionLog.GetAllUnverifiedMobileAccountTransactions().Count;
            }
            catch (Exception)
            {
            }
            return(i);
        }
        public void VerifyTransaction_Test()
        {
            //arrange
            Driver  driver   = new Driver(10007);
            decimal expected = driver.Balance + 570.13m;
            //act
            MobileAccountTransactionLog mobileLog = new MobileAccountTransactionLog(1);

            mobileLog.IsVerified = true;
            decimal actual = driver.Balance;

            //assert
            Assert.True(mobileLog.IsVerified);
            Assert.Equal(expected, actual, 0);
        }
Пример #7
0
        public void MakeMobileTransaction_Test()
        {
            //arrange
            string   expectedRefNumber            = "0000111223312";
            DateTime expectedDateTime             = DateTime.Now;
            string   expectedMobileAccountService = "JazzCash";
            decimal  expectedAmount  = 570.13m;
            Driver   expectedDriver  = new Driver(10007);
            decimal  expectedBalance = 0;
            //act
            MobileAccountTransactionLog actual = expectedDriver.MakeMobileAccountTransaction(expectedRefNumber, expectedMobileAccountService, expectedAmount);

            //assert
            Assert.Equal(expectedRefNumber, actual.ReferenceNumber);
            Assert.Equal(expectedDateTime, actual.TransactionRegisteredTime, TimeSpan.FromMilliseconds(300));
            Assert.Equal(expectedMobileAccountService, actual.MobileAccountServiceProviderName);
            Assert.Equal(expectedAmount, actual.Amount, 2);
            Assert.StrictEqual(expectedDriver, actual.Driver);
            Assert.Equal(expectedBalance, actual.Driver.Balance, 2);
        }