Example #1
0
 public void ApproveWithdrawal()
 {
     try
     {
         var options = CreateNewContextOptions();
         WithdrawalApplication item;
         using (var db = new EntireMoneyProcessingContext(options))
         {
             ProcessingTestHelper.PopulateDefaultMoneyCtx(db);
             var acc = db.UsersAccount.First();
             acc.CurrentMoney = 1000;
             db.SaveChanges();
         }
         using (var db = new EntireMoneyProcessingContext(options))
         {
             var repository = new WithdrawalProcessing(db);
             item = db.WithdrawalApplications.First();
             Assert.DoesNotThrow(() => repository.ApproveWithdrawal(item));
             Assert.True(item != null && item.IsApproved);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex.Message, ex);
         throw;
     }
 }
Example #2
0
 public bool CreateApplication(string withdrawalMethodCode, string userName)
 {
     try
     {
         var              options = CreateNewContextOptions();
         User             user;
         WithdrawalMethod withdrawalMethod;
         using (var db = new EntireMoneyProcessingContext(options))
         {
             ProcessingTestHelper.PopulateDefaultMoneyCtx(db);
         }
         WithdrawalApplication result = null;
         using (var db = new EntireMoneyProcessingContext(options))
         {
             var repository = new WithdrawalProcessing(db);
             user             = db.Set <User>().First(it => it.UserName == userName);
             withdrawalMethod = db.Set <WithdrawalMethod>().First(it => it.Code == withdrawalMethodCode);
             Assert.DoesNotThrow(() => result = repository.CreateApplication(ProcessingTestHelper.GenerateWithdrawalApplication(user, withdrawalMethod)));
             return(result != null && result.Id > 0);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex.Message, ex);
         throw;
     }
 }
Example #3
0
 public void GetApplications(DbContextOptions <EntireMoneyProcessingContext> options, WithdrawalApplicationFilter <int, int?> filter, int expectedCount)
 {
     try
     {
         IEnumerable <WithdrawalApplication> result = null;
         using (var db = new EntireMoneyProcessingContext(options))
         {
             var repository = new WithdrawalProcessing(db);
             Assert.DoesNotThrow(
                 () => result =
                     repository.GetApplications(filter));
             Assert.True(result != null && result.Count() == expectedCount);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex.Message, ex);
         throw;
     }
 }
Example #4
0
 public void CreateApplication2(DbContextOptions <EntireMoneyProcessingContext> options, TestComplexObject obj)
 {
     try
     {
         WithdrawalApplication result = null;
         using (var db = new EntireMoneyProcessingContext(options))
         {
             var repository = new WithdrawalProcessing(db);
             Assert.DoesNotThrow(
                 () =>
                 result =
                     repository.CreateApplication(obj.WithdrawalMethod, obj.User, obj.WithdrawalBefore, obj.Amount, obj.Comment));
             Assert.True(result != null && result.Id > 0);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex.Message, ex);
         throw;
     }
 }
Example #5
0
 public void GetById()
 {
     try
     {
         var options = CreateNewContextOptions();
         using (var db = new EntireMoneyProcessingContext(options))
         {
             ProcessingTestHelper.PopulateDefaultMoneyCtx(db);
         }
         WithdrawalApplication result = null;
         using (var db = new EntireMoneyProcessingContext(options))
         {
             var repository = new WithdrawalProcessing(db);
             Assert.DoesNotThrow(() => result = repository.GetById(db.WithdrawalApplications.First().Id));
             Assert.True(result != null && result.Id > 0);
         }
     }
     catch (Exception ex)
     {
         LogEventManager.Logger.Error(ex.Message, ex);
         throw;
     }
 }