Exemplo n.º 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
            }
        }
Exemplo n.º 2
0
        public int DoEnrollTrial(IEnrollmentParameters iiep)
        {
            int ownerId = 0;

            ownerId = this.enrollOwner.EnrollTestOwner(iiep);
            if (ownerId == 0)
            {
                throw new ApplicationException("Created Owner Id is 0");
            }
            Trace.WriteLine($"Email address: {iiep.EMailAddress}");
            return(ownerId);
        }
Exemplo n.º 3
0
        public bool ConvertTrial(int ownerId, IEnrollmentParameters iep)
        {
            bool ret = false;

            try
            {
                ret = this.enrollOwner.ConvertTrial(ownerId, iep);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
Exemplo n.º 4
0
        public IEnrollmentParameters GenerateTrialOwnerWithPet(EnrollmentType enrollType, string countryCode = "US", int numPets = 1, int riderNumber = 0)
        {
            IEnrollmentParameters iiep = null;

            switch (countryCode.ToLower())
            {
            case "us":
                iiep = GenerateUSTrialOwnerWithPet(enrollType, numPets);
                break;

            case "ca":
                iiep = GenerateCATrialOwnerWithPet(enrollType, numPets);
                if (enrollType == EnrollmentType.FullEnrollmentCollectPayment)
                {
                    //iiep.BillingParams.BankAccountAccountNumber = BillingTest.Default.CanadaBankAccountNumber;            // back end need this encrypt format
                    iiep.BillingParams.BankAccountTransitNumber = BillingTestCommonSettings.Default.BankAccountNumberCA.Substring(0, 5);
                    iiep.BillingParams.BankAccountBankCode      = BillingTestCommonSettings.Default.BankAccountNumberCA.Substring(0, 3);
                }
                break;

            case "au":
                iiep = GenerateAUTrialOwnerWithPet(enrollType, numPets);
                break;

            default:
                throw new Exception($"country is not supported yet - {countryCode}");
            }
            // set billing test enroll last name
            iiep.LastName      = $"bat{iiep.LastName}";
            iiep.EffectiveDate = DateTime.UtcNow.AddDays(-1);
            // riders?
            foreach (PetParameters pet in iiep.Pets)
            {
                if (riderNumber > 0)
                {
                    pet.Riders = new List <SelectedPolicyOption>();
                    pet.Riders.Add(riderA);
                    if (riderNumber > 1)
                    {
                        pet.Riders.Add(riderB);
                    }
                }
                else
                {
                    pet.Riders = new List <SelectedPolicyOption>();
                }
            }
            return(iiep);
        }
Exemplo n.º 5
0
        public int AddPetSkipPayment(int ownerId, PetParameters pet)
        {
            int ret = 0;
            IEnrollmentParameters fiep = ConverteFullEnrollmentParametersFromEnrollmentParameters(iep);

            try
            {
                pet.PromoCode = string.Empty;
                ret           = this.addPetFactory.AddAPetSkipPayment(ownerId, pet);
            }
            catch (Exception ex)
            {
                log.Fatal(ex);
            }
            return(ret);
        }
Exemplo n.º 6
0
        public async Task CATrialConvertOnePet()
        {
            bool bConvert = false;
            IEnrollmentParameters iiep = testDataManager.GenerateTrialOwnerWithPet(EnrollmentType.AddTrial, countryCode: "CA", numPets: 1);                                 // test data for trial

            ownerId = testDataManager.DoEnrollTrial(iiep);                                                                                                                  // trial enroll
            IEnrollmentParameters fullEnrollIep = testDataManager.GenerateTrialOwnerWithPet(EnrollmentType.FullEnrollmentCollectPayment, countryCode: "CA", numPets: 1);

            iiep.BillingParams     = fullEnrollIep.BillingParams;
            iiep.EffectiveDate     = DateTime.UtcNow.AddDays(-1);
            iiep.EnrollmentTypeVal = EnrollmentType.TrialUpgradeCollectPayment;
            bConvert = testDataManager.ConvertTrial(ownerId, iiep);                                                                                                        // convert
            System.Threading.Thread.Sleep(5000);                                                                                                                           // waiting for back end processes
            Assert.IsTrue(bConvert, $"failed to convert trial pet - ownerId <{ownerId}>; pet <{iiep.Pets.First().PetName}>");
            await billingDataVerifiers.VerifyBillingAccountForConvertedTrialPolicy(ownerId, iiep);                                                                         // verify billing account
        }
Exemplo n.º 7
0
        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
        }
Exemplo n.º 8
0
        public async Task <bool> ConvertTrialPolicy(int ownerId, IEnrollmentParameters iiep)
        {
            bool ret = false;
            RestRequestSpecification request = null;

            try
            {
                request             = new RestRequestSpecification();
                request.Verb        = HttpMethod.Post;
                request.RequestUri  = $"Enrollment/ConvertTrials/ConvertPolicy/{ownerId}";
                request.ContentType = "application/json";
                request.Content     = JsonSerializer.Serialize(iiep);

                var returnPost = await asyncRestClientQALib.ExecuteAsync <string>(request);

                ret = bool.Parse(returnPost.Value.ToString());
            }
            catch (Exception ex)
            {
                BillingTestCommon.log.Fatal(ex);
            }
            return(ret);
        }
Exemplo n.º 9
0
        public EnrollmentParameters ConvertEnrollmentParametersFromIEnrollmentParameters(IEnrollmentParameters iep)
        {
            EnrollmentParameters fiep = new EnrollmentParameters();

            fiep.Address       = iep.Address;
            fiep.Address2      = iep.Address2;
            fiep.BillingParams = new BillingParameters();
            fiep.BillingParams.BankAccountAccountNumber      = iep.BillingParams.BankAccountAccountNumber;
            fiep.BillingParams.BankAccountAccountNumberLast4 = iep.BillingParams.BankAccountAccountNumberLast4;
            fiep.BillingParams.BankAccountAccountType        = iep.BillingParams.BankAccountAccountType;
            fiep.BillingParams.BankAccountBankCode           = iep.BillingParams.BankAccountBankCode;
            fiep.BillingParams.BankAccountBankName           = iep.BillingParams.BankAccountBankName;
            fiep.BillingParams.BankAccountNameOnAccount      = iep.BillingParams.BankAccountNameOnAccount;
            fiep.BillingParams.BankAccountTransitNumber      = iep.BillingParams.BankAccountTransitNumber;
            fiep.BillingParams.BillingDayOfMonth             = iep.BillingParams.BillingDayOfMonth;
            fiep.BillingParams.CharityId     = iep.BillingParams.CharityId;
            fiep.BillingParams.PaymentMethod = iep.BillingParams.PaymentMethod;
            fiep.CampaignInstanceId          = iep.CampaignInstanceId;
            fiep.City          = iep.City;
            fiep.EffectiveDate = DateTime.UtcNow;
            //fiep.EMailAddress = iep.EMailAddress;
            fiep.EMailSuffix       = iep.EMailSuffix;
            fiep.EnrollmentTypeVal = iep.EnrollmentTypeVal;
            fiep.FirstName         = iep.FirstName;
            fiep.LastName          = iep.LastName;
            fiep.LeadId            = iep.LeadId;
            fiep.Password          = iep.Password;
            fiep.Pets = new List <PetParameters>();
            foreach (PetParameters pet in iep.Pets)
            {
                fiep.Pets.Add(pet);
            }
            //fiep.PetCount = iep.PetCount;
            fiep.Platform        = iep.Platform;
            fiep.PostalCode      = iep.PostalCode;
            fiep.PrimaryPhone    = iep.PrimaryPhone;
            fiep.ReferenceNumber = iep.ReferenceNumber;
            fiep.SecondaryPhone  = iep.SecondaryPhone;
            fiep.StateId         = iep.StateId;
            fiep.WorkPhone       = iep.WorkPhone;

            return(fiep);
        }