Ejemplo n.º 1
0
        public MemberAccountSummaryModel GetAccountSummary(string loyaltyId, string programCode, string externalId)
        {
            MemberAccountSummaryModel memberAccountSummaryOut = default;

            using (ConsoleCapture capture = new ConsoleCapture())
            {
                try
                {
                    var lwMemberPromo = lwSvc.GetAccountSummary(loyaltyId, programCode, externalId, out double time);
                    memberAccountSummaryOut = LODConvert.FromLW <MemberAccountSummaryModel>(lwMemberPromo);
                }
                catch (LWClientException ex)
                {
                    throw new LWServiceException(ex.Message, ex.ErrorCode);
                }
                catch (Exception ex)
                {
                    throw new LWServiceException(ex.Message, -1);
                }
                finally
                {
                    stepContext.AddAttachment(new Attachment("GetAccountSummary", capture.Output, Attachment.Type.Text));
                }
            }
            return(memberAccountSummaryOut);
        }
Ejemplo n.º 2
0
        public MemberAccountSummaryModel GetMemberAccountSummaryFromDB(string vckey)
        {
            StringBuilder query = new StringBuilder();

            query.Append("select SUM(p.points) as currencybalance, lm.memberstatus, vc.createdate, md.a_tierenddate, md.a_lastactivitydate, md.a_mktgprogramid");
            query.Append(" ,case when md.a_tiercode = 'RG' THEN 'Gold'");
            query.Append(" when md.a_tiercode = 'FG' THEN 'Five Star'");
            query.Append(" when md.a_tiercode = 'PC' THEN 'Presidents Circle'");
            query.Append(" when md.a_tiercode = 'PL' THEN 'Platinum'");
            query.Append(" when md.a_tiercode = 'PS' THEN 'Platinum Select'");
            query.Append(" when md.a_tiercode = 'VP' THEN 'Platinum VIP'");
            query.Append(" END as CURRENTTIERNAME");
            query.Append(",case when lm.memberstatus = 1 THEN 'Active'");
            query.Append(" when lm.memberstatus = 2 THEN 'Disabled'");
            query.Append(" END as MEMBERSTATUS");
            query.Append(" from bp_htz.ats_memberdetails md");
            query.Append(" inner join bp_htz.lw_virtualcard vc on vc.ipcode = md.a_ipcode");
            query.Append(" inner join bp_htz.lw_loyaltymember lm on lm.ipcode = vc.ipcode ");
            query.Append(" left join (select pt.vckey, pt.points, pt.expirationdate from bp_htz.lw_pointtransaction pt");
            query.Append(" where pt.expirationdate > CURRENT_TIMESTAMP)p on p.vckey = vc.vckey");
            query.Append($" where vc.vckey = {vckey}");
            query.Append(" group by lm.memberstatus, vc.createdate, md.a_tierenddate, md.a_lastactivitydate, md.a_mktgprogramid");
            query.Append(" ,case when md.a_tiercode = 'RG' THEN 'Gold'");
            query.Append(" when md.a_tiercode = 'FG' THEN 'Five Star'");
            query.Append(" when md.a_tiercode = 'PC' THEN 'Presidents Circle'");
            query.Append(" when md.a_tiercode = 'PL' THEN 'Platinum'");
            query.Append(" when md.a_tiercode = 'PS' THEN 'Platinum Select'");
            query.Append(" when md.a_tiercode = 'VP' THEN 'Platinum VIP' END");
            query.Append(" ,case when lm.memberstatus = 1 THEN 'Active'");
            query.Append(" when lm.memberstatus = 2 THEN 'Disabled'");
            query.Append(" END");

            MemberAccountSummaryModel memberAccountSummary = dbContext.QuerySingleRow <MemberAccountSummaryModel>(query.ToString());

            return(memberAccountSummary);
        }
Ejemplo n.º 3
0
        public void GetAccountSummaryTestsTest_Positive(MemberModel createMember, IHertzProgram program)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                TestStep.Start("Assing Member unique LoyaltyIds for each virtual card", "Unique LoyaltyIds should be assigned");
                createMember = memController.AssignUniqueLIDs(createMember);
                TestStep.Pass("Unique LoyaltyIds assigned", createMember.VirtualCards.ReportDetail());

                TestStep.Start($"Make AddMember Call", "Member should be added successfully and member object should be returned");
                MemberModel memberOut = memController.AddMember(createMember);
                AssertModels.AreEqualOnly(createMember, memberOut, MemberModel.BaseVerify);
                TestStep.Pass("Member was added successfully and member object was returned", memberOut.ReportDetail());

                int transactionCount = 1;
                var memVirtualCard   = memberOut.VirtualCards.First();
                TestStep.Start($"Add random transaction(s) to members virtual card with VCKEY = {memVirtualCard.VCKEY}", "Transaction(s) should be added to members virtual card");
                memVirtualCard.Transactions = TxnHeaderController.GenerateRandomTransactions(memVirtualCard, program, transactionCount, 500M);
                Assert.AreEqual(transactionCount, memVirtualCard.Transactions.Count, $"Expected {transactionCount} TxnHeader(s) to be present in members vitual card");
                TestStep.Pass("Transaction(s) is added to members virtual card", memVirtualCard.Transactions.ReportDetail());

                foreach (var transaction in memVirtualCard.Transactions)
                {
                    transaction.A_TXNQUALPURCHASEAMT = TxnHeaderController.CalculateQualifyingPurchaseAmount(transaction);
                    transaction.A_QUALTOTAMT         = TxnHeaderController.CalculateQualifyingPurchaseAmount(transaction);
                }

                TestStep.Start("Update Existing Member with added transaction", "Member object should be returned from UpdateMember call");
                MemberModel updatedMember = memController.UpdateMember(memberOut);
                Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned");
                TestStep.Pass("Member object returned from UpdateMember API call", updatedMember.ReportDetail());

                var vckey = memVirtualCard.VCKEY.ToString();
                TestStep.Start("Get Account Summary from DB", "Account Summary retrieved from DB");
                MemberAccountSummaryModel memberAccountSummaryOutDb = memController.GetMemberAccountSummaryFromDB(vckey);
                Assert.IsNotNull(memberAccountSummaryOutDb, "Account Summary could not be retrieved from DB");
                TestStep.Pass("Existing member was found", memberOut.ReportDetail());

                var loyaltyId   = memVirtualCard.LOYALTYIDNUMBER;
                var programCode = program != null ? program.EarningPreference : null;
                TestStep.Start("GetAccountSummary API call", "Account Summary retruned from API");
                MemberAccountSummaryModel memberAccountSummaryOut = memController.GetAccountSummary(loyaltyId, programCode, null);
                Assert.IsNotNull(memberAccountSummaryOut, "Account Summary not returned from API");
                TestStep.Pass("Account Summary was returned from API", memberOut.ReportDetail());

                TestStep.Start("Compare Account Summary between DB and API", "Account Summary matches");
                AssertModels.AreEqualWithAttribute(memberAccountSummaryOutDb, memberAccountSummaryOut);
                TestStep.Pass("Account Summary matches between DB and API", memberOut.ReportDetail());
            }
            catch (LWServiceException ex)
            {
                TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" });
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
        public void HertzTransferPoints_Positive(MemberModel memberSource, MemberModel memberDestionation, decimal points, IHertzTier tier, bool useRanum)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                //Generate unique LIDs for each virtual card in the member
                memberSource = memController.AssignUniqueLIDs(memberSource);
                string ranum;

                TestStep.Start($"Make AddMember Call", "Source Member should be added successfully");
                MemberModel memberOutSource = memController.AddMember(memberSource);
                AssertModels.AreEqualOnly(memberSource, memberOutSource, MemberModel.BaseVerify);
                TestStep.Pass("Source Member was added successfully and member object was returned", memberOutSource.ReportDetail());
                VirtualCardModel vcSource = memberOutSource.VirtualCards.First();

                memberDestionation = memController.AssignUniqueLIDs(memberDestionation);
                TestStep.Start($"Make AddMember Call", "Destination Member should be added successfully");
                MemberModel memberOutDestination = memController.AddMember(memberDestionation);
                AssertModels.AreEqualOnly(memberDestionation, memberOutDestination, MemberModel.BaseVerify);
                TestStep.Pass("Destination Member was added successfully and member object was returned", memberOutDestination.ReportDetail());
                VirtualCardModel vcDestination = memberOutDestination.VirtualCards.First();


                //Transactions are added to test the API with ranum and also to test the negative points scenario
                TestStep.Start($"Add Transaction to the source member", "Transactions added successfully");
                vcSource.Transactions = TxnHeaderController.GenerateRandomTransactions(vcSource, tier.ParentProgram, 1, 500);
                if (useRanum)
                {
                    ranum = vcSource.Transactions.Select(x => x.A_RANUM).First();
                }
                else
                {
                    ranum = null;
                }
                Assert.IsNotNull(vcSource.Transactions, "Expected populated transaction object, but transaction object returned was null");
                TestStep.Pass("Transaction added to the source member", vcSource.Transactions.ReportDetail());

                TestStep.Start("Update Existing Source Member with added transaction", "Source Member object should be returned from UpdateMember call");
                MemberModel updatedMember = memController.UpdateMember(memberOutSource);
                Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned");
                TestStep.Pass("Member object returned from UpdateMember API call", updatedMember.ReportDetail());


                var loyaltyIdSource      = memberOutSource.VirtualCards.First().LOYALTYIDNUMBER;
                var loyaltyIdDestination = memberOutDestination.VirtualCards.First().LOYALTYIDNUMBER;
                var vckeySource          = memberOutSource.VirtualCards.First().VCKEY.ToString();
                var vckeyDestination     = memberOutDestination.VirtualCards.First().VCKEY.ToString();

                TestStep.Start("Get Account Summary from DB for Source Member", "Account Summary retrieved from DB");
                MemberAccountSummaryModel memberAccountSummaryOutDbSourceInitial = memController.GetMemberAccountSummaryFromDB(vckeySource);
                Assert.IsNotNull(memberAccountSummaryOutDbSourceInitial, "Account Summary could not be retrieved from DB");
                TestStep.Pass("Existing member was found", memberAccountSummaryOutDbSourceInitial.ReportDetail());

                TestStep.Start("Get Account Summary from DB for Destination Member", "Account Summary retrieved from DB");
                MemberAccountSummaryModel memberAccountSummaryOutDbDestinationInitial = memController.GetMemberAccountSummaryFromDB(vckeyDestination);
                Assert.IsNotNull(memberAccountSummaryOutDbDestinationInitial, "Account Summary could not be retrieved from DB");
                TestStep.Pass("Existing member was found", memberAccountSummaryOutDbDestinationInitial.ReportDetail());


                TestStep.Start($"Make HertzTransferPoints Call", "HertzTransferPoints call should return HertzTransferPoints object");
                HertzTransferPointsResponseModel memberTransferPoints = memController.HertzTransferPoints(loyaltyIdSource, "csadmin", points.ToString(),
                                                                                                          loyaltyIdDestination, "automation");
                Assert.IsNotNull(memberTransferPoints, "Expected populated HertzTransferPoints object, but HertzTransferPoints object returned was null");
                TestStep.Pass("HertzTransferPoints object was returned", memberTransferPoints.ReportDetail());

                TestStep.Start($"Verify CurrencyBalance of Source Member was decreased", "CurrencyBalance returned should be correct");
                MemberAccountSummaryModel memberAccountSummaryOutDbSourceFinal = memController.GetMemberAccountSummaryFromDB(vckeySource);
                Assert.IsNotNull(memberAccountSummaryOutDbSourceFinal, "Account Summary could not be retrieved from DB");
                Assert.AreEqual(memberAccountSummaryOutDbSourceInitial.CURRENCYBALANCE - points,
                                memberAccountSummaryOutDbSourceFinal.CURRENCYBALANCE,
                                $"CurrencyBalance wasn't decrease due TransferPoints");
                TestStep.Pass("CurrencyBalance response is as expcted", memberAccountSummaryOutDbSourceFinal.ReportDetail());

                TestStep.Start($"Verify CurrencyBalance of Destination Member was increased", "CurrencyBalance returned should be correct");
                MemberAccountSummaryModel memberAccountSummaryOutDbDestinationFinal = memController.GetMemberAccountSummaryFromDB(vckeyDestination);
                Assert.IsNotNull(memberAccountSummaryOutDbDestinationFinal, "Account Summary could not be retrieved from DB");
                Assert.AreEqual(memberAccountSummaryOutDbDestinationInitial.CURRENCYBALANCE + points,
                                memberAccountSummaryOutDbDestinationFinal.CURRENCYBALANCE,
                                $"CurrencyBalance wasn't decrease due TransferPoints");
                TestStep.Pass("CurrencyBalance response is as expcted", memberAccountSummaryOutDbDestinationFinal.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (LWServiceException ex)
            {
                TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" });
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Ejemplo n.º 5
0
        public void HertzAwardLoyaltyCurrency_Positive(MemberModel member, IHertzTier tier, string pointeventname, decimal points, bool useRanum)
        {
            MemberController memController   = new MemberController(Database, TestStep);
            PointController  pointController = new PointController(Database, TestStep);

            try
            {
                //Generate unique LIDs for each virtual card in the member
                member = memController.AssignUniqueLIDs(member);
                string ranum;

                TestStep.Start($"Make AddMember Call", "Member should be added successfully");
                MemberModel memberOut = memController.AddMember(member);
                AssertModels.AreEqualOnly(member, memberOut, MemberModel.BaseVerify);
                TestStep.Pass("Member was added successfully and member object was returned", memberOut.ReportDetail());

                VirtualCardModel vc = memberOut.VirtualCards.First();
                //Transactions are added to test the API with ranum and also to test the negative points scenario
                TestStep.Start($"Add Transaction to the member", "Transactions added successfully");
                vc.Transactions = TxnHeaderController.GenerateRandomTransactions(vc, tier.ParentProgram, 1, 200);
                if (useRanum)
                {
                    ranum = vc.Transactions.Select(x => x.A_RANUM).First();
                }
                else
                {
                    ranum = null;
                }
                Assert.IsNotNull(vc.Transactions, "Expected populated transaction object, but transaction object returned was null");
                TestStep.Pass("Transaction added to the member", vc.Transactions.ReportDetail());

                TestStep.Start("Update Existing Member with added transaction", "Member object should be returned from UpdateMember call");
                MemberModel updatedMember = memController.UpdateMember(memberOut);
                Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned");
                TestStep.Pass("Member object returned from UpdateMember API call", updatedMember.ReportDetail());

                TestStep.Start("Find PointEventId in database", $"PointEventId should be found {pointeventname}");
                IEnumerable <PointEventModel> pointEvent = pointController.GetPointEventIdsFromDb(pointeventname);
                decimal pointEventId = pointEvent.Select(x => x.POINTEVENTID).First();
                Assert.IsTrue(pointEvent.Any(x => x.NAME.Equals(pointeventname)), "Expected pointevent name was not found in database");
                TestStep.Pass("Pointevent name was found in the Database", pointEvent.ReportDetail());

                var loyaltyId = memberOut.VirtualCards.First().LOYALTYIDNUMBER;
                TestStep.Start($"Make HertzAwardLoyaltyCurrency Call", "HertzAwardLoyaltyCurrency call should return HertzAwardLoyaltyCurrency object");
                HertzAwardLoyaltyCurrencyResponseModel memberAwardLoyaltyCurrency = memController.HertzAwardLoyaltyCurrency(loyaltyId, "csadmin", points, Convert.ToInt64(pointEventId), "automation", ranum);
                Assert.IsNotNull(memberAwardLoyaltyCurrency, "Expected populated AwardLoyaltyCurrency object, but AwardLoyaltyCurrency object returned was null");
                TestStep.Pass("HertzAwardLoyaltyCurrency object was returned", memberAwardLoyaltyCurrency.ReportDetail());

                var vckey = memberOut.VirtualCards.First().VCKEY.ToString();
                TestStep.Start("Get Account Summary from DB", "Account Summary retrieved from DB");
                MemberAccountSummaryModel memberAccountSummaryOutDb = memController.GetMemberAccountSummaryFromDB(vckey);
                Assert.IsNotNull(memberAccountSummaryOutDb, "Account Summary could not be retrieved from DB");
                TestStep.Pass("Existing member was found", memberAccountSummaryOutDb.ReportDetail());

                TestStep.Start("Verify Points awarded matches the points in DB", "Points awarded matches the points in DB");
                IEnumerable <PointTransactionModel> dbPointTransaction = pointController.GetPointTransactionsFromDb(decimal.Parse(vckey)).ToList();
                Assert.IsNotNull(dbPointTransaction, "Expected populated PointTransaction object from database query, but PointTransaction object returned was null");
                Assert.AreEqual(points, dbPointTransaction.Where(x => x.POINTEVENTID == pointEventId && x.POINTS == points).Select(x => x.POINTS).First(), $"Points awarded does not match database points{dbPointTransaction.Select(x => x.POINTS)} ");
                TestStep.Pass("Points awarded are added to the DB", dbPointTransaction.ReportDetail());

                TestStep.Start($"Verify CurrencyBalance of HertzAwardLoyaltyCurrency", "CurrencyBalance returned should be correct");
                Assert.AreEqual(dbPointTransaction.Sum(x => x.POINTS), memberAwardLoyaltyCurrency.CURRENCYBALANCE, $"CurrencyBalance does not match database points{dbPointTransaction.Select(x => x.POINTS)} ");
                Assert.AreEqual(0, memberAwardLoyaltyCurrency.CURRENCYTONEXTTIER, "CurrencyToNextTier does not match 0");
                TestStep.Pass("CurrencyBalance response is as expcted", memberAwardLoyaltyCurrency.ReportDetail());

                TestStep.Start("Compare Account Summary between DB and API", "Account Summary matches");
                AssertModels.AreEqualWithAttribute(memberAccountSummaryOutDb, memberAwardLoyaltyCurrency);
                TestStep.Pass("Account Summary matches between DB and API", memberAccountSummaryOutDb.ReportDetail());

                TestStep.Start($"Verify response of HertzAwardLoyaltyCurrency for GPR", "Response returned should be correct");
                if (tier.ParentProgram.EarningPreference == "N1")
                {
                    Assert.AreEqual(tier.RentalsToNextTier - vc.Transactions.Count(), memberAwardLoyaltyCurrency.RENTALSTONEXTTIER, $"RentalsToNextTier does not match {tier.RentalsToNextTier - vc.Transactions.Count()}");
                    Assert.AreEqual(tier.RevenueToNextTier - vc.Transactions.First().A_GRSREVNAMT, memberAwardLoyaltyCurrency.REVENUETONEXTTIER, $"RentalsToNextTier does not match {tier.RevenueToNextTier - vc.Transactions.First().A_GRSREVNAMT}");
                    Assert.AreEqual(vc.Transactions.Count(), memberAwardLoyaltyCurrency.TOTALRENTALSYTD, $"TotalRentalsYTD does not match {memberAwardLoyaltyCurrency.TOTALRENTALSYTD}");
                    Assert.AreEqual(vc.Transactions.Sum(x => x.A_GRSREVNAMT), memberAwardLoyaltyCurrency.TOTALREVENUEYTD, $"TotalRentalsYTD does not match {memberAwardLoyaltyCurrency.TOTALREVENUEYTD}");
                    Assert.AreEqual("Gold", memberAwardLoyaltyCurrency.CURRENTTIERNAME, $"CurrentTierName does not match {memberAwardLoyaltyCurrency.CURRENCYBALANCE}");
                }
                TestStep.Pass("HertzAwardLoyaltyCurrency response is as expcted for GPR", memberAwardLoyaltyCurrency.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (LWServiceException ex)
            {
                TestStep.Fail(ex.Message, new[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.ErrorMessage}" });
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }