示例#1
0
        public RewardDefModel GetRandomRewardDef(IHertzProgram program)
        {
            string         query     = $"select * from {RewardDefModel.TableName} sample(50) rd where rd.smallimagefile = '{program.EarningPreference}' and rd.active = '1'";
            RewardDefModel rewardDef = dbContext.QuerySingleRow <RewardDefModel>(query);

            return(rewardDef);
        }
示例#2
0
        public void AddMemberRewards_Negative(MemberModel testMember, IHertzProgram program, int errorCode, string errorMessage)
        {
            MemberController      memController = new MemberController(Database, TestStep);
            TxnHeaderController   txnController = new TxnHeaderController(Database, TestStep);
            List <TxnHeaderModel> txnList       = new List <TxnHeaderModel>();
            int              daysAfterCheckOut  = 1;
            DateTime         checkOutDt         = DateTime.Now;
            DateTime         checkInDt          = checkOutDt.AddDays(daysAfterCheckOut);
            DateTime         origBkDt           = checkOutDt;
            RewardController rewardController   = new RewardController(Database, TestStep);
            RewardDefModel   reward             = rewardController.GetRandomRewardDef(program);
            decimal          points             = Math.Round(Math.Max(0, (reward.HOWMANYPOINTSTOEARN - (reward.HOWMANYPOINTSTOEARN * 0.5M))));
            long             pointeventid       = 6263265;

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

                string loyaltyID   = testMember.VirtualCards[0].LOYALTYIDNUMBER;
                string alternateID = testMember.ALTERNATEID;
                string vckey       = testMember.VirtualCards[0].VCKEY.ToString();

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

                TestStep.Start($"Make AwardLoyaltyCurrency Call", $"Member should be updated successfully and earn {points} points");
                HertzAwardLoyaltyCurrencyResponseModel currencyOut = memController.HertzAwardLoyaltyCurrency(loyaltyID, "oagwuegbo", points, pointeventid, "Automated Appeasement", null);
                decimal pointsOut = memController.GetPointSumFromDB(loyaltyID);
                Assert.AreEqual(points, pointsOut, "Expected points and pointsOut values to be equal, but the points awarded to the member and the point summary taken from the DB are not equal");
                Assert.AreEqual(currencyOut.CurrencyBalance, points, "Expected point value put into AwardLoyaltyCurrency API Call to be equal to the member's current balance, but the point values are not equal");
                TestStep.Pass("Points are successfully awarded");

                TestStep.Start("Make AddMemberReward Call", "AddMemberReward Call is unsuccessful and throws an exception");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.AddMemberReward(loyaltyID, reward.CERTIFICATETYPECODE, testMember.MemberDetails.A_EARNINGPREFERENCE), "Excepted LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("AddMemberReward Call is unsuccessful and error codes are validated");
            }
            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();
            }
        }
示例#3
0
 public Tier(IHertzProgram parent, string Name, string Code, decimal EarningRateModifier, int rentalsToNextTier, int revenueToNextTier)
 {
     this.ParentProgram       = parent;
     this.Name                = Name;
     this.Code                = Code;
     this.EarningRateModifier = EarningRateModifier;
     this.RentalsToNextTier   = rentalsToNextTier;
     this.RevenueToNextTier   = revenueToNextTier;
     this.Rank                = 1;
 }
示例#4
0
        private static TxnHeader[] GenerateTxns(int num, string cdp, IHertzProgram programIn, string resCountry = "US")
        {
            List <TxnHeader> output = new List <TxnHeader>();

            for (int i = 0; i < num; i++)
            {
                output.Add(TxnHeader.Generate("", checkInDate: DateTime.Now.AddDays(2).Comparable(),
                                              checkOutDate: DateTime.Now.AddDays(1).Comparable(),
                                              bookDate: DateTime.Now.Comparable(),
                                              program: programIn,
                                              RSDNCTRYCD: resCountry, HODIndicator: 0, rentalCharges: Amount(i)));
            }
            return(output.ToArray());
        }
示例#5
0
        public void GetMemberRewards_Negative(MemberModel testMember, IHertzProgram program, int errorCode, string errorMessage)
        {
            MemberController      memController = new MemberController(Database, TestStep);
            List <TxnHeaderModel> txnList       = new List <TxnHeaderModel>();
            int              daysAfterCheckOut  = 1;
            DateTime         checkOutDt         = new DateTime(2020, 03, 12);
            DateTime         checkInDt          = checkOutDt.AddDays(daysAfterCheckOut);
            DateTime         origBkDt           = checkOutDt;
            RewardController rewardController   = new RewardController(Database, TestStep);
            RewardDefModel   reward             = rewardController.GetRandomRewardDef(program);
            decimal          points             = reward.HOWMANYPOINTSTOEARN;

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

                string loyaltyID   = testMember.VirtualCards[0].LOYALTYIDNUMBER;
                string alternateID = testMember.ALTERNATEID;
                string vckey       = testMember.VirtualCards[0].VCKEY.ToString();

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

                TestStep.Start("GetMemberRewards API is Called", "GetMemberRewards API Unsucessfully Returns");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetMemberRewards(loyaltyID), "Excepted LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("GetMemberRewards Return is Validated");
            }
            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 CancelMemberReward_Positive(MemberModel createMember, IHertzProgram program)
        {
            MemberController      memberController = new MemberController(Database, TestStep);
            TxnHeaderController   txnController    = new TxnHeaderController(Database, TestStep);
            List <TxnHeaderModel> txnList          = new List <TxnHeaderModel>();
            int              daysAfterCheckOut     = 1;
            DateTime         checkOutDt            = new DateTime(2020, 01, 31);
            DateTime         checkInDt             = checkOutDt.AddDays(daysAfterCheckOut);
            DateTime         origBkDt         = checkOutDt;
            RewardController rewardController = new RewardController(Database, TestStep);
            RewardDefModel   reward           = rewardController.GetRandomRewardDef(program);
            decimal          points           = reward.HOWMANYPOINTSTOEARN;
            decimal          pointsOutDb      = 0;

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

                string loyaltyID   = createMember.VirtualCards[0].LOYALTYIDNUMBER;
                string alternateID = createMember.ALTERNATEID;
                string vckey       = createMember.VirtualCards[0].VCKEY.ToString();

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

                if (program.EarningPreference == HertzLoyalty.GoldPointsRewards.EarningPreference)
                {
                    TestStep.Start($"Make UpdateMember Call", $"Member should be updated successfully and earn {points} points");
                    TxnHeaderModel txn = TxnHeaderController.GenerateTransaction(loyaltyID, checkInDt, checkOutDt, origBkDt, null, program, null, "US", points, null, null, "N", "US", null);
                    txnList.Add(txn);
                    createMember.VirtualCards[0].Transactions = txnList;
                    MemberModel updatedMember = memberController.UpdateMember(createMember);
                    txnList.Clear();
                    Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned");
                    TestStep.Pass("Member was successfully updated");
                }
                else //Dollar and Thrifty Members Cannot be updated with the UpdateMember API so we use the HertzAwardLoyatlyCurrency API instead
                {
                    TestStep.Start($"Make AwardLoyaltyCurrency Call", $"Member should be updated successfully and earn {points} points");
                    AwardLoyaltyCurrencyResponseModel currencyOut = memberController.AwardLoyaltyCurrency(loyaltyID, points);
                    pointsOutDb = memberController.GetPointSumFromDB(loyaltyID);
                    Assert.AreEqual(points, pointsOutDb, "Expected points and pointsOut values to be equal, but the points awarded to the member and the point summary taken from the DB are not equal");
                    Assert.AreEqual(currencyOut.CurrencyBalance, points, "Expected point value put into AwardLoyaltyCurrency API Call to be equal to the member's current balance, but the point values are not equal");
                    TestStep.Pass("Points are successfully awarded");
                }

                TestStep.Start("Make AddMemberReward Call", "AddMemberReward Call is successfully made");
                AddMemberRewardsResponseModel rewardResponse = memberController.AddMemberReward(loyaltyID, reward.CERTIFICATETYPECODE, createMember.MemberDetails.A_EARNINGPREFERENCE);
                Assert.IsNotNull(rewardResponse, "Expected populated AddMemberRewardsResponse object from AddMemberRewards call, but AddMemberRewardsResponse object returned was null");
                TestStep.Pass("Reward is added.");

                TestStep.Start("Validate that Member has Reward", "Member is found with Reward");
                IEnumerable <MemberRewardsModel> membersRewardOut = memberController.GetMemberRewardsFromDB(memberOut.IPCODE, rewardResponse.MemberRewardID);
                Assert.IsNotNull(membersRewardOut, "Expected populated MemberRewards object from query, but MemberRewards object returned was null");
                Assert.Greater(membersRewardOut.Count(), 0, "Expected at least one MemberReward to be returned from query");
                TestStep.Pass("Member Reward Found");

                var memberRewardId = rewardResponse.MemberRewardID.ToString();
                TestStep.Start("Call CancelMemberreward API", "Member reward is cancelled");
                var currencyBalance = memberController.CancelMemberReward(memberRewardId, null, null, null, null, null, null, null);
                Assert.IsNotNull(currencyBalance, "Expected Member Point Balance");
                TestStep.Pass("Successfully cancelled member reward");

                TestStep.Start("Get Total points from PointTransaction table in DB", "Expected Total points for the member");
                pointsOutDb = memberController.GetPointSumFromDB(loyaltyID);
                Assert.IsNotNull(pointsOutDb, "Expected non null point value");
                Assert.AreEqual(currencyBalance, pointsOutDb, "Expected API Point Balance after cancellation to be equal to sum of points from DB");
                TestStep.Pass("Point successfully credited to member");
            }
            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();
            }
        }
示例#7
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 static TxnHeaderModel GenerateTransaction(string loyaltyId,
                                                         DateTime?checkInDate        = null, DateTime?checkOutDate = null, DateTime?bookDate      = null,
                                                         decimal?CDP                 = null, IHertzProgram program = null, short?HODIndicator     = 0, string RSDNCTRYCD = "US",
                                                         decimal?rentalCharges       = 0M, string contractTypeCode = null, decimal?contractNumber = null, string sacCode       = null,
                                                         string checkoutWorldWideISO = null, string promNum        = null, string chkoutlocnum    = "06", string chkoutareanum = "01474", string chkoutlocid = null)
        {
            if (program == null)
            {
                program = HertzLoyalty.GoldPointsRewards;
            }

            TxnHeaderModel txn = new TxnHeaderModel()
            {
                A_LYLTYMEMBERNUM            = loyaltyId,
                A_CHKINDT                   = checkInDate,
                A_RANUM                     = RANUMController.Generate(),
                A_RESVID                    = null,
                A_CHKINLOCNUM               = "06",
                A_PROMNUM                   = promNum,
                A_VCHRNUM                   = null,
                A_CHKINAREANUM              = "01474",
                A_CHKOUTDT                  = checkOutDate,
                A_CHKOUTLOCNUM              = chkoutlocnum,
                A_CHKOUTAREANUM             = chkoutareanum,
                A_FTPTNRNUM                 = program.A_FTPTNRNUM,
                A_CHKOUTCITYCD              = null,
                A_CHKOUTWORLDWIDERGNCTRYISO = checkoutWorldWideISO ?? RSDNCTRYCD,
                A_CHKOUTWWDSTPROVCD         = StrongRandom.NumericString(2),
                A_ORIGBOOKDT                = bookDate,
                A_CHRGVEHCLSCD              = StrongRandom.NumericString(1),
                A_CRCARDTYPECD              = "0",
                A_RQSTSIPPCD                = null,
                A_GEOLOCTYPECD              = null,
                A_RASRCCD                   = program.A_RASRCCD,
                A_INTRNLNETRTGCD            = null,
                A_TRAVLPRPSTYPECD           = null,
                A_MKTGRTANALCD              = null,
                A_CRNCYISOCD                = null,
                A_RENTALTYPE                = null,
                A_DAYSCHRGQTY               = 1,
                A_LDWCDWCHRGAMT             = rentalCharges,
                A_DISCAMT                   = 0M,
                A_NWEXECSAMT                = 0M,
                A_PAITOTCHRGAMT             = 0M,
                A_ADDLAUTHDRVRCHRGAMT       = 0M,
                A_AGEDIFFCHRGAMT            = 0M,
                A_ADDLSRVCCHRGAMT           = 0M,
                A_SBTOTAMT                  = 0M,
                A_TOTCHRGAMT                = 0M,
                A_LISTOTCHRGAMT             = 0M,
                A_CHILDSEATTOTAMT           = 0M,
                A_ITVALLFEETOTAMT           = 0M,
                A_GARSPECLEQMNTAMT          = 0M,
                A_GRSREVNAMT                = rentalCharges,
                A_MISCGRPAMT                = 0M,
                A_NVGTNSYSTOTAMT            = 0M,
                A_SATLTRADIOTOTAMT          = 0M,
                A_REFUELINGOPTCD            = StrongRandom.AlphaString(1),
                A_REFUELINGCHRGAMT          = 0M,
                A_TPTOTCHRGAMT              = 0M,
                A_TRANSACTIONSTATE          = "MX",
                A_RESCHANNEL                = StrongRandom.AlphaString(2),
                A_TOTEXPIRINGEUPGRADES      = null,
                A_TOTEUPGRADES              = null,
                A_RARTTYPECD                = null,
                A_RESVRTTYPECD              = null,
                A_RTCATCD                   = null,
                A_RTCLSNCD                  = null,
                A_RTFMLYCD                  = null,
                A_SACCD                     = sacCode ?? "N",
                A_RSDNCTRYCD                = RSDNCTRYCD,
                A_GOLDRNTALIND              = "Y",
                A_TXNDATE                   = checkInDate ?? DateTime.Now.Comparable(),
                A_TXNHEADERID               = null,
                A_CHKOUTTM                  = null,
                A_TRANSTYPE                 = program.A_TRANSTYPE,
                A_RNTINGCTRYCRNCYUSDEXCHRT  = 1M,
                A_CORPDISCPRGID             = CDP ?? Convert.ToDecimal(StrongRandom.Next(0, 9)),
                A_CONTRACTTYPECD            = contractTypeCode ?? StrongRandom.NumericString(3),
                A_CONTRACTNUM               = contractNumber ?? Convert.ToDecimal(StrongRandom.Next(1, 999999)),
                A_BRANDID                   = null,
                A_CREDITCARDID              = null,
                A_TXNMASKID                 = null,
                A_TXNNUMBER                 = null,
                A_TXNREGISTERNUMBER         = StrongRandom.NumericString(1),
                A_TXNSTOREID                = StrongRandom.Next(1, 9),
                A_TXNTYPEID                 = StrongRandom.Next(1, 9),
                A_TXNAMOUNT                 = 0M,
                A_TXNQUALPURCHASEAMT        = 0M,
                A_QUALTOTAMT                = 0M,
                A_TXNDISCOUNTAMOUNT         = 0M,
                A_TXNEMPLOYEEID             = StrongRandom.NumericString(2),
                A_TXNCHANNEL                = StrongRandom.NumericString(2),
                A_TXNORIGINALTXNROWKEY      = null,
                A_TXNCREDITSUSED            = null,
                A_HODINDICATOR              = HODIndicator,
                A_CHKOUTLOCATIONID          = chkoutlocid
            };

            return(txn);
        }
        public static List <TxnHeaderModel> GenerateRandomTransactions(VirtualCardModel vc, IHertzProgram htzProgram, int numTransactions = 1, decimal amount = 100M)
        {
            List <TxnHeaderModel> output = new List <TxnHeaderModel>();

            for (int i = 0; i < numTransactions; i++)
            {
                output.Add(GenerateTransaction(vc.LOYALTYIDNUMBER, checkInDate: DateTime.Now, checkOutDate: DateTime.Now.AddDays(-1), program: htzProgram, rentalCharges: amount));
            }
            return(output);
        }
