Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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();
            }
        }