示例#1
0
        public async Task VerifyBillingAccountForConvertedTrialPolicy(int ownerId, IEnrollmentParameters iiep, bool bExist = true)
        {
            // get trudat owner
            ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
            // verify billing account existing
            accounts = await VerifyBillingAccountExist(ownerCollection.OwnerInformation.UniqueId.ToString(), bExist);

            // verify pet enrollment status
            bool b = await verifyOwnerPetEnrollmentStatus(ownerId, iiep.Pets.First().PetName);

            if (bExist)
            {
                Account account = accounts.First();
                Assert.IsTrue(account.AutoPay == accountExpected.AutoPay, $"auto pay- {account.AutoPay} is not as expected - {accountExpected.AutoPay}");           // verify auto pay
                //Assert.IsTrue(account.Currency.Equals(accountExpected.Currency), $"currency- {account.Currency} is as not expected - {accountExpected.Currency}");  // verify currency
                // TODO: billcycleday was not set correctly in convert
                //Assert.IsTrue(account.BillCycleDay.Equals(iiep.BillingParams.BillingDayOfMonth), $"bill cycle day- {account.BillCycleDay} is as not expected - {iiep.BillingParams.BillingDayOfMonth}");                  // verify currency
                iep = testDataManager.ConvertEnrollmentParametersFromIEnrollmentParameters(iiep);
                QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);

                InvoiceWithItems iNext = await VerifyAccountPremium(account.Id, iep, quote);                                                                        // verify premium
            }
            else
            {
                Assert.IsTrue(accounts.Count == 0, $"account shouldn't exist");                                                                                     // verify auto pay
            }
        }
示例#2
0
        //[TestMethod]
        public async Task CreateQuote()
        {
            EnrollmentParameters iep   = testDataManager.GenerateOwnerPetTestData(numPets: 1);       // get test data
            QaLibQuoteResponse   quote = await qaLibRestClient.CreateQuote(iep);

            Assert.IsNotNull(quote, "");
        }
示例#3
0
        public async Task USEnrollmentOnePetWithTwoRiderBank()
        {
            iep = testDataManager.GenerateOwnerPetTestData(numPets: 1, riderNumber: 2);                     // get test data
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                              // get quote

            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);                       // enroll with service standard enroll
            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);          // verify billing account
        }
        public async Task CAEnrollmentTwoPetsBank()
        {
            iep = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 2, riderNumber: random.Next(1, 2));      // get test data
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                                                  // get quote

            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);                                           // enroll with service standard enroll
            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);                              // verify billing account
        }
示例#5
0
        public async Task USEnrollmentOnePetWithBankSavingAccount()
        {
            iep = testDataManager.GenerateOwnerPetTestData(numPets: 1, riderNumber: random.Next(0, 2));     // get test data
            iep.BillingParams.BankAccountAccountType = BankAccountType.Saving;
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                              // get quote

            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);                       // enroll with service standard enroll
            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);          // verify billing account
        }
        public async Task USTrialEnrollmentOnePet()
        {
            iep = testDataManager.GenerateOwnerPetTestData(numPets: 1);                                     // test data for trial
            iep.EnrollmentTypeVal = EnrollmentType.IssueCertificate;                                        // making it a trial
            QaLibQuoteResponse qu = await testDataManager.CreateQuote(iep);

            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                              // get quote

            ownerId = testDataManager.DoTrialEnrollmentReturnOwnerCollection(iep);                          // trial enroll
            System.Threading.Thread.Sleep(3000);                                                            // waiting for back end processes
            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, null, null, bExist : false);      // verify billing account not exist
        }
示例#7
0
        public async Task FullEnrollmentUSCreditCard()
        {
            // enroll
            EnrollmentParameters iep  = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 1); // get test data
            EnrollmentParameters iepc = testDataManager.SetupBillingCreditCard(iep);                             // setup credit card

            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                                   // get quote

            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);
            // verify billing account
            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);
        }
