Beispiel #1
0
        private static TxnHeaderModel[] GenerateTxns(int num, decimal cdp, IHertzTier tierIn, string resCountry = "US", string chkOutLocNum = "06", string chkOutAreaNum = "01474", string chkoutLocId = null)
        {
            List <TxnHeaderModel> output = new List <TxnHeaderModel>();

            for (int i = 0; i < num; i++)
            {
                output.Add(TxnHeaderController.GenerateTransaction("", checkInDate: DateTime.Now.AddDays(2).Comparable(),
                                                                   checkOutDate: DateTime.Now.AddDays(1).Comparable(),
                                                                   bookDate: DateTime.Now.Comparable(),
                                                                   program: tierIn.ParentProgram,
                                                                   RSDNCTRYCD: resCountry, HODIndicator: 0, rentalCharges: Amount(i), CDP: cdp, chkoutlocnum: chkOutLocNum, chkoutareanum: chkOutAreaNum, chkoutlocid: chkoutLocId));
            }
            return(output.ToArray());
        }
        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();
            }
        }
Beispiel #3
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();
            }
        }