Beispiel #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
            }
        }
        public async Task <InvoiceWithItems> GetAccountInvoicesNext(string accountId)
        {
            InvoiceWithItems ret = new InvoiceWithItems();

            try
            {
                RestRequestSpecification req = new RestRequestSpecification();
                req.Verb        = HttpMethod.Get;
                req.RequestUri  = $"/v2/accounts/{accountId}/invoices/next";
                req.Headers     = Headers;
                req.ContentType = "application/json";
                var returnPost = await asyncRestClientBilling.ExecuteAsync <string>(req);

                if (returnPost.Success)
                {
                    ret = JsonSerializer.Deserialize <InvoiceWithItems>(returnPost.Value);
                }
                else
                {
                    ret = null;
                }
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
                ret = null;
            }
            return(ret);
        }
Beispiel #3
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
            }
        }
Beispiel #4
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
        }
Beispiel #5
0
        public async Task GetInvoices_nullInvoiceId()
        {
            request.RequestUri = $"v2/invoices?criteria.accountId={accountExternalId}&criteria.refundId=null";
            invoicesResult     = await asyncRestClientBilling.ExecuteAsync <string>(request);                       // ??? got all invoices

            Assert.IsTrue(invoicesResult.Success, $"successed unexpectedly");
            List <InvoiceWithItems> invoices = JsonSerializer.Deserialize <List <InvoiceWithItems> >(((RestResult <string>)invoicesResult).Value);
            InvoiceWithItems        invoice  = invoices.Where(i => i.Amount == BillingApiTestSettings.Default.BillingServiceApiAccountInoiceAmount).FirstOrDefault();

            Assert.IsNotNull(invoice, $"invoice is not as expected - {invoices}");
        }
Beispiel #6
0
        public async Task GetAccountsNextInvoice_success()
        {
            request.RequestUri = $"/v2/accounts/{BillingApiTestSettings.Default.BillingServiceApiAccountExternalId}/invoices/next";
            accountResult      = await asyncRestClientBilling.ExecuteAsync <string>(request);

            Assert.IsTrue(accountResult.Success, $"failed to restclient get account next invoice");
            InvoiceWithItems invoiceWithItems = JsonSerializer.Deserialize <InvoiceWithItems>(((RestResult <string>)accountResult).Value);

            Assert.IsNotNull(invoiceWithItems, $"no invoice for {BillingApiTestSettings.Default.BillingServiceApiAccountExternalId}");
            //Assert.IsTrue(invoiceWithItems.Amount == BillingApiTestSettings.Default.BillingServiceApiAccountNextInvoiceAmount, $"invoice amout {invoiceWithItems.Amount.ToString()} is not as expected - {BillingApiTestSettings.Default.BillingServiceApiAccountNextInvoiceAmount.ToString()}");
        }
Beispiel #7
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
        }
Beispiel #8
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);
        }
Beispiel #9
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);
        }
Beispiel #10
0
        public async Task <InvoiceWithItems> VerifyCanceledAccountPremium(string accountId, EnrollmentParameters iep, List <InvoiceItem> invoiceItems, bool bCanceld = true)
        {
            InvoiceWithItems ret            = null;
            bool             matchedPremium = false;
            string           assertMsg      = string.Empty;

            if (invoiceItems.Count <= 0)
            {
                Assert.Inconclusive("please provide expected premium first.");
            }
            var invoices = await billingRestClient.GetAccountInvoices(accountId);

            foreach (InvoiceWithItems invoice in invoices)
            {
                matchedPremium = false;
                for (int i = 0; i < invoiceItems.Count; i++)
                {
                    matchedPremium = invoiceItems[i].ChargeAmount == -1 * invoice.Amount;
                    if (matchedPremium)
                    {
                        assertMsg = string.Empty;
                        break;
                    }
                }
                if (matchedPremium)
                {
                    break;
                }
                else
                {
                    assertMsg += bCanceld ? $"canceled premium {invoice.Amount} doesn't match any expected\r\n"
                                          : $"pending canceled premium {invoice.Amount} is found\r\n";;
                }
            }
            Assert.IsTrue(matchedPremium, assertMsg);
            return(ret);
        }
Beispiel #11
0
        public async Task VerifyCanceledPetBillingInfo(int ownerId, EnrollmentParameters iep, List <InvoiceItem> invoiceItems, Account accountExpected, bool bExist = true)
        {
            Account account = await GetAccountByOwnerId(ownerId);

            InvoiceWithItems iNext = await VerifyCanceledAccountPremium(account.Id, iep, invoiceItems);                                                   // verify premium
        }
        public InvoicePreviewCriteria BuildInvoicePreviewCriteriaFromInvoice(OwnerCollection ownerCollection, InvoiceWithItems invoice, string IsoAlpha3Code)
        {
            InvoicePreviewCriteria ret = new InvoicePreviewCriteria();

            ret.PostalCode = ownerCollection.AddressInformation.Zipcode;
            ret.IsoAlpha2SateOrProvinceCode = "Minnesota"; // ownerCollection.AddressInformation.StateId.ToString();
            ret.IsoAlpha3CountryCode        = IsoAlpha3Code;
            InvoicePreviewItemCriteria item = new InvoicePreviewItemCriteria();

            item.Amount         = invoice.Amount;
            item.DiscountAmount = 0;
            item.ProductId      = "2c91a0f8557bc1f401557f2ceb5e1d31";    // "Pet Insurance";
            ret.Items.Add(item);
            return(ret);
        }