public void PayerRepositoryGetCorrectPayer()
        {
            var payerRepository = new PayerRepository(TEST_FB_DB_URL, TEST_FB_DB_PATH, Config.RemoteDbUser, Config.RemoteDbPassword);
            var correctPayer    = payerRepository.Get(21101);

            Assert.IsNotNull(correctPayer, "Player was not received");

            int      expectedAddressLength    = 32;
            decimal  expectedBalance          = 0;
            double   expecedDayValue          = 10113;
            double   expectedNightValue       = 0;
            string   expectedCounterName      = "жн-6807Я (5)";
            DateTime expectedCounterCheckDate = new DateTime(2008, 3, 1);
            DateTime expectedCounterMountDate = new DateTime(2009, 4, 7);

            Assert.IsTrue(correctPayer.Address.Length == expectedAddressLength,
                          $"Address is incorrect: length actual {correctPayer.Address.Length}; lenght expected {expectedAddressLength}");
            Assert.IsTrue(correctPayer.Balance == expectedBalance,
                          $"Balance is incorrect: actual {correctPayer.Balance}; expected {expectedBalance}");
            Assert.IsTrue(correctPayer.DayValue == expecedDayValue,
                          $"Day value is incorrect: actual {correctPayer.DayValue}; expected {expecedDayValue}");
            Assert.IsTrue(correctPayer.NightValue == expectedNightValue,
                          $"Night value is incorrect: actual {correctPayer.NightValue}; expected {expectedNightValue}");
            Assert.IsTrue(correctPayer.CounterName == expectedCounterName,
                          $"Counter name is incorrect: actual '{correctPayer.CounterName}'; expected '{expectedCounterName}'");
            Assert.IsTrue(correctPayer.CounterCheckDate == expectedCounterCheckDate,
                          $"Counter check date is incorrect: actual '{correctPayer.CounterCheckDate.ToString("dd.MM.yyyy")}'; expected '{expectedCounterCheckDate.ToString("dd.MM.yyyy")}'");
            Assert.IsTrue(correctPayer.CounterMountDate == expectedCounterMountDate,
                          $"Counter mount date is incorrect: actual '{correctPayer.CounterMountDate.ToString("dd.MM.yyyy")}'; expected '{expectedCounterMountDate.ToString("dd.MM.yyyy")}'");
        }
示例#2
0
 public void Setup()
 {
     Repo = new PayerRepository(DataAccess)
     {
         User = SystemOperator.SysOperator
     };
 }
示例#3
0
 /// <summary>
 /// 新增「繳款人」-初始資料
 /// </summary>
 /// <param name="db"></param>
 public static void CreatePayer(SysMessageLog Message, ApplicationDbContext dataAccess)
 {
     try
     {
         Message.Prefix             = "新增「繳款人」-初始資料:";
         using PayerRepository repo = new PayerRepository(dataAccess)
               {
                   User = SystemOperator.SysOperator, Message = Message
               };
         List <PayerSet> payers = new List <PayerSet>()
         {
             new PayerSet()
             {
                 Payer = new PayerModel()
                 {
                     CustomerCode = "992086", PayerId = "1", PayerName = "測試繳款人1", PayerType = PayerType.Normal, PayerNo = "8462"
                 }
             },
             new PayerSet()
             {
                 Payer = new PayerModel()
                 {
                     CustomerCode = "2143", PayerId = "1", PayerName = "測試繳款人2", PayerType = PayerType.Normal, PayerNo = "183729"
                 }
             },
             new PayerSet()
             {
                 Payer = new PayerModel()
                 {
                     CustomerCode = "805", PayerId = "1", PayerName = "測試繳款人3", PayerType = PayerType.Normal, PayerNo = "729183"
                 }
             },
             new PayerSet()
             {
                 Payer = new PayerModel()
                 {
                     CustomerCode = "993586", PayerId = "1", PayerName = "測試繳款人4", PayerType = PayerType.Normal, PayerNo = "76194"
                 }
             },
         };
         payers.ForEach(payer =>
         {
             if (null == repo.QueryData(new[] { payer.Payer.CustomerCode, payer.Payer.PayerId }))
             {
                 repo.Create(payer);
             }
         });
         repo.CommitData(FuncAction.Create);
     }
     finally
     {
         Message.Prefix = string.Empty;
     }
 }
        public void PayerRepositoryIncorrectCredentials()
        {
            var payerRepository = new PayerRepository(TEST_FB_DB_URL, TEST_FB_DB_PATH, string.Empty, string.Empty);

            try
            {
                var payer = payerRepository.Get(123);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is FbException, "Get payer from unautorise repository was not thrown exception");
            }
        }
        public void PayerRepositoryIncorrectLocation()
        {
            PayerRepository payerRepository = null;

            try
            {
                payerRepository = new PayerRepository(string.Empty, string.Empty, Config.RemoteDbUser, Config.RemoteDbPassword);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is ArgumentException, "Exception was not thrown after pass incorrect arguments");
            }

            Assert.IsNull(payerRepository, "Payer repository is't NULL after exception");
        }
        public void PayerRepositoryNullInit()
        {
            PayerRepository payerRepository = null;

            try
            {
                payerRepository = new PayerRepository(null, null, null, null);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex is ArgumentException, "Exception was not thrown after pass incorrect arguments");
            }

            Assert.IsNull(payerRepository, "Payer repository is't NULL after exception");
        }