public void BTA1235_ST1433_SOAP_RedeemMemberCouponByCertNmbr_NonExistingChannel() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_CertNumber_From_LWMemberCouponTable_With_EmptyDateRedeemed"]; Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get a valid certificateNumber from LW_MemberCoupon table"; string validCertNumber = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "CERTIFICATENMBR", sqlstmt); testStep.SetOutput("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); Logger.Info("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeem the member coupon with non existing channel and validate the Error Code:6003"; redemptiondate = System.DateTime.Now; string channel = "test"; string error = cdis_Service_Method.RedeemMemberCouponByByCertNumber_Invalid(validCertNumber, channel, "en", redemptiondate, timesused, false, false, string.Empty); if (error.Contains("Error code=6003") && error.Contains("Error Message=Specified channel is not defined")) { testStep.SetOutput("The ErrorMessage from Service is received as expected. " + error); Logger.Info("The ErrorMessage from Service is received as expected. " + error); } else { throw new Exception("Error not received as expected error: 6003. Actual error received is:\"" + error + "\""); } testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); //unredeem the cert again since we have less certificates cdis_Service_Method.UnRedeemMemberCouponByCertNumber(validCertNumber, out elapsedTime); Logger.Info("###Test Execution Ends### Test Passed: " + testCase.GetTestCaseName()); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); Logger.Info("Test Failed: " + testCase.GetTestCaseName() + "Reason: " + e.Message); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1235_ST1322_SOAP_RedeemMemberCouponByCertNmbr_ReturnAttributeTrue() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_CertNumber_From_LWMemberCouponTable_With_EmptyDateRedeemed"]; Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get a valid certificateNumber from LW_MemberCoupon table"; string validCertNumber = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "CERTIFICATENMBR", sqlstmt); testStep.SetOutput("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); Logger.Info("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeem the member coupon using certNumber with Return attributes true"; redemptiondate = System.DateTime.Now; bool?returnattributes = true; var certDetails = cdis_Service_Method.RedeemMemberCouponByCertNumber(validCertNumber, "Web", "en", redemptiondate, timesused, returnattributes, false, string.Empty, out elapsedTime); string dbRedemptionDate = DatabaseUtility.GetFromSoapDB("LW_MEMBERCOUPON", "CERTIFICATENMBR", validCertNumber, "DATEREDEEMED", string.Empty); Assert.AreEqual(System.DateTime.Now.ToString("MM/dd/yyyy"), Convert.ToDateTime(dbRedemptionDate).ToString("MM/dd/yyyy"), "Expected value is" + System.DateTime.Now.ToString("MM/dd/yyyy") + " and Actual value is" + Convert.ToDateTime(dbRedemptionDate).ToString("MM/dd/yyyy")); testStep.SetOutput("The Coupon name from the response of RedeemMemberCouponByCertNumber method is: " + certDetails.CouponDefinition.Name + "; the redemption date is: " + dbRedemptionDate); Logger.Info("TestStep: " + stepName + " ##Passed## The Coupon name from the response of RedeemMemberCouponByCertNumber method is: " + certDetails.CouponDefinition.Name + " and; the redemption date is: " + dbRedemptionDate); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); //unredeem the cert again since we have less certificates cdis_Service_Method.UnRedeemMemberCouponByCertNumber(validCertNumber, out elapsedTime); Logger.Info("###Test Execution Ends### Test Passed: " + testCase.GetTestCaseName()); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); Logger.Info("Test Failed: " + testCase.GetTestCaseName() + "Reason: " + e.Message); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1235_ST1435_SOAP_RedeemMemberCouponByCertNmbr_NonExistingCertNmbr() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_CertNumber_From_LWMemberCouponTable_With_EmptyDateRedeemed"]; testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeem the member coupon with non existing Certificate number and validate the Error code:3370"; redemptiondate = System.DateTime.Now; string invalidCertNumber = common.RandomNumber(10) + "-" + common.RandomNumber(4); string error = cdis_Service_Method.RedeemMemberCouponByByCertNumber_Invalid(invalidCertNumber, "Web", "en", redemptiondate, timesused, false, false, string.Empty); if (error.Contains(" Error code=3370") && error.Contains("Error Message=No coupon could be located using cert number")) { testStep.SetOutput("The ErrorMessage from Service is received as expected. " + error); Logger.Info("The ErrorMessage from Service is received as expected. " + error); } else { throw new Exception("Error not received as expected error:3370. Actual error received is:\"" + error + "\""); } testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("###Test Execution Ends### Test Passed: " + testCase.GetTestCaseName()); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); Logger.Info("Test Failed: " + testCase.GetTestCaseName() + "Reason: " + e.Message); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1239_ST1446_SOAP_GetBonusDefinitionCount_WhenAllParamsAreValid() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; double time = 0; try { Logger.Info("Test Method Started"); Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_Count_Future_Coupons"]; testStep = TestStepHelper.StartTestStep(testStep); stepName = "Getting Bonus Definitions Count from Service when all parameters are valid"; int output = cdis_Service_Method.GetBonusDefinitionCount(true, null, null, out time); testStep.SetOutput("Bonus Count : " + output); Logger.Info("Bonus Count : " + output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "validating the response from database"; string dbresponse = DatabaseUtility.GetBonusCountfromDbSOAP(); // string futureCouponCount = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "COUNT(*)", sqlstmt); // int activeCouponCount = Convert.ToInt32(dbresponse) - Convert.ToInt32(futureCouponCount); testStep.SetOutput("Active Bonus Count from database:" + dbresponse); Assert.AreEqual(output.ToString(), dbresponse, "Expected value is" + output + "Actual value is" + dbresponse); 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); } }
public void BTA830_SOAP_UnredeemMemberCouponByCertNmbr() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; double time = 0; Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); try { IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_CertNumber_From_LWMemberCouponTable_With_EmptyDateRedeemed"]; Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get a valid certificateNumber from LW_MemberCoupon table"; string validCertNumber = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "CERTIFICATENMBR", sqlstmt); testStep.SetOutput("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); Logger.Info("The valid certNumbr from LW_MemberCoupon table is: " + validCertNumber); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Redeem the member coupon using certNumber using RedeemMemberCouponByCertNumber method"; var certDetails = cdis_Service_Method.RedeemMemberCouponByCertNumber(validCertNumber); string dbRedemptionDate = DatabaseUtility.GetFromSoapDB("LW_MEMBERCOUPON", "CERTIFICATENMBR", validCertNumber, "DATEREDEEMED", string.Empty); string dbStatus = DatabaseUtility.GetFromSoapDB("LW_MEMBERCOUPON", "CERTIFICATENMBR", validCertNumber, "STATUS", string.Empty); Assert.AreEqual(System.DateTime.Now.ToString("MM/dd/yyyy"), Convert.ToDateTime(dbRedemptionDate).ToString("MM/dd/yyyy"), "Expected value is" + System.DateTime.Now.ToString("MM/dd/yyyy") + " and Actual value is" + Convert.ToDateTime(dbRedemptionDate).ToString("MM/dd/yyyy")); testStep.SetOutput("The Coupon name from the response of RedeemMemberCouponByCertNumber method is: " + certDetails.CouponDefinition.Name + "; the redemption date is: " + dbRedemptionDate + "; and coupon status is:" + dbStatus); Logger.Info("TestStep: " + stepName + " ##Passed## The Coupon name from the response of RedeemMemberCouponByCertNumber method is: " + certDetails.CouponDefinition.Name + " and; the redemption date is: " + dbRedemptionDate + " and coupon status is:" + dbStatus); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Unredeem the above member coupon using certNumber using UnRedeemMemberCouponByCertNumber method"; cdis_Service_Method.UnRedeemMemberCouponByCertNumber(validCertNumber, out time); string dbRedemptionDateAfterUnRedeem = DatabaseUtility.GetFromSoapDB("LW_MEMBERCOUPON", "CERTIFICATENMBR", validCertNumber, "DATEREDEEMED", string.Empty); string dbStatusAfterUnRedeem = DatabaseUtility.GetFromSoapDB("LW_MEMBERCOUPON", "CERTIFICATENMBR", validCertNumber, "STATUS", string.Empty); Assert.AreEqual("", dbRedemptionDateAfterUnRedeem, "Expected value is [] Actual value is" + dbRedemptionDateAfterUnRedeem); Assert.AreEqual("Active", dbStatusAfterUnRedeem, "Expected value is Active" + " and Actual value is" + dbStatusAfterUnRedeem); testStep.SetOutput("After unredeeming the coupon:; the redemption date is: [NULL]" + dbRedemptionDateAfterUnRedeem + ";coupon status is:" + dbStatusAfterUnRedeem); Logger.Info("TestStep: " + stepName + " ##Passed## After unredeeming the coupon:; the redemption date is: " + dbRedemptionDateAfterUnRedeem + ";coupon status is:" + dbStatusAfterUnRedeem); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); Logger.Info("###Test Execution Ends### Test Passed: " + testCase.GetTestCaseName()); testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); Logger.Info("Test Failed: " + testCase.GetTestCaseName() + "Reason: " + e.Message); testCase.SetErrorMessage(e.Message); Assert.Fail(e.Message); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA230_CDIS_GetRewardCatalogItem_PositiveCase() { testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); String stepName = ""; Dictionary <string, string> productListVerify = new Dictionary <string, string>(); try { Common common = new Common(this.DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); IList <JToken> JsonData = ProjectBasePage.GetJSONData("CommonSqlStatements"); string sqlstmt = (string)JsonData.FirstOrDefault()["Get_Reward_With_PartNumber"]; Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get a valid certificateNumber from LW_MemberCoupon table"; string validRewardIDWithPartNumber = DatabaseUtility.GetFromSoapDB(string.Empty, string.Empty, string.Empty, "ID", sqlstmt); //Logger.Info("Test Method Started"); //testStep = TestStepHelper.StartTestStep(testStep); //stepName = "Get Reward using GetRewardCatalog CDIS service"; //RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRewardCatalog(); //testStep.SetOutput("The RewardID is : " + rewardCatalog[0].RewardID + " and the reward name is :" + rewardCatalog[0].RewardName); //Logger.Info("RewardID:" + rewardCatalog[0].RewardID); //testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); //listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Reward Catalog Item for the above reward with CDIS service"; // RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRewardCatalog(); RewardCatalogItemStruct rewardCatalogItem = cdis_Service_Method.GetRewardCatalogItem(long.Parse(validRewardIDWithPartNumber)); testStep.SetOutput("The Product details for the above reward from response are ; ProductName: " + rewardCatalogItem.Product.ProductName + "; Product ID: " + rewardCatalogItem.Product.ProductID); //"; ProductVariantID: " + rewardCatalogItem.Product.ProductVariant[0].ProductVariantID + //"; ProductVariant_Description: " + rewardCatalogItem.Product.ProductVariant[0].Description + //"; ProductVariant_PartNumber: " + rewardCatalogItem.Product.ProductVariant[0].PartNumber + //"; ProductVariant_Quantity: " + rewardCatalogItem.Product.ProductVariant[0].Quantity + //"; ProductVariant_VariantOrder: " + rewardCatalogItem.Product.ProductVariant[0].VariantOrder); Logger.Info("ProductName: " + rewardCatalogItem.Product.ProductName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating reward details from DB"; // productListVerify = DatabaseUtility.GetRewardCatalogitemfromDBUsingIdSOAP(rewardCatalogItem.Product.ProductID + ""); string id = DatabaseUtility.GetFromSoapDB("lw_product", "ID", rewardCatalogItem.Product.ProductID.ToString(), "ID", string.Empty); string name = DatabaseUtility.GetFromSoapDB("lw_product", "NAME", rewardCatalogItem.Product.ProductName.ToString(), "NAME", string.Empty); // Assert.AreEqual(rewardCatalogItem.Product.ProductVariant[0].Description, productListVerify["ProductvariantDescription"], "Expected Value is " + rewardCatalogItem.Product.ProductVariant[0].Description + " Actual Value is " + productListVerify["ProductvariantDescription"]); Assert.AreEqual(rewardCatalogItem.Product.ProductName, name, "Expected Value is " + rewardCatalogItem.Product.ProductName + " Actual Value is " + name); Assert.AreEqual(rewardCatalogItem.Product.ProductID.ToString(), id, "Expected Value is " + rewardCatalogItem.Product.ProductID + " Actual Value is " + id); //Assert.AreEqual(rewardCatalogItem.Product.ProductVariant[0].ProductVariantID.ToString(), productListVerify["ProductvariantID"], "Expected Value is " + rewardCatalogItem.Product.ProductVariant[0].ProductVariantID + " Actual Value is " + productListVerify["ProductvariantID"]); //Assert.AreEqual(rewardCatalogItem.Product.ProductVariant[0].PartNumber, productListVerify["ProductvariantPartNumber"], "Expected Value is " + rewardCatalogItem.Product.ProductVariant[0].PartNumber + " Actual Value is " + productListVerify["ProductvariantPartNumber"]); //Assert.AreEqual(rewardCatalogItem.Product.ProductVariant[0].Quantity.ToString(), productListVerify["ProductvariantQuantity"], "Expected Value is " + rewardCatalogItem.Product.ProductVariant[0].Quantity + " Actual Value is " + productListVerify["ProductvariantQuantity"]); //Assert.AreEqual(rewardCatalogItem.Product.ProductVariant[0].VariantOrder.ToString(), productListVerify["ProductvariantOrder"], "Expected Value is " + rewardCatalogItem.Product.ProductVariant[0].VariantOrder + " Actual Value is " + productListVerify["ProductvariantOrder"]); testStep.SetOutput("The Product details from DB are ; ProductName: " + name + "; Product ID: " + id); //"; ProductVariantID: " + productListVerify["ProductvariantID"] + //"; ProductVariant_Description: " + productListVerify["ProductvariantDescription"] + //"; ProductVariant_PartNumber: " + productListVerify["ProductvariantPartNumber"] + //"; ProductVariant_Quantity: " + productListVerify["ProductvariantQuantity"] + //"; ProductVariant_VariantOrder: " + productListVerify["ProductvariantOrder"]); 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.ToString()); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }