Exemplo n.º 1
0
 public AwardLoyaltyCurrencyResponseModel AwardLoyaltyCurrency(string loyaltyID, decimal points)
 {
     using (ConsoleCapture capture = new ConsoleCapture())
     {
         AwardLoyaltyCurrencyResponseModel awardLoyaltyCurrencyOut = default;
         try
         {
             double   time                = 0;
             string   changedBy           = "oagwuegbo";
             long     pointeventID        = 6263265;
             DateTime pointExpirationDate = DateTime.Now.AddMonths(18);
             var      lwAwardLoyalty      = lwSvc.HertzAwardLoyaltyCurrency(loyaltyID, changedBy, points, pointeventID, "Automated Appeasement", null, null, out time);
             awardLoyaltyCurrencyOut = LODConvert.FromLW <AwardLoyaltyCurrencyResponseModel>(lwAwardLoyalty);
         }
         catch (LWClientException ex)
         {
             throw new LWServiceException(ex.Message, ex.ErrorCode);
         }
         catch (Exception ex)
         {
             throw new LWServiceException(ex.Message, -1);
         }
         finally
         {
             stepContext.AddAttachment(new Attachment("AwardLoyaltyCurrency", capture.Output, Attachment.Type.Text));
         }
         return(awardLoyaltyCurrencyOut);
     }
 }
        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();
            }
        }
Exemplo n.º 3
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();
            }
        }