public void AddMember_Negative(MemberModel member, bool generateLID, int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

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

                TestStep.Start($"Make AddMember Call", $"Add member call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.AddMember(member), "Excepted LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("Add Member call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
        public void CancelMemberReward_Negative(string memberRewardId, int errorCode, string errorMessage)
        {
            try
            {
                MemberController memberController = new MemberController(Database, TestStep);

                TestStep.Start("Make CancelMemberReward Call", $"CancelMemberReward call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memberController.CancelMemberReward(memberRewardId, null, null, null, null, null, null, null),
                                                                                  "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                TestStep.Pass("CancelMemberReward call threw expected exception", exception.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }
        public void GetLoyaltyEventNamesTestCaseTest(int errorCode, string errorMessage)
        {
            LWController lwController = new LWController(Database, TestStep);

            try
            {
                TestStep.Start("Make GetLoyaltyEventNames Call", $"GetLoyaltyEventNames call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => lwController.GetLoyaltyEventNames(string.Empty),
                                                                                  "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                TestStep.Pass("GetLoyaltyEventNames call threw expected exception", exception.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }
Beispiel #4
0
        public void HertzAwardLoyaltyCurrency_Negative(MemberModel member, string token, int errorCode, string errorMessage, string memLoyaltyID = null)
        {
            MemberController memController = new MemberController(Database, TestStep);

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

                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());

                var loyaltyId = memLoyaltyID ?? memberOut.VirtualCards.First().LOYALTYIDNUMBER;
                TestStep.Start($"Make HertzValidateToken Call", $"Add member call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.HertzValidateToken(loyaltyId, token), "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzValidateToken call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #5
0
        public void HertzAddUpdateCsAgent_Negative(CsAgentModel csAgent, string agentRoleName, int errorCode, string errorMessage)
        {
            CsAgentController CsAgentController = new CsAgentController(Database, TestStep);

            try
            {
                CsAgentRoleModel csAgentRole   = CsAgentController.GetFromDBRoleID(agentRoleName);
                decimal          caAgentRoleID = csAgentRole.ID;
                csAgent.ROLEID = caAgentRoleID;
                TestStep.Start($"Make HertzAwardLoyaltyCurrency Call", $"Add member call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => CsAgentController.AddCsAgent(csAgent));
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzAwardLoyaltyCurrency call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
        public void HTZUpdateTier_Negative(string csAgent, int errorCode, string errorMessage)
        {
            LWController lwController = new LWController(Database, TestStep);

            try
            {
                TestStep.Start($"Make HertzGetCSAgent Call", $"HertzGetCSAgent call should throw exception with error code = {errorCode}");
                LWServiceException exception =
                    Assert.Throws <LWServiceException>(() =>
                                                       lwController.HertzGetCSAgent(csAgent),
                                                       "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzGetCSAgent call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
        public void GetMemberPromotion_Negative(string loyaltyId, int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                if (loyaltyId == null)
                {
                    TestStep.Start("Make GetMemberPromotions Call", $"GetMemberPromotions call should throw exception with error code = {errorCode}");
                    LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetMemberPromotion(loyaltyId, null, null, null, null, null, null, null),
                                                                                      "Expected LWServiceException, exception was not thrown.");
                    Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                    Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                    TestStep.Pass("GetMemberPromotions call threw expected exception", exception.ReportDetail());
                }
                else if (string.Equals(loyaltyId, string.Empty))
                {
                    TestStep.Start("Get Existing Member without promotion from the database", "Existing member should be found");
                    MemberModel dbMember = memController.GetRandomMemberDBForMemberPromotion(MemberModel.Status.Active);
                    IEnumerable <MemberPromotionModel> dbMemPromo = memController.GetMemberPromotionsFromDB(memberId: dbMember.IPCODE);
                    Assert.IsNotNull(dbMember, "Member could not be retrieved from DB");
                    Assert.IsNotNull(dbMemPromo, "MemberPromotion could not be retrieved from DB");
                    TestStep.Pass("Existing member without promotion was found", dbMember.ReportDetail());

                    loyaltyId = dbMember.VirtualCards.First().LOYALTYIDNUMBER;
                    TestStep.Start("Make GetMemberPromotions Call", $"GetMemberPromotions call should throw exception with error code = {errorCode}");
                    LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetMemberPromotion(loyaltyId, null, null, null, null, null, null, null),
                                                                                      "Expected LWServiceException, exception was not thrown.");
                    Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                    Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                    TestStep.Pass("GetMemberPromotions call threw expected exception", exception.ReportDetail());
                }
                else
                {
                    TestStep.Start("Make GetMemberPromotions Call", $"GetMemberPromotions call should throw exception with error code = {errorCode}");
                    LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetMemberPromotion(loyaltyId, null, null, null, null, null, null, null),
                                                                                      "Expected LWServiceException, exception was not thrown.");
                    Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                    Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                    TestStep.Pass("GetMemberPromotions call threw expected exception", exception.ReportDetail());
                }
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #8
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();
            }
        }
        public void HertzTransferPoints_Negative(MemberModel memberSource, MemberModel memberDestination,
                                                 int errorCode, string errorMessage, string points, string csagent, string reasonCode)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                MemberModel memberOutSource = null;
                if (memberSource != null)
                {
                    //Generate unique LIDs for each virtual card in the member
                    memberSource = memController.AssignUniqueLIDs(memberSource);
                    TestStep.Start($"Make AddMember Call", "Member should be added successfully");
                    memberOutSource = memController.AddMember(memberSource);
                    AssertModels.AreEqualOnly(memberSource, memberOutSource, MemberModel.BaseVerify);
                    TestStep.Pass("Member was added successfully and member object was returned", memberOutSource.ReportDetail());
                }
                MemberModel memberOutDest = null;
                if (memberDestination != null)
                {
                    memberDestination = memController.AssignUniqueLIDs(memberDestination);
                    TestStep.Start($"Make AddMember Call", "Member should be added successfully");
                    memberOutDest = memController.AddMember(memberDestination);
                    AssertModels.AreEqualOnly(memberDestination, memberOutDest, MemberModel.BaseVerify);
                    TestStep.Pass("Member was added successfully and member object was returned", memberOutDest.ReportDetail());
                }
                var loyaltyIdSource      = memberOutSource?.VirtualCards?.First().LOYALTYIDNUMBER ?? "";
                var loyaltyIdDestination = memberOutDest?.VirtualCards?.First().LOYALTYIDNUMBER ?? "";

                TestStep.Start($"Make HertzTransferPoints Call", $"HertzTransferPoints call should throw exception with error code = {errorCode}");
                LWServiceException exception =
                    Assert.Throws <LWServiceException>(() =>
                                                       memController.HertzTransferPoints(loyaltyIdSource, csagent, points,
                                                                                         loyaltyIdDestination, reasonCode),
                                                       "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzTransferPoints call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #10
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 HTZUpdateTier_Negative(MemberModel member,
                                           string newTier, string tierEndDate, string marketingCode, string csAgent,
                                           int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                MemberModel memberOut = null;
                if (member != null)
                {
                    //Generate unique LIDs for each virtual card in the member
                    member = memController.AssignUniqueLIDs(member);
                    TestStep.Start($"Make AddMember Call", "Member should be added successfully");
                    memberOut = memController.AddMember(member);
                    AssertModels.AreEqualOnly(member, memberOut, MemberModel.BaseVerify);
                    TestStep.Pass("Member was added successfully and member object was returned", memberOut.ReportDetail());
                }
                var loyaltyId = memberOut?.VirtualCards?.First().LOYALTYIDNUMBER ?? "";
                var tierCode  = newTier ?? "";

                TestStep.Start($"Make HertzUpdateTier Call", $"HertzUpdateTier call should throw exception with error code = {errorCode}");
                LWServiceException exception =
                    Assert.Throws <LWServiceException>(() =>
                                                       memController.HertzUpdateTier(loyaltyId, csAgent, tierCode, tierEndDate, marketingCode),
                                                       "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzUpdateTier call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #12
0
        public void GetAccountSummaryTestsTest_Negative(string loyaltyId, int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                if (loyaltyId == null)
                {
                    TestStep.Start("Make GetAccountSummary Call", $"GetAccountSummary call should throw exception with error code = {errorCode}");
                    LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetAccountSummary(loyaltyId, null, null),
                                                                                      "Expected LWServiceException, exception was not thrown.");
                    Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                    Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                    TestStep.Pass("GetAccountSummary call threw expected exception", exception.ReportDetail());
                }
                else
                {
                    TestStep.Start("Make GetAccountSummary Call", $"GetAccountSummary call should throw exception with error code = {errorCode}");
                    LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetAccountSummary(loyaltyId, null, null),
                                                                                      "Expected LWServiceException, exception was not thrown.");
                    Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                    Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                    TestStep.Pass("GetAccountSummary call threw expected exception", exception.ReportDetail());
                }
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
        public void GetMembers_Negative(string[] searchTypes, string[] searchValues, int?startIdx, int?batchSize, bool validSearchValue, int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                TestStep.Start("Get Existing Member from the database", "Existing member should be found");
                MemberModel dbMember = memController.GetRandomFromDB(MemberModel.Status.Active);
                Assert.IsNotNull(dbMember, "Member could not be retrieved from DB");
                TestStep.Pass("Existing member was found", dbMember.ReportDetail());

                if (validSearchValue)
                {
                    searchValues = new string[] { dbMember.VirtualCards.First().LOYALTYIDNUMBER }
                }
                ;

                TestStep.Start($"Make GetMembers Call", $"GetMembers call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetMembers(searchTypes, searchValues, startIdx, batchSize, String.Empty),
                                                                                  "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                TestStep.Pass("GetMembers call threw expected exception", exception.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #14
0
        public void HertzAwardLoyaltyCurrency_Negative(MemberModel member, int errorCode, string errorMessage, decimal points, string csagent, string memLoyaltyID = null, string txnRanum = null, decimal?txnPointEventID = null)
        {
            MemberController memController   = new MemberController(Database, TestStep);
            PointController  pointController = new PointController(Database, TestStep);
            string           pointeventname  = "AwardNotApplied-CSAdjustment";

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

                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());

                TestStep.Start("Find PointEventId in database", $"PointEventId should be found {pointeventname}");
                IEnumerable <PointEventModel> pointEvent = pointController.GetPointEventIdsFromDb(pointeventname);
                decimal pointEventId = txnPointEventID ?? 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 = memLoyaltyID ?? memberOut.VirtualCards.First().LOYALTYIDNUMBER;
                TestStep.Start($"Make HertzAwardLoyaltyCurrency Call", $"Add member call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.HertzAwardLoyaltyCurrency(loyaltyId, csagent, points, Convert.ToInt64(pointEventId), "automationNeg", txnRanum), "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("HertzAwardLoyaltyCurrency call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
        public void GetMemberPromotionCount_Negative(int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

            try
            {
                TestStep.Start("Get Existing Member from the database", "Existing member should be found");
                MemberModel dbMember = memController.GetRandomFromDB(MemberModel.Status.Active);
                Assert.IsNotNull(dbMember, "Member could not be retrieved from DB");
                TestStep.Pass("Existing member was found", dbMember.ReportDetail());

                TestStep.Start("Make GetMembers Call", $"GetPromotionCount call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.GetMemberPromotionCount(dbMember.VirtualCards.First().LOYALTYIDNUMBER),
                                                                                  "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                TestStep.Pass("GetPromotionCount call threw expected exception", exception.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();
            }
        }
Beispiel #16
0
        public void AddAttributeSet_Negative(MemberModel member,
                                             AuctionHeaderModel auctionHeaderRequestModel,
                                             int errorCode, string errorMessage)
        {
            MemberController memController = new MemberController(Database, TestStep);

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

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

                TestStep.Start($"Make AddAttributeSet Call", "AddAttributeSet call should return AddAttributeSet object");
                LWServiceException exception =
                    Assert.Throws <LWServiceException>(() =>
                                                       memController.AddAttributeSet(vc, auctionHeaderRequestModel),
                                                       "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode);
                Assert.IsTrue(exception.Message.Contains(errorMessage));
                TestStep.Pass("AddAttributeSet call threw expected exception", exception.ReportDetail());
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message);
                Assert.Fail();
            }
        }
Beispiel #17
0
        public void AddMemberPromotion_Negative(string loyaltyId, string promoCode, int errorCode, string errorMessage)
        {
            MemberController    memController   = new MemberController(Database, TestStep);
            PromotionController promoController = new PromotionController(Database, TestStep);

            try
            {
                if (!string.IsNullOrEmpty(promoCode) && promoCode.Equals("0000"))
                {
                    TestStep.Start("Adding Member unique LoyaltyIds for each virtual card", "Unique LoyaltyIds should be assigned");
                    MemberModel createMember = MemberController.GenerateRandomMember(HertzLoyalty.GoldPointsRewards.RegularGold);
                    createMember = memController.AssignUniqueLIDs(createMember);
                    TestStep.Pass("Unique LoyaltyIds assigned", createMember.VirtualCards.ReportDetail());

                    loyaltyId = createMember.VirtualCards[0].LOYALTYIDNUMBER;
                    TestStep.Start($"Make AddMember Call", $"Member with LID {loyaltyId} 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());

                    loyaltyId = memberOut.VirtualCards.First().LOYALTYIDNUMBER;
                }
                else if (promoCode == string.Empty)
                {
                    TestStep.Start("Get Expired promotion from DB", "Expired promo found in DB");
                    IEnumerable <PromotionModel> promoOutDb = promoController.GetRandomExpiredPromotionFromDB();
                    Assert.Greater(promoOutDb.Count(), 0, "Expected one or more expired promotions from DB");
                    TestStep.Pass("Expired promotion found in DB", promoOutDb.ReportDetail());

                    promoCode    = promoOutDb.First().CODE;
                    errorMessage = $"Promotion {promoCode} is not valid anymore";

                    TestStep.Start("Adding Member unique LoyaltyIds for each virtual card", "Unique LoyaltyIds should be assigned");
                    MemberModel createMember = MemberController.GenerateRandomMember(HertzLoyalty.GoldPointsRewards.RegularGold);
                    createMember = memController.AssignUniqueLIDs(createMember);
                    TestStep.Pass("Unique LoyaltyIds assigned", createMember.VirtualCards.ReportDetail());

                    loyaltyId = createMember.VirtualCards[0].LOYALTYIDNUMBER;
                    TestStep.Start($"Make AddMember Call", $"Member with LID {loyaltyId} 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());
                }

                TestStep.Start("Make AddMemberPromotion Call", $"AddMemberPromotion call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memController.AddMemberPromotion(loyaltyId, promoCode, null, null, null, null, null, null),
                                                                                  "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                TestStep.Pass("AddMemberPromotion call threw expected exception", exception.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                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_NegativeCancelled(MemberModel createMember, IHertzProgram program, string memberRewardId, int errorCode, string errorMessage)
        {
            MemberController      memberController = new MemberController(Database, TestStep);
            RewardController      rewardController = new RewardController(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;
            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");

                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");

                errorMessage = $"Reward with id {memberRewardId} has already been cancelled";
                TestStep.Start("Make CancelMemberReward Call", $"CancelMemberReward call should throw exception with error code = {errorCode}");
                LWServiceException exception = Assert.Throws <LWServiceException>(() => memberController.CancelMemberReward(memberRewardId, null, null, null, null, null, null, null),
                                                                                  "Expected LWServiceException, exception was not thrown.");
                Assert.AreEqual(errorCode, exception.ErrorCode, $"Expected Error Code: {errorCode}");
                Assert.IsTrue(exception.Message.Contains(errorMessage), $"Expected Error Message to contain: {errorMessage}");
                TestStep.Pass("CancelMemberReward call threw expected exception", exception.ReportDetail());
            }
            catch (AssertionException ex)
            {
                TestStep.Fail(ex.Message);
                Assert.Fail();
            }
            catch (AssertModelEqualityException ex)
            {
                TestStep.Fail(ex.Message, ex.ComparisonFailures);
                Assert.Fail();
            }
            catch (Exception ex)
            {
                TestStep.Abort(ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }