//[TestMethod] public async Task CreateQuote() { EnrollmentParameters iep = testDataManager.GenerateOwnerPetTestData(numPets: 1); // get test data QaLibQuoteResponse quote = await qaLibRestClient.CreateQuote(iep); Assert.IsNotNull(quote, ""); }
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 } }
//[TestMethod] public async Task GetEnginVersionForState() { EnrollmentParameters iep = testDataManager.GenerateOwnerPetTestData(numPets: 1); var versionId = await qaLibRestClient.GetEnginVersionForState(iep.StateId); var pVersionId = await qaLibRestClient.GetPolicyVersionForState(iep.StateId); }
public async Task <PagedList <Enrollment> > GetEnrollmentsAsync(Guid sectionId, EnrollmentParameters enrollmentParameters, bool trackChanges) { var enrollment = await FindByCondition(e => e.SectionId.Equals(sectionId), trackChanges) .OrderBy(e => e.AttributeName) .ToListAsync(); return(PagedList <Enrollment> .ToPagedList(enrollment, enrollmentParameters.PageNumber, enrollmentParameters.PageSize)); }
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); }
public int DoStandardEnrollmentReturnOwnerCollection(EnrollmentParameters iep) { int ownerId = 0; ownerId = this.enrollmentService.EnrollSingleOwner(iep); if (ownerId == 0) { throw new ApplicationException("Created Owner Id is 0"); } Trace.WriteLine($"Email address: {iep.EMailAddress}"); return(ownerId); }
//[TestMethod] public async Task GettingPremium() { EnrollmentParameters iep = testDataManager.GenerateOwnerPetTestData(numPets: 1); // get test data decimal premium = await qaLibRestClient.GetPremium(iep); EnrollmentParameters iep1 = iep; foreach (PetParameters p in iep1.Pets) { p.Riders = null; } decimal premium1 = await qaLibRestClient.GetPremium(iep1); Assert.IsTrue(premium > 0, ""); }
public async Task <int> DoStandardEnrollmentReturnOwnerCollectionRestClient(EnrollmentParameters iep) { int ownerId = 0; QALibRestClient qalib = new QALibRestClient(); ownerId = await qalib.EnrollSingleOwner(iep); if (ownerId == 0) { throw new ApplicationException("Created Owner Id is 0"); } Trace.WriteLine($"Email address: {iep.EMailAddress}"); return(ownerId); }
public int AddPetCollectPayment(int ownerId, PetParameters pet, EnrollmentParameters iep) { int ret = 0; IEnrollmentParameters fiep = ConverteFullEnrollmentParametersFromEnrollmentParameters(iep); try { pet.PromoCode = string.Empty; ret = this.addPetFactory.AddPetCollectPayment(ownerId, pet, fiep); } catch (Exception ex) { log.Fatal(ex); } return(ret); }
public EnrollmentParameters SetupBillingCreditCard(EnrollmentParameters input) { EnrollmentParameters iep = input; iep.BillingParams.BankAccountAccountNumber = "4111111111111111"; iep.BillingParams.BankAccountAccountNumberLast4 = "1234"; //iep.BillingParams.BankAccountAccountType = LegacyPlatform.Constants.BankAccountType.Checking; //iep.BillingParams.BankAccountBankCode = string.Empty; //iep.BillingParams.BankAccountBankName = "Visa"; //iep.BillingParams.BankAccountNameOnAccount = "Visa Tester"; //iep.BillingParams.BankAccountTransitNumber = string.Empty; //iep.BillingParams.BillingDayOfMonth = 1; //iep.BillingParams.CharityId = 0; iep.BillingParams.PaymentMethod = LegacyPlatform.Constants.PaymentMethod.CreditCard; return(iep); }
public async Task <int> TrialEnrollOwner(EnrollmentParameters iep) { int ret = 0; try { var returnPost = await asyncRestClientQALib.PostAsync <string, EnrollmentParameters>($"/Enrollment/EnrollmentParameters/TrialEnrollOwner", iep).ConfigureAwait(false); ret = JsonSerializer.Deserialize <int>(returnPost.Value); } catch (Exception ex) { BillingTestCommon.log.Fatal(ex); } return(ret); }
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); }
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 }
public async Task <decimal> GetPremium(EnrollmentParameters iep) { decimal ret = 0; PremiumSprocParameters psp = new PremiumSprocParameters(); List <PetParameters> pets = (List <PetParameters>)iep.Pets; try { psp.AgeId = (int)pets[0].AgeId; psp.BreedId = pets[0].BreedId; psp.ClinicId = pets[0].HospitalId == null ? 0 : (int)pets[0].HospitalId; psp.CountryId = 0; psp.Deductible = pets[0].Deductible; psp.Gender = pets[0].Gender == LegacyPlatform.Constants.Gender.Male ? 'M' : 'F'; psp.IsRenewal = false; psp.PetFoodId = 0; psp.PolicyVersionId = int.Parse(await GetPolicyVersionForState(iep.StateId)); psp.PromoCode = pets[0].PromoCode; if (pets[0].Riders?.Count > 0) { foreach (SelectedPolicyOption r in pets[0].Riders) { psp.SelectedPolicyOptions += $"{r.Name} "; ret += r.Cost; } } psp.SpayedNeuteredStatus = pets[0].SpayedNeutered ? 1 : 0; psp.SpecieId = (int)pets[0].Species; psp.UserId = 0; psp.VersionId = int.Parse(await new QALibRestClient().GetEnginVersionForState(iep.StateId)); psp.WorkingPets = (pets[0].IsWorkingPet ? 1 : 0).ToString(); psp.Zipcode = iep.PostalCode; var dec = await GetTruDatPremium(psp); ret += System.Math.Round(decimal.Parse(dec), 2); } catch (Exception ex) { BillingTestCommon.log.Fatal(ex); ret = 0; } return(ret); }
public async Task <IActionResult> GetEnrollmentsForSection(Guid sectionId, [FromQuery] EnrollmentParameters enrollmentParameters) { var section = await _repository.Section.GetSectionsAsync(sectionId, trackChanges : false); if (section == null) { _logger.LogInfo($"Section with id: {sectionId} doesn't exist in the database."); return(NotFound()); } var enrollmentsFromDb = await _repository.Enrollment.GetEnrollmentsAsync(sectionId, enrollmentParameters, trackChanges : false); Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(enrollmentsFromDb.MetaData)); var enrollmentsDto = _mapper.Map <IEnumerable <EnrollmentDto> >(enrollmentsFromDb); return(Ok(enrollmentsDto)); }
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); }
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); }
public async Task <bool> ConvertTrialPet(int ownerId, string petName, EnrollmentParameters iep) { bool ret = false; RestRequestSpecification request = null; try { request = new RestRequestSpecification(); request.Verb = HttpMethod.Post; request.RequestUri = $"Enrollment/ConvertTrials/ConverPet/{ownerId}/{petName}"; request.ContentType = "application/json"; request.Content = JsonSerializer.Serialize(iep); var returnPost = await asyncRestClientQALib.ExecuteAsync <string>(request); ret = bool.Parse(returnPost.Value.ToString()); } catch (Exception ex) { BillingTestCommon.log.Fatal(ex); } return(ret); }
public async Task <int> EnrollSingleOwner(EnrollmentParameters iep) { int ret = 0; RestRequestSpecification request = null; try { request = new RestRequestSpecification(); request.Verb = HttpMethod.Post; request.RequestUri = $"Enrollment/EnrollmentParameters/FullEnrollOwner"; request.ContentType = "application/json"; request.Content = JsonSerializer.Serialize(iep); var returnPost = await asyncRestClientQALib.ExecuteAsync <RestResult <EnrollmentParameters> >(request); ret = int.Parse(returnPost.Value.ToString()); } catch (Exception ex) { BillingTestCommon.log.Fatal(ex); } return(ret); }
public async Task VerifyBillingAccountForConvertedTrialPolicy(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); // verify pet enrollment status bool b = await verifyOwnerPetEnrollmentStatus(ownerId, iep.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(iep.BillingParams.BillingDayOfMonth), $"bill cycle day- {account.BillCycleDay} is as not expected - {iiep.BillingParams.BillingDayOfMonth}"); // verify currency 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 <QaLibQuoteResponse> CreateQuote(EnrollmentParameters ep) { QaLibQuoteResponse qr = await quoteService.CreateQuoteAsync(ep); return(qr); }
public async Task <List <PaymentMethod> > VerifyAccountPaymentMethod(string accountId, EnrollmentParameters iep) { List <PaymentMethod> ret = null; ret = await billingRestClient.GetAccountPaymentMethodByAccountId(accountId); Assert.IsTrue(ret?.Count > 0, "account payment methods is not retrieved"); foreach (PaymentMethod payment in ret) { Assert.IsTrue(payment.Type.Equals(iep.BillingParams.PaymentMethod.ToString()), $"bank account type {payment.Type} is not match the expected {iep.BillingParams.BankAccountAccountType}"); Assert.IsTrue(payment.AchBankName.Equals(iep.BillingParams.BankAccountBankName), $"bank name {payment.AchBankName} is not match the expected {iep.BillingParams.BankAccountBankName}"); Assert.IsTrue(payment.AchAccountName.Equals(iep.BillingParams.BankAccountNameOnAccount), $"bank account name {payment.AchAccountName} is not match the expected {iep.BillingParams.BankAccountNameOnAccount}"); Assert.IsTrue(payment.AchAccountType.Equals(iep.BillingParams.BankAccountAccountType.ToString()), $"bank account type {payment.Type} is not match the expected {iep.BillingParams.BankAccountAccountType}"); Assert.IsTrue(payment.AchAccountNumberMask.Contains(iep.BillingParams.BankAccountAccountNumberLast4), $"last 4 digit {payment.AchAccountNumberMask} is not match the expected {iep.BillingParams.BankAccountAccountNumberLast4}"); if (iep.StateId < 60) // us only { Assert.IsTrue(payment.AchAbaCode.Equals(iep.BillingParams.BankAccountTransitNumber.ToString()), $"transit number {payment.AchAbaCode} is not match the expected {iep.BillingParams.BankAccountTransitNumber}"); } break; } return(ret); }
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); }
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); }
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 }
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 FullEnrollmentParameters ConverteFullEnrollmentParametersFromEnrollmentParameters(EnrollmentParameters iep) { FullEnrollmentParameters fiep = new FullEnrollmentParameters(); fiep.Address = iep.Address; fiep.Address2 = iep.Address2; fiep.BillingParams = new Trupanion.Test.QALib.DatabaseAccess.Models.SprocParameters.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.ExternalAccountId = string.Empty; 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.PersonInfo = new Trupanion.Test.QALib.DatabaseAccess.Models.Poco.TestData.OwnerPocos.PersonInfo(); 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); }