示例#10
0
        public void GetMemberRewards_Positive(MemberModel testMember, IHertzProgram program)
        {
            MemberController      memController = new MemberController(Database, TestStep);
            List <TxnHeaderModel> txnList       = new List <TxnHeaderModel>();
            int              daysAfterCheckOut  = 1;
            DateTime         checkOutDt         = new DateTime(2020, 03, 12);
            DateTime         checkInDt          = checkOutDt.AddDays(daysAfterCheckOut);
            DateTime         origBkDt           = checkOutDt;
            RewardController rewardController   = new RewardController(Database, TestStep);
            RewardDefModel   reward             = rewardController.GetRandomRewardDef(program);
            decimal          points             = reward.HOWMANYPOINTSTOEARN;

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

                string loyaltyID   = testMember.VirtualCards[0].LOYALTYIDNUMBER;
                string alternateID = testMember.ALTERNATEID;
                string vckey       = testMember.VirtualCards[0].VCKEY.ToString();

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

                TestStep.Start($"Make AwardLoyaltyCurrency Call", $"Member should be updated successfully and earn {points} points");
                AwardLoyaltyCurrencyResponseModel currencyOut = memController.AwardLoyaltyCurrency(loyaltyID, points);
                decimal pointsOut = memController.GetPointSumFromDB(loyaltyID);
                Assert.AreEqual(points, pointsOut, "Expected points and pointsOut values to be equal, but the points awarded to the member and the point summary taken from the DB are not equal");
                Assert.AreEqual(currencyOut.CurrencyBalance, points, "Expected point value put into AwardLoyaltyCurrency API Call to be equal to the member's current balance, but the point values are not equal");
                TestStep.Pass("Points are successfully awarded");

                TestStep.Start("Make AddMemberReward Call", "AddMemberReward Call is successfully made");
                AddMemberRewardsResponseModel rewardResponse = memController.AddMemberReward(loyaltyID, reward.CERTIFICATETYPECODE, testMember.MemberDetails.A_EARNINGPREFERENCE);
                Assert.IsNotNull(rewardResponse, "Expected populated AddMemberRewardsResponse object from AddMemberRewards call, but AddMemberRewardsResponse object returned was null");
                TestStep.Pass("Reward is added.");

                TestStep.Start("Validate that Member has Reward in DB", "Member is found with Reward");
                IEnumerable <MemberRewardsModel> membersRewardOut = memController.GetMemberRewardsFromDB(memberOut.IPCODE, null);
                Assert.IsNotNull(membersRewardOut, "Expected populated MemberRewards object from query, but MemberRewards object returned was null");
                //Assert.Greater(membersRewardOut.Count(), 0, "Expected at least one MemberReward to be returned from query");
                TestStep.Pass("Member Reward Found");

                TestStep.Start("GetMemberRewards API is Called", "GetMemberRewards API Sucessfully Returns");
                List <GetMemberRewardsResponseModel> getMROut = memController.GetMemberRewards(loyaltyID);
                Assert.AreEqual(membersRewardOut.Count(), getMROut.Count);
                TestStep.Pass("GetMemberRewards Return is Validated");
            }
            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();
            }
        }
示例#11
0
        //[TestCaseSource(typeof(AddMemberRewardsData), "FlashSaleScenarios")]
        public void AddMemberRewards_FlashSale(MemberModel testMember, string[] typeCodes, decimal points, IHertzProgram program)
        {
            MemberController    memController = new MemberController(Database, TestStep);
            TxnHeaderController txnController = new TxnHeaderController(Database, TestStep);
            int      daysAfterCheckOut        = 1;
            DateTime checkOutDt   = new DateTime(2020, 02, 25);
            DateTime checkInDt    = checkOutDt.AddDays(daysAfterCheckOut);
            DateTime origBkDt     = checkOutDt;
            long     pointeventid = 6263265;

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

                string loyaltyID   = testMember.VirtualCards[0].LOYALTYIDNUMBER;
                string alternateID = testMember.ALTERNATEID;
                string vckey       = testMember.VirtualCards[0].VCKEY.ToString();

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

                TestStep.Start($"Make AwardLoyaltyCurrency Call", $"Member should be updated successfully and earn {points} points");
                HertzAwardLoyaltyCurrencyResponseModel currencyOut = memController.HertzAwardLoyaltyCurrency(loyaltyID, "oagwuegbo", points, pointeventid, "Automated Appeasement", null);
                decimal pointsOut = memController.GetPointSumFromDB(loyaltyID);
                Assert.AreEqual(points, pointsOut, "Expected points and pointsOut values to be equal, but the points awarded to the member and the point summary taken from the DB are not equal");
                Assert.AreEqual(currencyOut.CurrencyBalance, points, "Expected point value put into AwardLoyaltyCurrency API Call to be equal to the member's current balance, but the point values are not equal");
                TestStep.Pass("Points are successfully awarded");

                TestStep.Start("Redeem all the rewards in the list", "Member should be able to redeem all rewards");
                foreach (string certificateTypeCode in typeCodes)
                {
                    AddMemberRewardsResponseModel rewardResponse = memController.AddMemberReward(loyaltyID, certificateTypeCode, testMember.MemberDetails.A_EARNINGPREFERENCE);
                    Assert.IsNotNull(rewardResponse, "Expected populated AddMemberRewardsResponse object from AddMemberRewards call, but AddMemberRewardsResponse object returned was null");
                }
                TestStep.Pass("Member is able to redeem all rewards");
            }
            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();
            }
        }
示例#12
0
        public void MultiThreadingTestsPositive(MemberModel member1, MemberModel member2)
        {
            MemberController      memController = new MemberController(Database, TestStep);
            List <TxnHeaderModel> txnList1      = new List <TxnHeaderModel>();
            List <TxnHeaderModel> txnList2      = new List <TxnHeaderModel>();

            int           daysAfterCheckOut = 1;
            DateTime      checkOutDt        = DateTime.Now;
            DateTime      checkInDt         = checkOutDt.AddDays(daysAfterCheckOut);
            DateTime      origBkDt          = checkOutDt;
            IHertzProgram program           = HertzLoyalty.GoldPointsRewards;
            decimal       points            = 10;

            try
            {
                TestStep.Start("Assign Members unique LoyaltyIds for each virtual card", "Unique LoyaltyIds should be assigned");
                member1 = memController.AssignUniqueLIDs(member1);
                member2 = memController.AssignUniqueLIDs(member2);
                TestStep.Pass("Unique LoyaltyIds assigned", member1.VirtualCards.ReportDetail());

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

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

                string  loyaltyID1 = member1.VirtualCards[0].LOYALTYIDNUMBER;
                string  loyaltyID2 = member2.VirtualCards[0].LOYALTYIDNUMBER;
                decimal?cdp        = null;
                for (int x = 0; x < 50; x++)
                {
                    TestStep.Start($"Make UpdateMember Call", $"Members {loyaltyID1} and {loyaltyID2} should be updated successfully and earn {points} points");
                    TxnHeaderModel txn1 = TxnHeaderController.GenerateTransaction(loyaltyID1, checkInDt, checkOutDt, origBkDt, cdp, program, null, "US", points, null, null, "N", "US", null);
                    txnList1.Add(txn1);
                    member1.VirtualCards[0].Transactions = txnList1;
                    TxnHeaderModel txn2 = TxnHeaderController.GenerateTransaction(loyaltyID2, checkInDt, checkOutDt, origBkDt, cdp, program, null, "US", points, null, null, "N", "US", null);
                    txnList2.Add(txn2);
                    member2.VirtualCards[0].Transactions = txnList2;

                    MemberModel updatedMember  = memController.UpdateMember(member1);
                    MemberModel updatedMember2 = memController.UpdateMember(member2);
                    txnList1.Clear();
                    txnList2.Clear();
                    TestStep.Pass("Member was successfully updated");
                }
            }
            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();
            }
        }