public static decimal?CalculateQualifyingPurchaseAmount(TxnHeaderModel expectedTransaction) { decimal?sumOfValues = Sum(expectedTransaction.A_SBTOTAMT, expectedTransaction.A_LDWCDWCHRGAMT, expectedTransaction.A_ADDLSRVCCHRGAMT, expectedTransaction.A_AGEDIFFCHRGAMT, expectedTransaction.A_ADDLAUTHDRVRCHRGAMT, expectedTransaction.A_CHILDSEATTOTAMT, expectedTransaction.A_MISCGRPAMT, expectedTransaction.A_GARSPECLEQMNTAMT, expectedTransaction.A_TOTCHRGAMT, expectedTransaction.A_NVGTNSYSTOTAMT, expectedTransaction.A_SATLTRADIOTOTAMT, expectedTransaction.A_REFUELINGCHRGAMT) * expectedTransaction.A_RNTINGCTRYCRNCYUSDEXCHRT ?? 1M; decimal?total = Multiply(sumOfValues, expectedTransaction.A_RNTINGCTRYCRNCYUSDEXCHRT); return(total); }
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(); } }
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 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(); } }