public void BTA574_MP_Verify_SocialMediaForRewardsAndCoupon() { ProjectBasePage basePages = new ProjectBasePage(driverContext); NonAdminUserData WebsiteData = new NonAdminUserData(driverContext); testCase = new TestCase(TestContext.TestName); listOfTestSteps = new List <TestStep>(); testStep = new TestStep(); string stepName = ""; try { #region Object Initialization var userName = NavigatorUsers.NonAdminUser; var password = NavigatorUsers.NavigatorPassword; var navigator_LoginPage = new Navigator_LoginPage(DriverContext); var navigator_UsersHomePage = new Navigator_UsersHomePage(DriverContext); var application_Nav_Util_Page = new Application_Nav_Util_Page(DriverContext); var websitePage = new Navigator_Users_WebsitePage(DriverContext); var modulesPage = new Navigator_Users_Website_ModulesPage(DriverContext); common = new Common(DriverContext); CDIS_Service_Methods cdis_Service_Method = new CDIS_Service_Methods(common); var MPortal_LoginPage = new MemberPortal_LoginPage(DriverContext); var MPortal_MyWalletPage = new MemberPortal_MyWalletPage(DriverContext); var MPortal_MyAccountPage = new MemberPortal_MyAccountPage(DriverContext); #endregion #region Part1: Navigator portal-Enable social media for rewards and coupons #region Step1:Launch Navigator Portal stepName = "Launch Navigator URL"; testStep = TestStepHelper.StartTestStep(testStep); navigator_LoginPage.LaunchNavigatorPortal(login.Url, out string LaunchMessage); testStep.SetOutput(LaunchMessage); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step2:Login As User with All roles User stepName = "Login As User Admin User and Navigate to Home page by selecting Organization and Environment"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = userName; login.Password = password; navigator_LoginPage.Login(login, Users.AdminRole.USER.ToString(), out string stroutput); testStep.SetOutput(stroutput); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step3 : Select organization and environment on USER Home page" stepName = "Select organization and environment on USER page"; testStep = TestStepHelper.StartTestStep(testStep); navigator_UsersHomePage.Navigator_Users_SelectOrganizationEnvironment(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step4: Navigate to Website > Modules page stepName = "Navigate to Website > Modules page"; testStep = TestStepHelper.StartTestStep(testStep); application_Nav_Util_Page.OpenApplication(NavigatorEnums.ApplicationName.website); websitePage.NavigateToWebsiteTab(Navigator_Users_WebsitePage.WebsiteTabs.Modules, out stroutput); testStep.SetOutput(stroutput); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step5: Enable Social Media for Coupons stepName = "Enable Social Media for Coupons"; testStep = TestStepHelper.StartTestStep(testStep); var webSiteName = WebsiteData.MemberPortal_WebSiteName; var moduleType = EnumUtils.GetDescription(Navigator_Users_Website_ModulesPage.ModuleTypeList.CouponsListView); var configName = Navigator_Users_Website_ModulesPage.ConfigNames.CFCoupons_Config.ToString(); modulesPage.EnableSocialMedia(moduleType, webSiteName, configName, out stroutput); testStep.SetOutput(stroutput); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step6: Enable Social Media for Rewards stepName = "Enable Social Media for Rewards"; testStep = TestStepHelper.StartTestStep(testStep); moduleType = EnumUtils.GetDescription(Navigator_Users_Website_ModulesPage.ModuleTypeList.RewardHistoryListView); configName = Navigator_Users_Website_ModulesPage.ConfigNames.CFRewardsHistory_Config.ToString(); moduleType = "Reward History - List View"; configName = "CFRewardsHistory_Config"; websitePage.NavigateToWebsiteTab(Navigator_Users_WebsitePage.WebsiteTabs.Modules, out string msg); modulesPage.EnableSocialMedia(moduleType, webSiteName, configName, out stroutput); testStep.SetOutput(stroutput); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step7:Bounce the Member portal App pool stepName = "Bounce the Member Portal App pool"; testStep = TestStepHelper.StartTestStep(testStep); var WebsiteManagement = new Navigator_Users_WebsiteManagementPage(DriverContext); WebsiteManagement.Navigator_Website_Select_WebsiteManagementTab(); WebsiteManagement.BounceAppPool("MemberPortal"); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step8: Logout stepName = "Logout from USER page"; testStep = TestStepHelper.StartTestStep(testStep); navigator_LoginPage.Logout(); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #endregion #region Part2: Creating members using CDIS service and adding rewards and coupons #region Step9: Adding member with CDIS service cdis_Service_Method = new CDIS_Service_Methods(common); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = basePages.CreateMemberThroughCDIS(); testStep.SetOutput("Member UserName:"******"; Member First Name:" + output.FirstName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); #endregion #region Step10: Getting Coupon Definitions from Service IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Getting Coupon Definitions from Service"; GetCouponDefinitionsOut def = cdis_Service_Method.GetCouponDefinitions(); testStep.SetOutput("First Coupon Name : " + def.CouponDefinition[1].Name); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); #endregion #region Step11: Adding Coupon to member from Service testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding Coupon to member from Service"; long memberCouponId = cdis_Service_Method.AddMemberCoupon(vc[0].LoyaltyIdNumber, def.CouponDefinition[0].Id); testStep.SetOutput("MemberCoupon Added to the user : "******"API")); listOfTestSteps.Add(testStep); #endregion #region Step12: Get Recent Reward Catalog with CDIS service testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Recent Reward Catalog with CDIS service"; RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRecentRewardCatalog(0, 0, 0); RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); foreach (RewardCatalogSummaryStruct r in rewardCatalog) { if (r.CurrencyToEarn == 0) { reward = r; break; } } testStep.SetOutput("RewardID:" + reward.RewardID + " and the reward name is :" + reward.RewardName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); #endregion #region Step13: Add Members to Reward Catalog with CDIS service vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Members to Reward Catalog with CDIS service"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("The reward with RewardID:" + memberRewardsOut.MemberRewardID + " has been added to the member with IPCODE: " + output.IpCode); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); #endregion #endregion #region Part3: Verifying the social media share options on Member Portal #region Step14:Launch Member Portal stepName = "Launch Member Portal URL"; testStep = TestStepHelper.StartTestStep(testStep); MPortal_LoginPage.LaunchMemberPortal(login.MemberPortal_url, out string Output); testStep.SetOutput(Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step15: Login As Member stepName = "Login As Member User"; testStep = TestStepHelper.StartTestStep(testStep); login.UserName = output.Username; login.Password = "******"; MPortal_LoginPage.LoginMemberPortal(login.UserName, login.Password, out string Message); testStep.SetOutput(Message); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step16: Navigate to Mywallet page stepName = "Navigate to Mywallet page"; testStep = TestStepHelper.StartTestStep(testStep); MPortal_MyAccountPage.NavigateToMPDashBoardMenu(MemberPortal_MyAccountPage.MPDashboard.MyWallet, out string message); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step17: Verify My Reward Social media share options stepName = "Verify My Reward Social Media Share Options"; testStep = TestStepHelper.StartTestStep(testStep); MPortal_MyWalletPage.VerifySociaMediaOptionsForRewardsAndCoupons("rewards", out var Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step18: Verify My Coupons Social media share options stepName = "Verify My Coupons Social Media Share Options"; testStep = TestStepHelper.StartTestStep(testStep); MPortal_MyAccountPage.NavigateToMPDashBoardMenu(MemberPortal_MyAccountPage.MPDashboard.MyWallet, out message); var stepstatus = MPortal_MyWalletPage.VerifySociaMediaOptionsForRewardsAndCoupons("coupons", out Step_Output); testStep.SetOutput(Step_Output); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, stepstatus, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #region Step19: Logout from member portal stepName = "Logout from Member Portal"; testStep = TestStepHelper.StartTestStep(testStep); MPortal_LoginPage.LogoutMPPortal(); testStep.SetOutput("Logout from Member Portal is Successful"); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); #endregion #endregion testCase.SetStatus(true); } catch (Exception e) { testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB")); listOfTestSteps.Add(testStep); testCase.SetStatus(false); testCase.SetErrorMessage(e.Message); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString()); Assert.Fail(); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1242_ST1565_SOAP_GetAllRewardOrderShippingAddresses_TerminatedMember() { 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); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Recent Reward Catalog with CDIS service"; var reward = cdis_Service_Method.getReward(); testStep.SetOutput("RewardID:" + reward.RewardID + " and the reward name is :" + reward.RewardName); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Members Rewards with CDIS service"; Hashtable addressData = cdis_Service_Method.SetRewardOrderShippingAddress(); List <Object> addressList = new List <Object>(); ICollection key = addressData.Keys; foreach (string k in key) { addressList.Add(addressData[k]); } AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, "testFirst", "testLast", "*****@*****.**", (string)addressData["addresslineone"], (string)addressData["addresslinetwo"], (string)addressData["addresslinethree"], (string)addressData["addresslinefour"], (string)addressData["city"], (string)addressData["state"], (string)addressData["ziporpostalcode"], (string)addressData["county"], (string)addressData["country"], "Web", "SOAP", reward); testStep.SetOutput("The reward with RewardID:" + memberRewardsOut.MemberRewardID + " has been added to the member with IPCODE: " + output.IpCode); Logger.Info("member RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Verify the members rewardid in DB and fetch his membersrewardsID"; string dbresponse = DatabaseUtility.GetMemberRewardIDfromDBUsingIdSOAP(output.IpCode + "", reward.RewardID + ""); Assert.AreEqual(memberRewardsOut.MemberRewardID + "", dbresponse, "Expected Value is " + memberRewardsOut.MemberRewardID.ToString() + " Actual Value is " + dbresponse); testStep.SetOutput("memberrewardid from the database is: " + dbresponse + " for a member with IPCode: " + output.IpCode + " and rewardID: " + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Terminating the member"; //cdis_Service_Method.TerminateMember(vc[0].LoyaltyIdNumber); string actualMessage = cdis_Service_Method.TerminateMember(vc[0].LoyaltyIdNumber, DateTime.Now, "SOAP_Automation", String.Empty, out elapsedTime); Assert.AreEqual("pass", actualMessage, "Member with loyality id number : " + vc[0].LoyaltyIdNumber + " is not terminated"); var getAccountSummary = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("Member detail's: IPCODE: " + vc[0].IpCode + " and member status is:" + getAccountSummary.MemberStatus); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating the Member status for Terminated member from database"; dbresponse = DatabaseUtility.GetMemberStatusfromDbSOAP(output.IpCode + ""); string value = (Member_Status)Int32.Parse(dbresponse) + ""; Assert.AreEqual(Member_Status.Terminated.ToString(), value, "Expected value is" + Member_Status.Terminated.ToString() + "Actual value is" + value); testStep.SetOutput("The card status from database for terminated member is : \"" + dbresponse + "\" and the member status: " + (Member_Status)Int32.Parse(dbresponse)); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testCase.SetStatus(true); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get All the Rewards Orders shipping addresses for Terminated member"; ShippingAddressStruct[] address = cdis_Service_Method.GetAllRewardOrderShippingAddresses(vc[0].LoyaltyIdNumber); List <string> addressFromResponse = new List <string>(); addressFromResponse.Add(address[0].AddressLineOne); addressFromResponse.Add(address[0].AddressLineTwo); addressFromResponse.Add(address[0].AddressLineThree); addressFromResponse.Add(address[0].AddressLineFour); addressFromResponse.Add(address[0].City); addressFromResponse.Add(address[0].StateOrProvince); addressFromResponse.Add(address[0].ZipOrPostalCode); addressFromResponse.Add(address[0].County); addressFromResponse.Add(address[0].Country); addressFromResponse.Add(address[0].County); IEnumerable <object> finalData = addressList.Except(addressFromResponse); if (!finalData.Any()) { testStep.SetOutput("Member's reward order shipping addresses is returned successfully"); } else { throw new Exception("Member's reward order shipping addresses is different from the actual data"); } 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); } }
public void BTA1243_ST1354_SOAP_IsMemberRewardRedeemed_PassInvalidRewardId_Negative() { 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); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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 = "Get Recent Reward Catalog with GetRewardCatalog service"; RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRecentRewardCatalog(0, 0, 0); RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); foreach (RewardCatalogSummaryStruct r in rewardCatalog) { if (r.CurrencyToEarn == 0) { reward = r; break; } } testStep.SetOutput("The RewardID from the response of GetRewardCatalog method is : " + reward.RewardID); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Reward to Member using AddMemberRewards service"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("The membersRewardID is: " + memberRewardsOut.MemberRewardID); Logger.Info("RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Verify whether the member reward is redeemed or not by passing Invalid RewardID"; string error = (string)cdis_Service_Method.IsMemberRewardRedeemedIDNegative(); testStep.SetOutput("Throws an expection with the " + error); string[] errors = error.Split(';'); string[] errorssplit = errors[0].Split('='); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating the response for Error Code as 3347"; Assert.AreEqual("3347", errorssplit[1], "Expected value is" + "3347" + "Actual value is" + errorssplit[1]); testStep.SetOutput("The ErrorMessage from Service is: " + errors[1]); 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); } }
public void BTA233_CDIS_GetMemberRewardsSummary_PositiveCase() { 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); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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 = "Get \"Reward Definition\" from GetRewardCatalog method"; //RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRecentRewardCatalog(0,0,0); //RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); //foreach (RewardCatalogSummaryStruct r in rewardCatalog) //{ // if (r.CurrencyToEarn == 0) // { // reward = r; // break; // } //} var reward = cdis_Service_Method.getReward(); testStep.SetOutput("The following reward is fetched from GetRewardCatalog method; RewardID: " + reward.RewardID + ";Rewardname: " + reward.RewardName); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Reward to the above Member"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("Reward added sucessfully and the; membersRewardID : " + memberRewardsOut.MemberRewardID); Logger.Info("RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Verify MemberRewardID, RewardDefID and RewardName from response of the GetMemberRewardsSummary method matches with the reward added through AddMemberreward method"; MemberRewardSummaryStruct[] memberRewardSummaryStruct = cdis_Service_Method.GetMemberRewardsSummary(vc[0].LoyaltyIdNumber); Assert.AreEqual(memberRewardSummaryStruct[0].MemberRewardID, memberRewardsOut.MemberRewardID, "Expected Value is " + memberRewardSummaryStruct[0].MemberRewardID + " Actual Value is " + memberRewardsOut.MemberRewardID); Assert.AreEqual(memberRewardSummaryStruct[0].RewardDefID, reward.RewardID, "Expected Value is " + memberRewardSummaryStruct[0].RewardDefID + " Actual Value is " + reward.RewardID); Assert.AreEqual(memberRewardSummaryStruct[0].RewardName, reward.RewardName, "Expected Value is " + memberRewardSummaryStruct[0].RewardName + " Actual Value is " + reward.RewardName); testStep.SetOutput("GetMemberRewardsSumamry's MemberRewardID: " + memberRewardSummaryStruct[0].MemberRewardID + " and the AddMemberReward's MemberRewardsID : " + memberRewardsOut.MemberRewardID + " are matching"); Logger.Info("Member RewardID:" + memberRewardSummaryStruct[0].MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate membersrewardID in lw_memberrewards table"; string dbresponse = DatabaseUtility.GetMemberRewardIDfromDBUsingIdSOAP(output.IpCode + "", reward.RewardID + ""); Assert.AreEqual(memberRewardSummaryStruct[0].MemberRewardID + "", dbresponse, "Expected Value is " + memberRewardSummaryStruct[0].MemberRewardID + " Actual Value is " + dbresponse); testStep.SetOutput("Response from database [MemberRewardID]: " + dbresponse); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Reward Catalog Item with CDIS service"; RewardCatalogItemStruct rewardCatalogItem = cdis_Service_Method.GetRewardCatalogItem(reward.RewardID); testStep.SetOutput("The reward details from RewardCatalogItem for the Reward with ID " + reward.RewardID + " are: ; Reward Name: " + rewardCatalogItem.RewardName + "; Reward ID: " + rewardCatalogItem.RewardID); Logger.Info("Reward ID: " + rewardCatalogItem.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate reward details of RewardCatalogItem response with GetMemberRewardsSumamry method details"; Assert.AreEqual(memberRewardSummaryStruct[0].RewardDefID + "", rewardCatalogItem.RewardID + "", "Expected Value is " + memberRewardSummaryStruct[0].RewardDefID + " Actual Value is " + rewardCatalogItem.RewardID); Assert.AreEqual(memberRewardSummaryStruct[0].RewardName + "", rewardCatalogItem.RewardName, "Expected Value is " + memberRewardSummaryStruct[0].RewardName + " Actual Value is " + rewardCatalogItem.RewardName); testStep.SetOutput("The Reward details from GetRewardCatalogItem are " + "; RewardID: " + rewardCatalogItem.RewardID + ";RewardName: " + rewardCatalogItem.RewardName + "; and Reward details from GetMemberRewardsSumamry are: " + "; RewardID : " + memberRewardSummaryStruct[0].RewardDefID + "; RewardName: " + memberRewardSummaryStruct[0].RewardName); 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); } }
public void BTA235_SOAP_IsMemberRewardRedeemed() { 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); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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 = "Get Recent Reward Catalog with GetRewardCatalog service"; RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRecentRewardCatalog(0, 0, 0); RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); foreach (RewardCatalogSummaryStruct r in rewardCatalog) { if (r.CurrencyToEarn == 0) { reward = r; break; } } testStep.SetOutput("The RewardID from the response of GetRewardCatalog method is : " + reward.RewardID); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Reward to Member using AddMemberRewards service"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("The membersRewardID is: " + memberRewardsOut.MemberRewardID); Logger.Info("RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Verify whether member reward is redeemed using IsMemberRewardRedeemed method"; bool Value = cdis_Service_Method.IsMemberRewardRedeemed(memberRewardsOut.MemberRewardID + "", out time); testStep.SetOutput("The response from the IsMemberRewardRedeemed method is [" + Value + "] which means memberRewardID : " + memberRewardsOut.MemberRewardID + " has not been redeemed"); Logger.Info("Member Reward Redeemed: " + Value); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate the redeemed status"; Assert.AreEqual("False", Value.ToString(), "Expected Value is :False and Actual Value is : " + Value); testStep.SetOutput("IsMemberRewardRedeemed method returns : [" + Value + "]"); 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); } }
//TODO: Need the exact reward name from DB public void BTA1245_ST1781_SOAP_ReturnMemberRewardOrder_OrderNumberExistsPartNumberDoesNotExists() { 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); List <string> CategoryID = new List <string>(); List <string> DBCategoryID = new List <string>(); string errorCode = "3355"; string expectedMessage = "Order number not found."; try { Logger.Info("Test Method Started: " + testCase.GetTestCaseName()); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); testStep.SetOutput("IpCode: " + output.IpCode + ", Name: " + output.FirstName);; Logger.Info("TestStep: " + stepName + " ##Passed## IpCode:" + output.IpCode + ", Name: " + output.FirstName); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Award LoyaltyCurrency to a member using AwardLoyaltyCurrency method"; decimal? amount = 100; DateTime expirationdate = new DateTime(DateTime.Now.Year, 12, 31); DateTime?transactiondate = DateTime.Now; AwardLoyaltyCurrencyOut awardLoyaltyCurrency = cdis_Service_Method.AwardLoyaltyCurrency(vc[0].LoyaltyIdNumber, LoyaltyEvents.PurchaseActivity, LoyaltyCurrency.BasePoints, amount, transactiondate, expirationdate, "Awarding new amounts", "SOAPService"); GetAccountSummaryOut getInitialAccountSummary = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); decimal initialBalance = getInitialAccountSummary.CurrencyBalance; testStep.SetOutput("The LoyaltyCurrencyBalance awarded to the member is: " + awardLoyaltyCurrency.CurrencyBalance.ToString()); Logger.Info("TestStep: " + stepName + " ##Passed## The LoyaltyCurrencyBalance awarded to the member is: " + awardLoyaltyCurrency.CurrencyBalance.ToString()); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Members rewards with CDIS service"; RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); reward.RewardName = DatabaseUtility.GetFromSoapDB("LW_REWARDSDEF", "name", "ZeroBalanceReward", "name", string.Empty); AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("The reward with RewardID:" + memberRewardsOut.MemberRewardID + " has been added to the member with IPCODE: " + output.IpCode); Logger.Info("member RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Return member rewards based on the Order number where order number exists and part number does not exists"; string orderNumber = memberRewardsOut.OrderNumber; string message = cdis_Service_Method.ReturnMemberRewardOrder(orderNumber, out elapsedTime); Assert.AreEqual(message.Contains(errorCode), true, "Error code received is different and is : " + errorCode + " for the member with order number: " + orderNumber); Assert.AreEqual(message.Contains(expectedMessage), true, "Error message received is different and is : " + expectedMessage + " for the member with order number: " + orderNumber); testStep.SetOutput("Returned error code: " + errorCode + " and Error message : " + expectedMessage); 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 BTA232_CDIS_GetMemberRewards_PositiveCase() { 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); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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 = "Get \"Reward Definition\" from GetRewardCatalog method"; var reward = cdis_Service_Method.getReward(); testStep.SetOutput("The following reward is fetched from GetRewardCatalog method; RewardID: " + reward.RewardID + ";Rewardname: " + reward.RewardName); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Reward to the above Member"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("Reward added sucessfully and the; membersRewardID : " + memberRewardsOut.MemberRewardID); Logger.Info("RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Members Rewards with CDIS service"; MemberRewardOrderStruct[] memberRewards = cdis_Service_Method.GetMemberRewards(vc[0].LoyaltyIdNumber); Assert.AreEqual(output.FirstName, memberRewards[0].FirstName, "Expected Value is " + output.FirstName + " Actual Value is " + memberRewards[0].FirstName); Assert.AreEqual(memberRewardsOut.MemberRewardID, memberRewards[0].MemberRewardInfo[0].MemberRewardID, "Expected Value is " + memberRewardsOut.MemberRewardID + " Actual Value is " + memberRewards[0].MemberRewardInfo[0].MemberRewardID); Assert.AreEqual(reward.RewardID, memberRewards[0].MemberRewardInfo[0].RewardDefID, "Expected Value is " + reward.RewardID + " Actual Value is " + memberRewards[0].MemberRewardInfo[0].RewardDefID); testStep.SetOutput("The member (IPCODE: " + output.IpCode + ", FirstName: " + output.FirstName + ") rewards details are: " + "; MemberRewardID: " + memberRewards[0].MemberRewardInfo[0].MemberRewardID + "; and the Reward Definition ID is : " + memberRewards[0].MemberRewardInfo[0].RewardDefID); Logger.Info("Member RewardID:" + memberRewards[0].MemberRewardInfo[0].MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validate \"MemberRewardID\" for the member in DB"; string dbresponse = DatabaseUtility.GetMemberRewardIDfromDBUsingIdSOAP(output.IpCode + "", reward.RewardID + ""); testStep.SetOutput("MemberRewardID from database : " + dbresponse); Assert.AreEqual(memberRewards[0].MemberRewardInfo[0].MemberRewardID + "", dbresponse, "Expected Value is " + memberRewards[0].MemberRewardInfo[0].MemberRewardID + " 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.ToString()); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA249_SOAP_CancelMemberReward() { 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); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Award Loyalty Balance"; AwardLoyaltyCurrencyOut loyaltyCurrencyOut = cdis_Service_Method.AwardLoyaltyCurrency(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty currency balance of the member is: " + loyaltyCurrencyOut.CurrencyBalance); Logger.Info("Balance of Account after awarding loyalty currency" + loyaltyCurrencyOut.CurrencyBalance); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Account Activity Summary through GetAccountSummary method"; GetAccountSummaryOut AccountSummaryOutBeforeReward = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty Currency of the member before adding the reward is " + AccountSummaryOutBeforeReward.CurrencyBalance); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Recent Reward Catalog with GetRewardCatalog service"; RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRecentRewardCatalog(0, 100, 100); RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); foreach (RewardCatalogSummaryStruct r in rewardCatalog) { if (r.CurrencyToEarn == 100) { reward = r; break; } } testStep.SetOutput("The RewardID from the response of GetRewardCatalog method is : " + reward.RewardID + " and the reward name is: " + reward.RewardName); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); // IList<VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Reward to Member using AddMemberRewards service"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("The membersRewardID is: " + memberRewardsOut.MemberRewardID); Logger.Info("RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Account Activity Summary through GetAccountSummary method"; GetAccountSummaryOut AccountSummaryOutAfterReward = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty Currency of the member after adding reward is " + AccountSummaryOutAfterReward.CurrencyBalance); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Cancelling the member reward with CDIS service"; decimal value = cdis_Service_Method.CancelMemberReward(memberRewardsOut.MemberRewardID + "", out time); testStep.SetOutput("The Loyalty currency balance from the CancelMemberReward response is :" + value); Logger.Info("Value from the service:" + value); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Account Activity Summary through GetAccountSummary method after cancelling the reward"; AccountSummaryOutBeforeReward = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty Currency of the member after cancelling the reward is " + AccountSummaryOutBeforeReward.CurrencyBalance); Assert.AreEqual(AccountSummaryOutBeforeReward.CurrencyBalance, value, "Expected Value is " + AccountSummaryOutBeforeReward.CurrencyBalance + " Actual Value is " + value); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating the reward status with data from the DB"; string dbresponse = DatabaseUtility.GetMemberRewardStatusfromDBUsingIdSOAP(output.IpCode + "", reward.RewardID + ""); testStep.SetOutput("The Reward status from database : " + dbresponse); Assert.AreEqual("Cancelled", dbresponse, "Expected Value is " + "Cancelled" + " 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.ToString()); } finally { testCase.SetTestCaseSteps(listOfTestSteps); testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow()); listOfTestCases.Add(testCase); } }
public void BTA1241_ST1326_SOAP_CancelMemberReward_InvalidMemberRewardId_Negative() { 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); stepName = "Adding member with CDIS service"; Member output = cdis_Service_Method.GetCDISMemberGeneral(); 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); IList <VirtualCard> vc = output.GetLoyaltyCards(); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Award Loyalty Balance"; AwardLoyaltyCurrencyOut loyaltyCurrencyOut = cdis_Service_Method.AwardLoyaltyCurrency(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty currency balance of the member is: " + loyaltyCurrencyOut.CurrencyBalance); Logger.Info("Balance of Account after awarding loyalty currency" + loyaltyCurrencyOut.CurrencyBalance); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Account Activity Summary through GetAccountSummary method"; GetAccountSummaryOut AccountSummaryOutBeforeReward = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty Currency of the member before adding the reward is " + AccountSummaryOutBeforeReward.CurrencyBalance); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Recent Reward Catalog with GetRewardCatalog service"; RewardCatalogSummaryStruct[] rewardCatalog = cdis_Service_Method.GetRecentRewardCatalog(0, 100, 100); RewardCatalogSummaryStruct reward = new RewardCatalogSummaryStruct(); foreach (RewardCatalogSummaryStruct r in rewardCatalog) { if (r.CurrencyToEarn == 100) { reward = r; break; } } testStep.SetOutput("The RewardID from the response of GetRewardCatalog method is : " + reward.RewardID + " and the reward name is: " + reward.RewardName); Logger.Info("RewardID:" + reward.RewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Add Reward to Member using AddMemberRewards service"; AddMemberRewardsOut memberRewardsOut = (AddMemberRewardsOut)cdis_Service_Method.AddMemberRewards(vc[0].LoyaltyIdNumber, vc[0].LoyaltyIdNumber, reward); testStep.SetOutput("The membersRewardID is: " + memberRewardsOut.MemberRewardID); Logger.Info("RewardID:" + memberRewardsOut.MemberRewardID); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Get Account Activity Summary through GetAccountSummary method"; GetAccountSummaryOut AccountSummaryOutAfterReward = cdis_Service_Method.GetAccountSummary(vc[0].LoyaltyIdNumber); testStep.SetOutput("The loyalty Currency of the member after adding reward is " + AccountSummaryOutAfterReward.CurrencyBalance); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Cancelling the member reward with CDIS service by providing invalid member reward id"; string error = (string)cdis_Service_Method.CancelMemberRewardNegative(); testStep.SetOutput("Throws an expection with the " + error); string[] errors = error.Split(';'); string[] errorssplit = errors[0].Split('='); testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("API")); listOfTestSteps.Add(testStep); testStep = TestStepHelper.StartTestStep(testStep); stepName = "Validating the response for Error Code as 3356"; Assert.AreEqual("3356", errorssplit[1], "Expected value is" + "3356" + "Actual value is" + errorssplit[1]); testStep.SetOutput("The ErrorMessage from Service is: " + errors[1]); 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); } }