public void GetMembers_Positive() { MemberController memController = new MemberController(Database, TestStep); string[] searchType = { "CardID" }; string[] searchValue = { String.Empty }; 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()); searchValue = new string[] { dbMember.VirtualCards.First().LOYALTYIDNUMBER }; TestStep.Start($"Make GetMembers Call by SearchType = {searchType}, SearchValue = {searchValue}", "GetMembers should return one member"); IEnumerable <MemberModel> getMembersOut = memController.GetMembers(searchType, searchValue, null, null, String.Empty); Assert.AreEqual(1, getMembersOut.Count()); TestStep.Pass("GetMembers returned one member", getMembersOut.ReportDetail()); MemberModel getMember = getMembersOut.First(); TestStep.Start($"Verify GetMembers returned member matches DB Member", "API member should match existing member found from DB"); AssertModels.AreEqualOnly(dbMember, getMember, MemberModel.BaseVerify); TestStep.Pass("API member matches existing member found from DB"); TestStep.Start($"Verify MemberDetails in {MemberDetailsModel.TableName} table", "Database member details should match API member"); AssertModels.AreEqualWithAttribute(getMember.MemberDetails, dbMember.MemberDetails); TestStep.Pass("API Member details matches member details in database", dbMember.MemberDetails.ReportDetail()); TestStep.Start($"Verify MemberPreferences in {MemberPreferencesModel.TableName} table", "Database member preferences should match API member"); AssertModels.AreEqualWithAttribute(getMember.MemberPreferences, dbMember.MemberPreferences); TestStep.Pass("API Member preferences created matches member preferences in database", dbMember.MemberPreferences.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 void HertzAddUpdateCsAgent_Positive(CsAgentModel csAgent, string agentRoleName, bool UpdateCsAgent) { CsAgentController CsAgentController = new CsAgentController(Database, TestStep); CsAgentModel csAgentOut; try { CsAgentRoleModel csAgentRole = CsAgentController.GetFromDBRoleID(agentRoleName); decimal caAgentRoleID = csAgentRole.ID; csAgent.ROLEID = caAgentRoleID; TestStep.Start($"Make HertzAddUpdateCSAgent Call", "CSAgent should be added successfully"); csAgentOut = CsAgentController.AddCsAgent(csAgent); AssertModels.AreEqualWithAttribute(csAgent, csAgentOut); TestStep.Pass("CsAgent was added successfully and CsAgent object was returned", csAgentOut.ReportDetail()); TestStep.Start($"Verify CsAgent in {CsAgentModel.TableName} table", "Database CsAgent should match created CsAgent"); CsAgentModel dbCsAgent = CsAgentController.GetFromDB(csAgentOut.USERNAME); AssertModels.AreEqualWithAttribute(csAgentOut, dbCsAgent); TestStep.Pass("CsAgent created matches CsAgent in database", dbCsAgent.ReportDetail()); if (UpdateCsAgent) { csAgentOut.LASTNAME = csAgentOut.LASTNAME + "Updated"; csAgentOut.EMAILADDRESS = "*****@*****.**"; TestStep.Start($"Make HertzAddUpdateCSAgent Call for updating Last Name and Email", "CSAgent should be updated successfully"); CsAgentModel csAgentOutUpdated = CsAgentController.AddCsAgent(csAgentOut); AssertModels.AreEqualWithAttribute(csAgentOutUpdated, csAgentOut); TestStep.Pass("CsAgent was added successfully and CsAgent object was returned", csAgentOutUpdated.ReportDetail()); TestStep.Start($"Verify CsAgent is updated in {CsAgentModel.TableName} table", "Database CsAgent should match updated CsAgent"); CsAgentModel dbCsAgentUpdated = CsAgentController.GetFromDB(csAgentOutUpdated.USERNAME); AssertModels.AreEqualWithAttribute(csAgentOutUpdated, dbCsAgentUpdated); TestStep.Pass("CsAgent created matches CsAgent in database", dbCsAgentUpdated.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 AddMember_Positive(MemberModel createMember) { 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()); TestStep.Start($"Verify Member in {MemberModel.TableName} table", "Database member should match created member"); MemberModel dbMember = memController.GetFromDB(memberOut.IPCODE); AssertModels.AreEqualOnly(createMember, dbMember, MemberModel.BaseVerify); TestStep.Pass("Member created matches member in database", dbMember.ReportDetail()); TestStep.Start($"Verify MemberDetails in {MemberDetailsModel.TableName} table", "Database member details should match created member"); AssertModels.AreEqualOnly(createMember.MemberDetails, dbMember.MemberDetails, MemberDetailsModel.BaseVerify); TestStep.Pass("Member details in database match created member details", dbMember.MemberDetails.ReportDetail()); TestStep.Start($"Verify MemberPreferences in {MemberPreferencesModel.TableName} table", "Database member preferences should match created member"); AssertModels.AreEqualWithAttribute(createMember.MemberPreferences, dbMember.MemberPreferences); TestStep.Pass("Member preferences created matches member preferences in database", dbMember.MemberPreferences.ReportDetail()); TestStep.Start($"Verify VirtualCard in {VirtualCardModel.TableName} table", "Database VirtualCard should API member VirtualCard"); AssertModels.AreEqualWithAttribute(memberOut.VirtualCards.First(), dbMember.VirtualCards.First()); TestStep.Pass("API Member VirtualCard matches database member VirtualCard", dbMember.VirtualCards.First().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 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 void HertzAwardLoyaltyCurrency_Positive(MemberModel member, IHertzTier tier, string pointeventname, decimal points, bool useRanum) { MemberController memController = new MemberController(Database, TestStep); PointController pointController = new PointController(Database, TestStep); try { //Generate unique LIDs for each virtual card in the member member = memController.AssignUniqueLIDs(member); string ranum; 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()); VirtualCardModel vc = memberOut.VirtualCards.First(); //Transactions are added to test the API with ranum and also to test the negative points scenario TestStep.Start($"Add Transaction to the member", "Transactions added successfully"); vc.Transactions = TxnHeaderController.GenerateRandomTransactions(vc, tier.ParentProgram, 1, 200); if (useRanum) { ranum = vc.Transactions.Select(x => x.A_RANUM).First(); } else { ranum = null; } Assert.IsNotNull(vc.Transactions, "Expected populated transaction object, but transaction object returned was null"); TestStep.Pass("Transaction added to the member", vc.Transactions.ReportDetail()); 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()); TestStep.Start("Find PointEventId in database", $"PointEventId should be found {pointeventname}"); IEnumerable <PointEventModel> pointEvent = pointController.GetPointEventIdsFromDb(pointeventname); decimal pointEventId = 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 = memberOut.VirtualCards.First().LOYALTYIDNUMBER; TestStep.Start($"Make HertzAwardLoyaltyCurrency Call", "HertzAwardLoyaltyCurrency call should return HertzAwardLoyaltyCurrency object"); HertzAwardLoyaltyCurrencyResponseModel memberAwardLoyaltyCurrency = memController.HertzAwardLoyaltyCurrency(loyaltyId, "csadmin", points, Convert.ToInt64(pointEventId), "automation", ranum); Assert.IsNotNull(memberAwardLoyaltyCurrency, "Expected populated AwardLoyaltyCurrency object, but AwardLoyaltyCurrency object returned was null"); TestStep.Pass("HertzAwardLoyaltyCurrency object was returned", memberAwardLoyaltyCurrency.ReportDetail()); var vckey = memberOut.VirtualCards.First().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", memberAccountSummaryOutDb.ReportDetail()); TestStep.Start("Verify Points awarded matches the points in DB", "Points awarded matches the points in DB"); IEnumerable <PointTransactionModel> dbPointTransaction = pointController.GetPointTransactionsFromDb(decimal.Parse(vckey)).ToList(); Assert.IsNotNull(dbPointTransaction, "Expected populated PointTransaction object from database query, but PointTransaction object returned was null"); Assert.AreEqual(points, dbPointTransaction.Where(x => x.POINTEVENTID == pointEventId && x.POINTS == points).Select(x => x.POINTS).First(), $"Points awarded does not match database points{dbPointTransaction.Select(x => x.POINTS)} "); TestStep.Pass("Points awarded are added to the DB", dbPointTransaction.ReportDetail()); TestStep.Start($"Verify CurrencyBalance of HertzAwardLoyaltyCurrency", "CurrencyBalance returned should be correct"); Assert.AreEqual(dbPointTransaction.Sum(x => x.POINTS), memberAwardLoyaltyCurrency.CURRENCYBALANCE, $"CurrencyBalance does not match database points{dbPointTransaction.Select(x => x.POINTS)} "); Assert.AreEqual(0, memberAwardLoyaltyCurrency.CURRENCYTONEXTTIER, "CurrencyToNextTier does not match 0"); TestStep.Pass("CurrencyBalance response is as expcted", memberAwardLoyaltyCurrency.ReportDetail()); TestStep.Start("Compare Account Summary between DB and API", "Account Summary matches"); AssertModels.AreEqualWithAttribute(memberAccountSummaryOutDb, memberAwardLoyaltyCurrency); TestStep.Pass("Account Summary matches between DB and API", memberAccountSummaryOutDb.ReportDetail()); TestStep.Start($"Verify response of HertzAwardLoyaltyCurrency for GPR", "Response returned should be correct"); if (tier.ParentProgram.EarningPreference == "N1") { Assert.AreEqual(tier.RentalsToNextTier - vc.Transactions.Count(), memberAwardLoyaltyCurrency.RENTALSTONEXTTIER, $"RentalsToNextTier does not match {tier.RentalsToNextTier - vc.Transactions.Count()}"); Assert.AreEqual(tier.RevenueToNextTier - vc.Transactions.First().A_GRSREVNAMT, memberAwardLoyaltyCurrency.REVENUETONEXTTIER, $"RentalsToNextTier does not match {tier.RevenueToNextTier - vc.Transactions.First().A_GRSREVNAMT}"); Assert.AreEqual(vc.Transactions.Count(), memberAwardLoyaltyCurrency.TOTALRENTALSYTD, $"TotalRentalsYTD does not match {memberAwardLoyaltyCurrency.TOTALRENTALSYTD}"); Assert.AreEqual(vc.Transactions.Sum(x => x.A_GRSREVNAMT), memberAwardLoyaltyCurrency.TOTALREVENUEYTD, $"TotalRentalsYTD does not match {memberAwardLoyaltyCurrency.TOTALREVENUEYTD}"); Assert.AreEqual("Gold", memberAwardLoyaltyCurrency.CURRENTTIERNAME, $"CurrentTierName does not match {memberAwardLoyaltyCurrency.CURRENCYBALANCE}"); } TestStep.Pass("HertzAwardLoyaltyCurrency response is as expcted for GPR", memberAwardLoyaltyCurrency.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(); } }
public void UpdateMember_Positive(long memberStatus, IHertzTier hertzTier, int transactionCount) { MemberController memController = new MemberController(Database, TestStep); TxnHeaderController txnController = new TxnHeaderController(Database, TestStep); try { TestStep.Start("Get Existing Member from the database", "Existing member should be found"); MemberModel member = memController.GetRandomFromDB(MemberModel.Status.Active, hertzTier); member.CHANGEDBY = "UpdateMemberAutomation"; Assert.IsNotNull(member, "Member could not be retrieved from DB"); Assert.IsNotNull(member.VirtualCards, "Expected member to have virtual cards"); TestStep.Pass("Existing member was found", member.ReportDetail()); var memVirtualCard = member.VirtualCards.First(); TestStep.Start($"Add {transactionCount} 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, hertzTier.ParentProgram, 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(member); Assert.IsNotNull(updatedMember, "Expected non null Member object to be returned"); TestStep.Pass("Member object returned from UpdateMember API call", updatedMember.ReportDetail()); TestStep.Start($"Verify API response contains expected Member", "API response should contain passed member."); AssertModels.AreEqualOnly(member, updatedMember, MemberModel.BaseVerify); TestStep.Pass("API response member matches expected member."); TestStep.Start($"Verify API response contains expected MemberDetails for passed member", "API response should contain passed member details."); AssertModels.AreEqualWithAttribute(member.MemberDetails, updatedMember.MemberDetails); TestStep.Pass("API response contains passed member details."); TestStep.Start($"Verify API response contains expected MemberPreferences for passed member", "API response should contain passed member preferences."); AssertModels.AreEqualWithAttribute(member.MemberPreferences, updatedMember.MemberPreferences); TestStep.Pass("API response contains passed member preferences."); TestStep.Start($"Verify API response contains expected VirtualCard for passed member", "API response should contain passed virtual card details."); AssertModels.AreEqualWithAttribute(memVirtualCard, updatedMember.VirtualCards.First()); TestStep.Pass("API response contains passed virtual card.", updatedMember.VirtualCards.ReportDetail()); TestStep.Start($"Verify Updated Member contains {transactionCount} transaction(s)", $"Members virtual card should contain {transactionCount} transaction(s)"); Assert.AreEqual(transactionCount, updatedMember.VirtualCards.First().Transactions.Count); TestStep.Pass("Members virtual card contained the expected number of transactions"); foreach (var transaction in memVirtualCard.Transactions) { TestStep.Start($"Verify Update Member API response contains transaction RANUM [{transaction.A_RANUM}]", "Update Member API response should contain expected transaction"); var updateMemTransaction = updatedMember.VirtualCards.First().Transactions.Find(x => x.A_RANUM == transaction.A_RANUM); Assert.NotNull(updateMemTransaction, $"Transaction with RANUM [{transaction.A_RANUM}] not found in members virtual card"); AssertModels.AreEqualWithAttribute(transaction, updateMemTransaction); TestStep.Pass("Members virtual card contains expected transaction", updateMemTransaction.ReportDetail()); TestStep.Start($"Verify transaction details are in {TxnHeaderModel.TableName} for A_VCKEY = {memVirtualCard.VCKEY}, A_RANUM = {transaction.A_RANUM}", "Transaction header should be found"); IEnumerable <TxnHeaderModel> dbTransactions = txnController.GetFromDB(memVirtualCard.VCKEY, transaction.A_RANUM); Assert.IsNotNull(dbTransactions, "No transactions returned from the database"); Assert.AreEqual(1, dbTransactions.Count()); AssertModels.AreEqualWithAttribute(transaction, dbTransactions.First()); TestStep.Pass("Transaction header was found in database", dbTransactions.First().ReportDetail()); } } catch (AssertionException ex) { TestStep.Fail(ex.Message); Assert.Fail(); } catch (LWServiceException ex) { TestStep.Fail(ex.Message, new string[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {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(); } }
//[Category("Bonus_Positive")] //[Category("Bonus")] //[TestCaseSource(typeof(CorpNewMember550PointsOngoingActivity), "PositiveScenarios")] //[TestCaseSource(typeof(EUSchneider3x2019Bonus), "PositiveScenarios")] //[TestCaseSource(typeof(GPRAAABonusActivity), "PositiveScenarios")] //[TestCaseSource(typeof(ACIActivation800Activity), "PositiveScenarios")] //[TestCaseSource(typeof(HorizonCardPointsActivity), "PositiveScenarios")] //[TestCaseSource(typeof(OngoingEMEABirthdayActivity), "PositiveScenarios")] //[TestCaseSource(typeof(VisaInfinite10RGBonusActivity), "PositiveScenarios")] //[TestCaseSource(typeof(EUCorp800Points_OngoingActivity), "PositiveScenarios")] //[TestCaseSource(typeof(LapsedOnGoingActivity), "PositiveScenarios")] public void RealTime_Bonus_Positive(MemberModel member, TxnHeaderModel[] transactionsIn, ExpectedPointEvent[] expectedPointEvents, string[] requiredPromotionCodes) { //Currently there are no async rules for Hertz should be all ran by return of UpdateMember int ruleTriggerWaitMS = 1; MemberController memController = new MemberController(Database, TestStep); TxnHeaderController txnController = new TxnHeaderController(Database, TestStep); PointController pointController = new PointController(Database, TestStep); try { TestStep.Start("Assigning 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", "Member should be added successfully and member object should be returned"); MemberModel memberOut = memController.AddMember(member); Assert.IsNotNull(memberOut, "Expected populated member object, but member object returned was null"); Assert.IsNotNull(memberOut.VirtualCards, "Expected member to have virtual cards"); TestStep.Pass("Member was added successfully and member object was returned", memberOut.ReportDetail()); TestStep.Start($"Verify MemberDetails in AddMember output against member details passed", "API MemberDetails should match passed MemberDetails"); AssertModels.AreEqualWithAttribute(member.MemberDetails, memberOut.MemberDetails); TestStep.Pass("API MemberDetails match passed MemberDetails", memberOut.MemberDetails.ReportDetail()); var memberVC = memberOut.VirtualCards.First(); if (requiredPromotionCodes != null) { foreach (string promoCode in requiredPromotionCodes) { TestStep.Start($"Make AddMemberPromotion call to add required promotion {promoCode} to member", "AddMemberPromotion call should return MemberPromotion object"); MemberPromotionModel memberPromo = memController.AddMemberPromotion(memberVC.LOYALTYIDNUMBER, promoCode, null, null, false, null, null, false); Assert.NotNull(memberPromo, "Expected AddMemberPromotion to return MemberPromotion object, but returned object was null"); TestStep.Pass("AddMemberPromotion call returned MemberPromotion object", memberPromo.ReportDetail()); } } TestStep.Start($"Add {transactionsIn.Length} transaction(s) to members virtual card with VCKEY = {memberVC.VCKEY}", "Transaction(s) should be added to members virtual card"); if (memberVC.Transactions == null) { memberVC.Transactions = new List <TxnHeaderModel>(); } foreach (var transaction in transactionsIn) { transaction.A_LYLTYMEMBERNUM = memberVC.LOYALTYIDNUMBER; memberVC.Transactions.Add(transaction); } Assert.AreEqual(transactionsIn.Length, memberVC.Transactions.Count, $"Expected {transactionsIn.Length} TxnHeader(s) to be present in members vitual card"); TestStep.Pass("Transaction(s) added to members virtual card", memberVC.Transactions.ReportDetail()); TestStep.Start("Update Existing Member with added transaction(s)", "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()); memberOut = updatedMember; Thread.Sleep(ruleTriggerWaitMS); TestStep.Start($"Verify TxnHeader(s) in DB with VCKEY = {memberVC.VCKEY}", "TxnHeader(s) from database should match expected TxnHeader"); List <TxnHeaderModel> dbTxns = txnController.GetFromDB(memberVC.VCKEY).ToList(); Assert.IsNotNull(dbTxns, "Expected Database query to return TxnHeaders"); foreach (var expectedTransaction in transactionsIn) { var foundHeader = dbTxns.Find(x => x.A_RANUM == expectedTransaction.A_RANUM); Assert.IsNotNull(foundHeader, $"Expected to find TxnHeader with RANUM = { expectedTransaction.A_RANUM}"); } TestStep.Pass("TxnHeader(s) from database matches expected TxnHeader(s)", transactionsIn.Select(x => x.A_RANUM).ToArray()); TestStep.Start($"Verify point transaction(s) exist for member VCKEY = {memberVC.VCKEY}", "Point transaction(s) should exist for member"); IEnumerable <PointTransactionModel> ptTransactions = pointController.GetPointTransactionsFromDb(memberVC.VCKEY); Assert.NotNull(ptTransactions, "Expected database query to return point transactions"); Assert.IsTrue(ptTransactions.Count() >= transactionsIn.Length, $"Expected at least {transactionsIn.Length} point transaction(s) to be found"); TestStep.Pass("Point event(s) exists for member", ptTransactions.ReportDetail()); TestStep.Start($"Verify point event(s) match expected {String.Join(",", expectedPointEvents.Select(x => x.PointEventName))}", "Point transaction should contain expected point event(s)"); List <PointEventModel> pointEvents = pointController.GetPointEventsFromDb(ptTransactions.Select(x => x.POINTEVENTID).ToArray()).ToList(); List <string> pointEventNames = ptTransactions.Select(x => pointEvents.Find(y => y.POINTEVENTID == x.POINTEVENTID).NAME).ToList(); List <string> expectedPointEventNames = expectedPointEvents.Select(x => x.PointEventName).ToList(); Assert.IsTrue(!expectedPointEventNames.Except(pointEventNames).Any(), $"Expected point events {String.Join(",", expectedPointEventNames)} - Actual {String.Join(",", pointEventNames)}"); TestStep.Pass("Point event(s) exists for member", pointEvents.ReportDetail()); List <PointTransactionModel> ptTransCompare = ptTransactions.ToList(); foreach (ExpectedPointEvent expectedEvent in expectedPointEvents) { PointEventModel ptEvent = pointEvents.Find(x => x.NAME.Equals(expectedEvent.PointEventName)); TestStep.Start($"Verify point event {expectedEvent.PointEventName} points = {expectedEvent.PointAmount}", $"Points for event {expectedEvent.PointEventName} should be {expectedEvent.PointAmount}"); PointTransactionModel ptTransaction = ptTransCompare.Find(x => x.POINTEVENTID == ptEvent.POINTEVENTID && x.POINTS == expectedEvent.PointAmount); Assert.NotNull(ptTransaction, $"Expected point transaction Name:{expectedEvent.PointEventName} Point Value: {expectedEvent.PointAmount} was not found"); Assert.AreEqual(expectedEvent.PointAmount, ptTransaction.POINTS, $"Expected points for {expectedEvent.PointEventName} do not match"); TestStep.Pass($"Points for event {expectedEvent.PointEventName} match expected: {expectedEvent.PointAmount}", ptTransaction.ReportDetail()); ptTransCompare.Remove(ptTransaction); } } catch (AssertionException ex) { TestStep.Fail(ex.Message); Assert.Fail(); } catch (LWServiceException ex) { TestStep.Fail(ex.Message, new string[] { $"Error Code: {ex.ErrorCode}", $"Error Message: {ex.Message}" }); Assert.Fail(); } catch (AssertModelEqualityException ex) { TestStep.Fail(ex.Message, ex.ComparisonFailures); Assert.Fail(); } catch (Exception ex) { TestStep.AddAttachment(new Attachment("StackTrace", ex.StackTrace, Attachment.Type.Text)); TestStep.Abort(ex.Message); Assert.Fail(); } }
public void GetMemberPromotion_Positive(MemberModel createMember, string promotionCode) { MemberController memController = new MemberController(Database, TestStep); PromotionController promoController = new PromotionController(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()); TestStep.Start("Find promotion in database", "Promotion should be found"); IEnumerable <PromotionModel> promos = promoController.GetFromDB(code: promotionCode); Assert.NotNull(promos, "Expected Promotion.GetFromDB to return IEnumerable<Promotion> object"); Assert.IsTrue(promos.Any(x => x.CODE.Equals(promotionCode)), "Expected promotion code was not found in database"); TestStep.Pass("Promotion was found", promos.ReportDetail()); var loyaltyId = memberOut.VirtualCards.First().LOYALTYIDNUMBER; TestStep.Start("Make AddMemberPromotion Call", "AddMemberPromotion call should return MemberPromotion object"); MemberPromotionModel memberPromoOut = memController.AddMemberPromotion(loyaltyId, promotionCode, null, null, false, null, null, false); Assert.IsNotNull(memberPromoOut, "Expected populated MemberPromotion object, but MemberPromotion object returned was null"); TestStep.Pass("MemberPromotion object was returned", memberPromoOut.ReportDetail()); TestStep.Start($"Verify added member promotion exists in {MemberPromotionModel.TableName}", $"Member promotion should be in {MemberPromotionModel.TableName}"); IEnumerable <MemberPromotionModel> dbMemberPromo = memController.GetMemberPromotionsFromDB(null, null, memberOut.IPCODE); Assert.IsNotNull(dbMemberPromo, "Expected populated MemberPromotion object from database query, but MemberPromotion object returned was null"); Assert.Greater(dbMemberPromo.Count(), 0, "Expected at least one MemberPromotion to be returned from query"); AssertModels.AreEqualOnly(memberPromoOut, dbMemberPromo.OrderByDescending(x => x.CREATEDATE).First(), MemberPromotionModel.BaseVerify); TestStep.Pass("MemberPromotion object exists in table", dbMemberPromo.ReportDetail()); TestStep.Start("Make GetMemberPromotion call", "Member promotion should be returned"); IEnumerable <MemberPromotionModel> memberPromotionModelOut = memController.GetMemberPromotion(loyaltyId, null, null, false, string.Empty, string.Empty, false, null); Assert.Greater(memberPromotionModelOut.Count(), 0, "Expected at least one MemberPromotion to be returned from API"); TestStep.Pass("MemberPromotion object was returned from API", memberPromotionModelOut.ReportDetail()); TestStep.Start("Compare Member Promotion Count", "Member promotion count from API should match count from DB"); Assert.AreEqual(memberPromotionModelOut.Count(), dbMemberPromo.Count(), "Expected Member Promotion count to match"); TestStep.Pass("MemberPromotion count match completed"); TestStep.Start($"Verify Member Promotion in {MemberPromotionModel.TableName} table", "Member Promo from API GetMemberPromotion"); AssertModels.AreEqualWithAttribute(memberPromotionModelOut, dbMemberPromo); TestStep.Pass("API Member promotion created matches member promotions in database", memberOut.MemberPreferences.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(); } }