コード例 #1
0
        public void BTA1031_ST1215_SOAP_ApplyTxnCreditToMemberCardIdNull_VerifyElapsedTime()
        {
            testCase        = new TestCase(TestContext.TestName);
            listOfTestSteps = new List <TestStep>();
            testStep        = new TestStep();
            String stepName = "";

            try
            {
                Logger.Info("Test Method Started");
                Common common = new Common(this.DriverContext);
                CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common);

                testStep = TestStepHelper.StartTestStep(testStep);
                List <string> TransactionList = new List <string>();
                stepName        = "Getting Transaction in the Transaction History Details Table";
                testStep        = TestStepHelper.StartTestStep(testStep);
                TransactionList = ProjectBasePage.GetTransactionDetailsFromTransationHistoryTableFromDB(out Step_Output);
                string transactionHeaderId = TransactionList[0];
                string txnAmount           = TransactionList[2];
                testStep.SetOutput(Step_Output);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API"));
                listOfTestSteps.Add(testStep);

                testStep = TestStepHelper.StartTestStep(testStep);
                stepName = "Adding member with CDIS service";
                Member output = cdis_Service_Method.GetCDISMemberGeneral();
                vc = output.GetLoyaltyCards();
                testStep.SetOutput("IpCode: " + output.IpCode + " , Name: " + output.FirstName);
                Logger.Info("IpCode: " + output.IpCode + " , Name: " + output.FirstName);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API"));
                listOfTestSteps.Add(testStep);

                testStep = TestStepHelper.StartTestStep(testStep);
                stepName = "Apply transaction to a member with Cardid as null ";
                string  memberIdentity = vc[0].LoyaltyIdNumber;
                decimal pointsEarned   = cdis_Service_Method.ApplyTxnCredit(memberIdentity, null, transactionHeaderId, "ApplyingTxnCredit_CDIS", out elapsedTime);
                if (pointsEarned == Convert.ToDecimal(txnAmount))
                {
                    testStep.SetOutput("Applied  transaction to a member where Cardid is null with MemberIdentity: " + memberIdentity + " TransactionHeaderId: " + transactionHeaderId + " TransactionAmount: " + txnAmount);
                }
                else
                {
                    throw new Exception("Failed to apply Transaction to a member");
                }
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API"));
                listOfTestSteps.Add(testStep);

                testStep = TestStepHelper.StartTestStep(testStep);
                stepName = "Validate the transaction is added in database ";
                string txnHeaderIdFromDB = DatabaseUtility.GetFromSoapDB("ats_txndetailitem", "A_TXNHEADERID", transactionHeaderId, "A_TXNHEADERID", string.Empty);
                Assert.AreEqual(transactionHeaderId, txnHeaderIdFromDB, "Expected value is" + transactionHeaderId + "Actual Value is" + txnHeaderIdFromDB);
                testStep.SetOutput("Transaction is added successfully in txndetailitem table with transactionHeaderId: " + transactionHeaderId);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API"));
                listOfTestSteps.Add(testStep);

                testStep = TestStepHelper.StartTestStep(testStep);
                stepName = "Validate the elapsed time is greater than Zero";
                if (elapsedTime > 0)
                {
                    testStep.SetOutput("Elapsed time is greater than zero and the elapsed time is " + elapsedTime);
                }
                else
                {
                    throw new Exception("Elapsed time is not greater than Zero");
                }
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API"));
                listOfTestSteps.Add(testStep);

                testCase.SetStatus(true);
            }
            catch (Exception e)
            {
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API"));
                listOfTestSteps.Add(testStep);
                testCase.SetStatus(false);
                testCase.SetErrorMessage(e.Message);
                Assert.Fail(e.Message);
            }
            finally
            {
                testCase.SetTestCaseSteps(listOfTestSteps);
                testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow());
                listOfTestCases.Add(testCase);
            }
        }