示例#8
0
        public async Task CAAddATrialPetInFullEnrollment()
        {
            iep     = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 1, riderNumber: random.Next(0, 2)); // get test data
            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);                                          // enroll with service standard enroll
            PetParameters petParams = testDataManager.GetTrialPetParameter(iep.PostalCode, iep.StateId);                       // another pet
            int           petId     = testDataManager.AddATrialPet(ownerId, petParams);                                        // adding to trial policy

            System.Threading.Thread.Sleep(3000);                                                                               // waiting for back end processes
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                                                 // get quote

            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);                             // verify billing account
        }
        public async Task CAAddAPetInEnrolledPolicyCollectPayment()
        {
            iep = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 1, riderNumber: random.Next(0, 2));      // get test data
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                                                  // get quote

            ownerId = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);                                           // enroll with service standard enroll
            PetParameters petParams = testDataManager.GetPetParameter(iep.PostalCode);                                          // another pet
            int           petId     = testDataManager.AddPetSkipPayment(ownerId, petParams);

            Assert.IsTrue(petId > 0, $"failed to add pet for owner - {ownerId}. {petParams}");
            iep.Pets.Add(petParams);                                                                                            // add
            // TODO - no new invoice in billing
            //System.Threading.Thread.Sleep(3000);                                                                              // waiting for back end processes
            //await BillingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);                            // verify billing account
        }
示例#10
0
        public async Task <QaLibQuoteResponse> CreateQuote(EnrollmentParameters iep)
        {
            QaLibQuoteResponse ret = new QaLibQuoteResponse();

            try
            {
                var returnPost = await asyncRestClientQALib.PostAsync <string, EnrollmentParameters>($"/Enrollment/Quotes/CreateQuote", iep).ConfigureAwait(false);

                ret = JsonSerializer.Deserialize <QaLibQuoteResponse>(returnPost.Value);
            }
            catch (Exception ex)
            {
                BillingTestCommon.log.Fatal(ex);
            }
            return(ret);
        }
示例#11
0
        public async Task CAPendingCancelAEnrolledPet()
        {
            iep = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 1, riderNumber: random.Next(0, 2));                                  // get test data
            iep.EffectiveDate = DateTime.Now.AddDays(-7);
            ownerId           = testDataManager.DoStandardEnrollmentReturnOwnerCollection(iep);                                                             // enroll with service standard enroll
            System.Threading.Thread.Sleep(10000);                                                                                                           // waiting for back end processes

            bool bCanceled = testDataManager.PendingCancelPolicy(ownerId, iep.Pets.First().PetName);                                                        // pending cancel pet

            Assert.IsTrue(bCanceled, $"failed to peding cancel pet - {iep.Pets.First().PetName} from owner's policy (ownerid = {ownerId})");
            System.Threading.Thread.Sleep(10000);                                                                                                           // waiting for back end processes

            bCanceled = await billingDataVerifiers.verifyOwnerPetEnrollmentStatus(ownerId, iep.Pets.First().PetName, EnrollmentStatus.PendingCancellation); // verify pet has been canceled

            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                                                                              // get quote

            await billingDataVerifiers.VerifyPendingCanceledPetBillingInfo(ownerId, iep.Pets.First().PetName, iep, quote, accountExpected);                 // verify billing account
        }
示例#12
0
        public async Task CAAddAEnrollmentPetInTrialPolicy()
        {
            iep = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 1);
            iep.EnrollmentTypeVal = EnrollmentType.IssueCertificate;
            ownerId = testDataManager.DoTrialEnrollmentReturnOwnerCollection(iep);                          // trial enroll
            var iep2 = testDataManager.GenerateOwnerPetTestData(countryCode: "CA", numPets: 1);

            iep.BillingParams = iep2.BillingParams;
            PetParameters petParams = testDataManager.GetPetParameter(iep.PostalCode);                      // another pet

            petParams.PromoCode = BillingTestCommonSettings.Default.PromoCodeUsaCanada;
            int petId = testDataManager.AddPetCollectPayment(ownerId, petParams, iep);

            System.Threading.Thread.Sleep(3000);                                                            // waiting for back end processes
            iep.Pets.Remove(iep.Pets.First());
            iep.Pets.Add(petParams);
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                              // get quote

            await billingDataVerifiers.VerifyBillingAccount(ownerId, iep, quote, accountExpected);          // verify billing account
        }
        public async Task USTrialConvertTwoWeeksAgoPet()
        {
            bool bConvert = false;
            IEnrollmentParameters iiep = testDataManager.GenerateTrialOwnerWithPet(EnrollmentType.AddTrial, numPets: 1);   // test data for trial

            iiep.EffectiveDate = DateTime.UtcNow.AddDays(-15);
            iiep.Pets.First().LastExamDate = DateTime.UtcNow.AddDays(-15);
            iiep.Pets.First().CreatedOn    = DateTime.UtcNow.AddDays(-15);
            ownerId = testDataManager.DoEnrollTrial(iiep);                                                                  // trial enroll
            IEnrollmentParameters fullEnrollIep = testDataManager.GenerateTrialOwnerWithPet(EnrollmentType.FullEnrollmentCollectPayment, numPets: 1);

            iiep.BillingParams     = fullEnrollIep.BillingParams;
            iiep.EffectiveDate     = DateTime.UtcNow.AddDays(-14);
            iiep.EnrollmentTypeVal = EnrollmentType.TrialUpgradeCollectPayment;
            bConvert = testDataManager.ConvertTrial(ownerId, iiep);                                                        // convert
            Assert.IsTrue(bConvert, $"failed to convert trial pet - {iiep.Pets.First().PetName}");
            System.Threading.Thread.Sleep(5000);                                                                           // waiting for back end processed to complete
            iep = testDataManager.ConvertEnrollmentParametersFromIEnrollmentParameters(iiep);
            QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep);                                             // get quote

            await billingDataVerifiers.VerifyBillingAccountForConvertedTrialPolicy(ownerId, iep, quote, accountExpected);  // verify billing account
        }
示例#14
0
        public async Task <QaLibQuoteResponse> CreateQuote(EnrollmentParameters ep)
        {
            QaLibQuoteResponse qr = await quoteService.CreateQuoteAsync(ep);

            return(qr);
        }
示例#15
0
        public async Task VerifyCanceledPetBillingInfo(int ownerId, EnrollmentParameters iep, QaLibQuoteResponse quote, Account accountExpected, bool bExist = true)
        {
            //try
            //{
            //    // get trudat owner
            //    ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
            //    accounts = await billingRestClient.GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());
            //}
            //catch(Exception ex)
            //{
            //    Logger.Log.Fatal(ex);
            //}
            //Account account = accounts.First();
            Account account = await GetAccountByOwnerId(ownerId);

            InvoiceWithItems iNext = await VerifyCanceledAccountPremium(account.Id, iep, quote);                                                   // verify premium
        }
示例#16
0
        public async Task VerifyPendingCanceledPetBillingInfo(int ownerId, string petName, EnrollmentParameters iep, QaLibQuoteResponse quote, Account accountExpected, bool bExist = true)
        {
            ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);                  // get trudat owner
            accounts        = await billingRestClient.GetBillingAccountByPolicyHolderId(ownerCollection.OwnerInformation.UniqueId.ToString());

            Account          account = accounts.First();
            InvoiceWithItems iNext   = await VerifyAccountPremium(account.Id, iep, quote);                                                 // verify premium
        }
示例#17
0
        public async Task <InvoiceWithItems> VerifyAccountPremium(string accountId, EnrollmentParameters iep, QaLibQuoteResponse quote, bool bMatch = true)
        {
            InvoiceWithItems ret       = null;
            bool             found     = false;
            string           assertMsg = string.Empty;

            if (quote == null)
            {
                Assert.Inconclusive("please provide expected premium first");
            }
            ret = await billingRestClient.GetAccountInvoicesNext(accountId);

            Assert.IsTrue(ret != null, "no next invoice");
            for (int i = 0; i < iep.Pets.Count; i++)
            {
                found = false;
                foreach (InvoiceItem item in ret.InvoiceItems)
                {
                    assertMsg = $"<{quote.Pets[i].Premium} -- {item.ChargeAmount}>";
                    found     = quote.Pets[i].Premium == item.ChargeAmount;
                    if (found)
                    {
                        assertMsg = string.Empty;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
                else
                {
                    assertMsg += bMatch ? $"premium doesn't match any invoice item - {assertMsg}\r\n"
                                        : $"premium matched invoice item - {assertMsg}\r\n";
                }
            }
            return(ret);
        }
示例#18
0
        public async Task VerifyBillingAccount(int ownerId, EnrollmentParameters iep, QaLibQuoteResponse quote, Account accountExpected, bool bExist = true)
        {
            // get trudat owner
            ownerCollection = testDataManager.GetEnrolledOwnerCollection(ownerId);
            // verify billing account existing
            accounts = await VerifyBillingAccountExist(ownerCollection.OwnerInformation.UniqueId.ToString(), bExist);

            if (bExist)
            {
                Account account = accounts.First();
                Assert.IsTrue(account.AutoPay == accountExpected.AutoPay, $"auto pay- {account.AutoPay} is not as expected - {accountExpected.AutoPay}");                                              // verify auto pay
                Assert.IsTrue(account.Currency.Equals(accountExpected.Currency), $"currency- {account.Currency} is as not expected - {accountExpected.Currency}");                                     // verify currency
                Assert.IsTrue(account.BillCycleDay.Equals(iep.BillingParams.BillingDayOfMonth), $"bill cycle day- {account.BillCycleDay} is as not expected - {iep.BillingParams.BillingDayOfMonth}"); // verify currency
                List <PaymentMethod> paymentMethod = await VerifyAccountPaymentMethod(account.Id, iep);                                                                                                // verify bank info

                InvoiceWithItems iNext = await VerifyAccountPremium(account.Id, iep, quote);                                                                                                           // verify premium

                decimal dueBalance = await GetExpectedDueBalance(account, iep.StateId, quote);                                                                                                         // verify premium

                Assert.IsTrue(dueBalance == account.Balance, $"due balance {dueBalance} doen'st match expected {account.Balance}");
                // TODO - verify due date and charity
                //Assert.IsTrue(account.BalancePastDueDate == null || account.BalancePastDueDate.Equals(iep.EffectiveDate), $"past due date {account.BalancePastDueDate} doesn't match expected {iep.EffectiveDate}");  // past due date
                //Assert.IsTrue(account.CharityId == null || account.CharityId.Equals(iep.BillingParams.CharityId), $"charity {account.CharityId} doesn't match expected {iep.BillingParams.CharityId}");                 // past due date
            }
            else
            {
                Assert.IsTrue(accounts.Count == 0, $"account shouldn't exist");                                                                                     // verify auto pay
            }
        }
示例#19
0
        public async Task <decimal> GetExpectedDueBalance(Account account, int stateId, QaLibQuoteResponse quote)
        {
            decimal ret = 0;

            try
            {
                ret = await qaLibRestClient.GetSetupFeeByStateId(stateId);

                for (int i = 0; i < quote.Pets.Count; i++)
                {
                    ret += quote.Pets[i].Premium;
                }
                if (stateId >= 60)                              // canada: tax are in item
                {
                    List <InvoiceWithItems> invoices = await billingRestClient.GetAccountInvoices(account.Id);

                    foreach (InvoiceWithItems invoice in invoices)
                    {
                        List <InvoiceItem> invoicItems = await billingRestClient.GetInvoicesItems(invoice.Id);

                        foreach (InvoiceItem item in invoicItems)
                        {
                            ret += item.TaxAmount;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Fatal(ex);
                ret = 0;
            }
            return(ret);
        }
示例#20
0
        public async Task <InvoiceWithItems> VerifyCanceledAccountPremium(string accountId, EnrollmentParameters iep, QaLibQuoteResponse quote, bool bCanceld = true)
        {
            InvoiceWithItems ret       = null;
            bool             found     = false;
            string           assertMsg = string.Empty;

            if (quote == null)
            {
                Assert.Inconclusive("please provide expected premium first.");
            }
            var invoices = await billingRestClient.GetAccountInvoices(accountId);

            foreach (InvoiceWithItems invoice in invoices)
            {
                for (int i = 0; i < iep.Pets.Count; i++)
                {
                    found = quote.Pets[i].Premium == -1 * invoice.Amount;
                    if (found)
                    {
                        assertMsg = string.Empty;
                        break;
                    }
                }
                if (bCanceld)
                {
                    assertMsg += found ? string.Empty : $"canceled premium {invoice.Amount} doesn't match any expected\r\n";
                }
                else
                {
                    assertMsg += !found ? string.Empty : $"pending canceled premium {invoice.Amount} is found\r\n";
                }
                if (found)
                {
                    break;
                }
            }
            Assert.IsTrue(found, assertMsg);
            return(ret);
        }