public void StateFormatter_CollectionFormatter () { WebTest t = new WebTest ("StateFormatter_CollectionConverter.aspx"); t.Run (); var fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("btnSearch"); fr.Controls.Add ("ddlDate"); fr.Controls.Add ("txtSearchValue"); fr.Controls ["btnSearch"].Value = "Search"; fr.Controls ["ddlDate"].Value = "2009"; t.Request = fr; string pageHtml = t.Run (); string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml); string originalHtml = @"<div> <table id=""gvECCN"" cellspacing=""0"" rules=""all"" border=""1"" style=""border-collapse:collapse;""> <tr> <th align=""left"" scope=""col""> </th><th align=""left"" scope=""col"">Schedule B</th><th align=""left"" scope=""col"">Count</th><th align=""left"" scope=""col"">Total</th><th align=""left"" scope=""col"">Percent</th> </tr><tr> <td style=""height:18px;width:30px;"">1</td><td style=""width:140px;"">test</td><td style=""width:90px;"">1</td><td style=""width:100px;"">100</td><td style=""width:90px;"">250.00 %</td> </tr> </table> </div>"; HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1"); }
public void CrossPagePosting_BaseFixture () { WebTest t = new WebTest ("CrossPagePosting1.aspx"); string html = t.Run (); if (html.IndexOf ("LinkButtonText") < 0) Assert.Fail ("Link button not created fail"); PageDelegates pd = new PageDelegates (); pd.Load = Load; t.Invoker = new PageInvoker (pd); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "LinkButton1"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; fr.Url = "CrossPagePosting2.aspx"; html = t.Run (); if (html.IndexOf ("CrossedPostbackPage") < 0) Assert.Fail ("CrossPagePosting removeing to target page fail"); }
public void StateFormatter_CorrectConverter () { // We test only if it doesn't throw exception on postback WebTest t = new WebTest ("StateFormatter_CorrectConverter.aspx"); t.Run (); var fr = new FormRequest (t.Response, "Form1"); fr.Controls.Add ("Button1"); fr.Controls ["Button1"].Value = "Change"; t.Request = fr; t.Run (); fr = new FormRequest (t.Response, "Form1"); fr.Controls.Add ("Button2"); fr.Controls ["Button2"].Value = "Refresh"; }
[Category ("NotDotNet")] // for dot-net use __CALLBACKID insted __CALLBACKTARGET and __CALLBACKARGUMENT insted __CALLBACKPARAM public void CallBackResulrValues () { WebTest t = new WebTest ("CallbackTest1.aspx"); string html = t.Run (); PageDelegates pd = new PageDelegates (); pd.Load = Load; t.Invoker = new PageInvoker (pd); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("__CALLBACKTARGET"); fr.Controls.Add ("__CALLBACKARGUMENT"); fr.Controls["__EVENTTARGET"].Value = ""; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls ["__CALLBACKTARGET"].Value = "__Page"; fr.Controls ["__CALLBACKARGUMENT"].Value = "monitor"; t.Request = fr; html = t.Run (); // Into result string the last 2 variables shows if events been done // first - RaiseCallbackEvent // second - GetCallbackResult if (html.IndexOf ("12|true|true") < 0) Assert.Fail ("CallBack#1"); fr.Controls["__EVENTTARGET"].Value = ""; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls ["__CALLBACKTARGET"].Value = "__Page"; fr.Controls ["__CALLBACKARGUMENT"].Value = "laptop"; t.Request = fr; html = t.Run (); // Into result string the last 2 variables shows if events been done // first - RaiseCallbackEvent // second - GetCallbackResult if (html.IndexOf ("10|true|true") < 0) Assert.Fail ("CallBack#2"); }
public void StateFormatter_CorrectConverter () { // We test only if it doesn't throw exception on postback try { WebTest.Host.AppDomain.AssemblyResolve += new ResolveEventHandler (ResolveAssemblyHandler); WebTest t = new WebTest ("StateFormatter_CorrectConverter.aspx"); t.Run (); var fr = new FormRequest (t.Response, "Form1"); fr.Controls.Add ("Button1"); fr.Controls ["Button1"].Value = "Change"; t.Request = fr; t.Run (); fr = new FormRequest (t.Response, "Form1"); fr.Controls.Add ("Button2"); fr.Controls ["Button2"].Value = "Refresh"; } finally { WebTest.Host.AppDomain.AssemblyResolve -= new ResolveEventHandler (ResolveAssemblyHandler); } }
public void DetailsView_EditPostback () { WebTest t = new WebTest ("DetailsViewDataActions.aspx"); t.Invoker = PageInvoker.CreateOnLoad (EditPostback_Load); string pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("Edit"), "BeforeEditPostback"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1"; fr.Controls["__EVENTARGUMENT"].Value = "Edit$0"; t.Request = fr; pageHTML = t.Run (); string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td>1001</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td><input name=\"DetailsView1$ctl01\" type=\"text\" value=\"Mahesh\" title=\"FName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td><input name=\"DetailsView1$ctl02\" type=\"text\" value=\"Chand\" title=\"LName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1$ctl03','')\">Update</a> <a href=\"javascript:__doPostBack('DetailsView1','Cancel$0')\">Cancel</a></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><table>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$3')\">3</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; #else string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td>1001</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td><input name=\"DetailsView1$ctl01\" type=\"text\" value=\"Mahesh\" title=\"FName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td><input name=\"DetailsView1$ctl02\" type=\"text\" value=\"Chand\" title=\"LName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1$ctl03','')\">Update</a> <a href=\"javascript:__doPostBack('DetailsView1','Cancel$0')\">Cancel</a></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><table border=\"0\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$3')\">3</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; #endif HtmlDiff.AssertAreEqual (origHtmlValue, renderedHtml, "AfterEditPostback"); // Checking for change mode event fired. ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ModeChanging", eventlist[0], "#1"); Assert.AreEqual ("ModeChanged", eventlist[1], "#2"); }
public void DetailsView_DeletePostback () { WebTest t = new WebTest ("DetailsViewDataActions.aspx"); t.Invoker = PageInvoker.CreateOnLoad (DeletePostback_Load); string pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("1001"), "BeforeDeletePostback"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1"; fr.Controls["__EVENTARGUMENT"].Value = "Delete$0"; t.Request = fr; pageHTML = t.Run (); //Console.WriteLine ("XXXXFAIL {0}", pageHTML); string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td>1002</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td>Melanie</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td>Talmadge</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1','Edit$0')\">Edit</a> <a href=\"javascript:__doPostBack('DetailsView1','Delete$0')\">Delete</a> <a href=\"javascript:__doPostBack('DetailsView1','New$0')\">New</a></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><table>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$2')\">2</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; #else string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td>1002</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td>Melanie</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td>Talmadge</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1','Edit$0')\">Edit</a> <a href=\"javascript:__doPostBack('DetailsView1','Delete$0')\">Delete</a> <a href=\"javascript:__doPostBack('DetailsView1','New$0')\">New</a></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><table border=\"0\">\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$2')\">2</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; #endif HtmlDiff.AssertAreEqual (origHtmlValue, renderedHtml, "DeleteDataPostback"); Assert.AreEqual (false, renderedHtml.Contains ("1001"), "AfterDeletePostback"); // Checking for delete event fired. ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ItemDeleting", eventlist[0], "#1"); Assert.AreEqual ("ItemDeleted", eventlist[1], "#2"); }
public void Menu_PostBackFireEvents_1 () { PageDelegates pd = new PageDelegates (); pd.Init = Menu_SetTableMode; WebTest t = new WebTest ("PostBackMenuTest.aspx"); t.Invoker = new PageInvoker (pd); string str = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "Menu1"; #if DOT_NET fr.Controls["__EVENTARGUMENT"].Value = "root"; // "0_1"; #else fr.Controls ["__EVENTARGUMENT"].Value = "0"; // "0_1"; #endif t.Request = fr; str = t.Run (); Assert.AreEqual ("MenuItemClick", t.UserData.ToString (), "PostBackEvent"); }
public void MultiView_Events_SwitchViewByIndex_PostBack () { WebTest t = new WebTest ("NoEventValidation.aspx"); t.Invoker = PageInvoker.CreateOnInit (new PageDelegate (EventsTest_4)); string html = t.Run (); if (html.IndexOf ("View_1_is_active") < 0) Assert.Fail ("MultiView_Events#1 Failed"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("bt"); fr.Controls["bt"].Value = "Button"; t.Request = fr; html = t.Run (); if (html.IndexOf ("ActiveViewChangedFired") < 0) { Assert.Fail ("MultiView_Events#3 Failed"); } if (html.IndexOf ("View_2_is_active") < 0) Assert.Fail ("MultiView_Events#4 Failed"); }
public void FormView_EditPostback () { WebTest t = new WebTest ("FormViewInsertEditDelete.aspx"); string pageHTML = t.Run (); string newHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 string origHtml = "<table cellspacing=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n <span id=\"FormView1_ID\">1001</span> \n <span id=\"FormView1_LName\">Chand</span>\n <span id=\"FormView1_FName\">Mahesh</span> \n <a id=\"FormView1_EditButton\" href=\"javascript:__doPostBack('FormView1$EditButton','')\">Edit</a>\n <a id=\"FormView1_NewButton\" href=\"javascript:__doPostBack('FormView1$NewButton','')\">New</a>\n <a id=\"FormView1_DeleteButton\" href=\"javascript:__doPostBack('FormView1$DeleteButton','')\">Delete</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #else string origHtml = "<table cellspacing=\"0\" border=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n <span id=\"FormView1_ID\">1001</span> \n <span id=\"FormView1_LName\">Chand</span>\n <span id=\"FormView1_FName\">Mahesh</span> \n <a id=\"FormView1_EditButton\" href=\"javascript:__doPostBack('FormView1$EditButton','')\">Edit</a>\n <a id=\"FormView1_NewButton\" href=\"javascript:__doPostBack('FormView1$NewButton','')\">New</a>\n <a id=\"FormView1_DeleteButton\" href=\"javascript:__doPostBack('FormView1$DeleteButton','')\">Delete</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table border=\"0\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #endif HtmlDiff.AssertAreEqual (origHtml, newHtml, "BeforeEditPostback"); //Edit button postback (change to edit mode - buttons "Update" and "Cancel" should appear. FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$EditButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); newHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 origHtml = "<table cellspacing=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n Enter First Name:<input name=\"FormView1$FNameEdit\" type=\"text\" value=\"Mahesh\" id=\"FormView1_FNameEdit\" /><br />\n Enter Last Name:<input name=\"FormView1$LNameEdit\" type=\"text\" value=\"Chand\" id=\"FormView1_LNameEdit\" /><br />\n <a id=\"FormView1_UpdateButton\" href=\"javascript:__doPostBack('FormView1$UpdateButton','')\">Update</a>\n <a id=\"FormView1_CancelUpdateButton\" href=\"javascript:__doPostBack('FormView1$CancelUpdateButton','')\">Cancel</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #else origHtml = "<table cellspacing=\"0\" border=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n Enter First Name:<input name=\"FormView1$FNameEdit\" type=\"text\" value=\"Mahesh\" id=\"FormView1_FNameEdit\" /><br />\n Enter Last Name:<input name=\"FormView1$LNameEdit\" type=\"text\" value=\"Chand\" id=\"FormView1_LNameEdit\" /><br />\n <a id=\"FormView1_UpdateButton\" href=\"javascript:__doPostBack('FormView1$UpdateButton','')\">Update</a>\n <a id=\"FormView1_CancelUpdateButton\" href=\"javascript:__doPostBack('FormView1$CancelUpdateButton','')\">Cancel</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table border=\"0\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #endif HtmlDiff.AssertAreEqual (origHtml, newHtml, "AfterEditPostback"); //Update record postback fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("FormView1$FNameEdit"); fr.Controls.Add ("FormView1$LNameEdit"); fr.Controls["__EVENTTARGET"].Value = "FormView1$UpdateButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["FormView1$FNameEdit"].Value = "Merav"; fr.Controls["FormView1$LNameEdit"].Value = "Test"; t.Request = fr; pageHTML = t.Run (); newHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 origHtml = "<table cellspacing=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n <span id=\"FormView1_ID\">1001</span> \n <span id=\"FormView1_LName\">Test</span>\n <span id=\"FormView1_FName\">Merav</span> \n <a id=\"FormView1_EditButton\" href=\"javascript:__doPostBack('FormView1$EditButton','')\">Edit</a>\n <a id=\"FormView1_NewButton\" href=\"javascript:__doPostBack('FormView1$NewButton','')\">New</a>\n <a id=\"FormView1_DeleteButton\" href=\"javascript:__doPostBack('FormView1$DeleteButton','')\">Delete</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #else origHtml = "<table cellspacing=\"0\" border=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n <span id=\"FormView1_ID\">1001</span> \n <span id=\"FormView1_LName\">Test</span>\n <span id=\"FormView1_FName\">Merav</span> \n <a id=\"FormView1_EditButton\" href=\"javascript:__doPostBack('FormView1$EditButton','')\">Edit</a>\n <a id=\"FormView1_NewButton\" href=\"javascript:__doPostBack('FormView1$NewButton','')\">New</a>\n <a id=\"FormView1_DeleteButton\" href=\"javascript:__doPostBack('FormView1$DeleteButton','')\">Delete</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table border=\"0\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #endif HtmlDiff.AssertAreEqual (origHtml, newHtml, "AfterUpdatePostback"); //Postback to return to Edit mode fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$EditButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); newHtml = pageHTML.Substring (pageHTML.IndexOf ("start") + 5, pageHTML.IndexOf ("end") - pageHTML.IndexOf ("start") - 5); Assert.AreEqual (true, pageHTML.Contains ("Merav"), "EditModePostback1"); Assert.AreEqual (true, pageHTML.Contains ("CancelUpdateButton"), "EditModePostback2"); // Cancel edited record postback fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("FormView1$FNameEdit"); fr.Controls.Add ("FormView1$LNameEdit"); fr.Controls["FormView1$FNameEdit"].Value = "EditFirstName"; fr.Controls["FormView1$LNameEdit"].Value = "EditLastName"; fr.Controls["__EVENTTARGET"].Value = "FormView1$CancelUpdateButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); newHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 origHtml = "<table cellspacing=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n <span id=\"FormView1_ID\">1001</span> \n <span id=\"FormView1_LName\">Test</span>\n <span id=\"FormView1_FName\">Merav</span> \n <a id=\"FormView1_EditButton\" href=\"javascript:__doPostBack('FormView1$EditButton','')\">Edit</a>\n <a id=\"FormView1_NewButton\" href=\"javascript:__doPostBack('FormView1$NewButton','')\">New</a>\n <a id=\"FormView1_DeleteButton\" href=\"javascript:__doPostBack('FormView1$DeleteButton','')\">Delete</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table>\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #else origHtml = "<table cellspacing=\"0\" border=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n <span id=\"FormView1_ID\">1001</span> \n <span id=\"FormView1_LName\">Test</span>\n <span id=\"FormView1_FName\">Merav</span> \n <a id=\"FormView1_EditButton\" href=\"javascript:__doPostBack('FormView1$EditButton','')\">Edit</a>\n <a id=\"FormView1_NewButton\" href=\"javascript:__doPostBack('FormView1$NewButton','')\">New</a>\n <a id=\"FormView1_DeleteButton\" href=\"javascript:__doPostBack('FormView1$DeleteButton','')\">Delete</a>\n </td>\r\n\t</tr><tr>\r\n\t\t<td colspan=\"2\"><table border=\"0\">\r\n\t\t\t<tr>\r\n\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('FormView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('FormView1','Page$3')\">3</a></td>\r\n\t\t\t</tr>\r\n\t\t</table></td>\r\n\t</tr>\r\n</table>"; #endif HtmlDiff.AssertAreEqual (origHtml, newHtml, "CancelEditedRecordPostback"); }
public void Wizard_PostBackFireEvents_3 () { WebTest t = new WebTest (); PageDelegates pd = new PageDelegates (); pd.PreInit = _postbackEvents; t.Invoker = new PageInvoker (pd); string html = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); //SideBarButton fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls ["__EVENTTARGET"].Value = "Wizard1$SideBarContainer$SideBarList$ctl01$SideBarButton"; fr.Controls ["__EVENTARGUMENT"].Value = ""; t.Request = fr; html = t.Run (); Assert.AreEqual ("SideBarButtonClick", t.UserData.ToString (), "SideBarButton"); }
public void LoadPostData () //Just flow and not implementation detail { WebTest t = new WebTest (PageInvoker.CreateOnLoad (LoadPostData_Load)); string html = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("RadioButtonList1"); fr.Controls["__EVENTTARGET"].Value = "RadioButtonList1"; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["RadioButtonList1"].Value = "test"; t.Request = fr; t.Run (); ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ControlLoad", eventlist[0], "Live Cycle Flow #1"); Assert.AreEqual ("PageLoad", eventlist[1], "Live Cycle Flow #2"); Assert.AreEqual ("ControlLoad", eventlist[2], "Live Cycle Flow #3"); Assert.AreEqual ("LoadPostData", eventlist[3], "Live Cycle Flow #4"); }
public void DetailsView_EmptyDataTextPropertyRender () { PageDelegate pd = new PageDelegate (DetailsView_EmptyDataTextProperty); WebTest t = new WebTest (PageInvoker.CreateOnLoad (pd)); string result = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "LinkButton1"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; //t.Invoker = PageInvoker.CreateOnLoad (pd); result = t.Run (); string newHtml = HtmlDiff.GetControlFromPageHtml (result); #if NET_4_0 string origHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>Empty Data</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"LinkButton1\" href=\"javascript:__doPostBack('LinkButton1','')\">Test</a>"; #else string origHtml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>Empty Data</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div><a id=\"LinkButton1\" href=\"javascript:__doPostBack('LinkButton1','')\">Test</a>"; #endif HtmlDiff.AssertAreEqual(origHtml, newHtml, "EmptyDataTextTest"); }
public void CheckBoxList_Bug600415 () { WebTest t = new WebTest ("CheckBoxList_Bug600415.aspx"); #if NET_4_0 string origHtmlFirst = "<table id=\"checkBoxList\">\r\n\t<tr>\r\n\t\t<td><input id=\"checkBoxList_0\" type=\"checkbox\" name=\"checkBoxList$0\" checked=\"checked\" value=\"Item 1\" /><label for=\"checkBoxList_0\">Item 1</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_1\" type=\"checkbox\" name=\"checkBoxList$1\" value=\"Item 2\" /><label for=\"checkBoxList_1\">Item 2</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_2\" type=\"checkbox\" name=\"checkBoxList$2\" checked=\"checked\" value=\"Item 3\" /><label for=\"checkBoxList_2\">Item 3</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_3\" type=\"checkbox\" name=\"checkBoxList$3\" value=\"Item 4\" /><label for=\"checkBoxList_3\">Item 4</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlSecond = "<table id=\"checkBoxList\">\r\n\t<tr>\r\n\t\t<td><input id=\"checkBoxList_0\" type=\"checkbox\" name=\"checkBoxList$0\" value=\"Item 1\" /><label for=\"checkBoxList_0\">Item 1</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_1\" type=\"checkbox\" name=\"checkBoxList$1\" value=\"Item 2\" /><label for=\"checkBoxList_1\">Item 2</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_2\" type=\"checkbox\" name=\"checkBoxList$2\" value=\"Item 3\" /><label for=\"checkBoxList_2\">Item 3</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_3\" type=\"checkbox\" name=\"checkBoxList$3\" value=\"Item 4\" /><label for=\"checkBoxList_3\">Item 4</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlThird = "<table id=\"checkBoxList\">\r\n\t<tr>\r\n\t\t<td><input id=\"checkBoxList_0\" type=\"checkbox\" name=\"checkBoxList$0\" checked=\"checked\" value=\"Item 1\" /><label for=\"checkBoxList_0\">Item 1</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_1\" type=\"checkbox\" name=\"checkBoxList$1\" checked=\"checked\" value=\"Item 2\" /><label for=\"checkBoxList_1\">Item 2</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_2\" type=\"checkbox\" name=\"checkBoxList$2\" checked=\"checked\" value=\"Item 3\" /><label for=\"checkBoxList_2\">Item 3</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_3\" type=\"checkbox\" name=\"checkBoxList$3\" checked=\"checked\" value=\"Item 4\" /><label for=\"checkBoxList_3\">Item 4</label></td>\r\n\t</tr>\r\n</table>"; #else string origHtmlFirst = "<table id=\"checkBoxList\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><input id=\"checkBoxList_0\" type=\"checkbox\" name=\"checkBoxList$0\" checked=\"checked\" /><label for=\"checkBoxList_0\">Item 1</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_1\" type=\"checkbox\" name=\"checkBoxList$1\" /><label for=\"checkBoxList_1\">Item 2</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_2\" type=\"checkbox\" name=\"checkBoxList$2\" checked=\"checked\" /><label for=\"checkBoxList_2\">Item 3</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_3\" type=\"checkbox\" name=\"checkBoxList$3\" /><label for=\"checkBoxList_3\">Item 4</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlSecond = "<table id=\"checkBoxList\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><input id=\"checkBoxList_0\" type=\"checkbox\" name=\"checkBoxList$0\" /><label for=\"checkBoxList_0\">Item 1</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_1\" type=\"checkbox\" name=\"checkBoxList$1\" /><label for=\"checkBoxList_1\">Item 2</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_2\" type=\"checkbox\" name=\"checkBoxList$2\" /><label for=\"checkBoxList_2\">Item 3</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_3\" type=\"checkbox\" name=\"checkBoxList$3\" /><label for=\"checkBoxList_3\">Item 4</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlThird = "<table id=\"checkBoxList\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><input id=\"checkBoxList_0\" type=\"checkbox\" name=\"checkBoxList$0\" checked=\"checked\" /><label for=\"checkBoxList_0\">Item 1</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_1\" type=\"checkbox\" name=\"checkBoxList$1\" checked=\"checked\" /><label for=\"checkBoxList_1\">Item 2</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_2\" type=\"checkbox\" name=\"checkBoxList$2\" checked=\"checked\" /><label for=\"checkBoxList_2\">Item 3</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"checkBoxList_3\" type=\"checkbox\" name=\"checkBoxList$3\" checked=\"checked\" /><label for=\"checkBoxList_3\">Item 4</label></td>\r\n\t</tr>\r\n</table>"; #endif string html = t.Run (); string listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlFirst, listHtml, "#A1"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("cmdClick"); fr.Controls ["cmdClick"].Value = "Ok"; t.Request = fr; html = t.Run (); listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlSecond, listHtml, "#A2"); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("checkBoxList$0"); fr.Controls ["checkBoxList$0"].Value = "on"; fr.Controls.Add ("checkBoxList$1"); fr.Controls ["checkBoxList$1"].Value = "on"; fr.Controls.Add ("checkBoxList$2"); fr.Controls ["checkBoxList$2"].Value = "on"; fr.Controls.Add ("checkBoxList$3"); fr.Controls ["checkBoxList$3"].Value = "on"; t.Request = fr; html = t.Run (); listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlThird, listHtml, "#A3"); }
public void RaisePostDataChangedEvent_PostBack () { WebTest t = new WebTest (PageInvoker.CreateOnInit (RaisePostDataChangedEvent_Init)); string html = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("RadioButtonList1"); fr.Controls["__EVENTTARGET"].Value = "RadioButtonList1"; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["RadioButtonList1"].Value = "test"; t.Request = fr; t.Run (); if (t.UserData == null) Assert.Fail ("RaisePostDataChangedEvent Failed#1"); Assert.AreEqual ("SelectedIndexChanged", (string) t.UserData, "RaisePostDataChangedEvent Failed#2"); }
public void CheckBoxList_Bug377703_2 () { WebTest t = new WebTest ("CheckBoxList_Bug377703_2.aspx"); t.Invoker = PageInvoker.CreateOnInit (CheckBoxList_Bug377703_2_OnInit); #if NET_4_0 string origHtmlFirst = "<table id=\"cbxl2\">\r\n\t<tr>\r\n\t\t<td><input id=\"cbxl2_0\" type=\"checkbox\" name=\"cbxl2$0\" value=\"x\" /><label for=\"cbxl2_0\">x</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl2_1\" type=\"checkbox\" name=\"cbxl2$1\" value=\"y\" /><label for=\"cbxl2_1\">y</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl2_2\" type=\"checkbox\" name=\"cbxl2$2\" value=\"z\" /><label for=\"cbxl2_2\">z</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlSecond = "<table id=\"cbxl2\" class=\"aspNetDisabled\">\r\n\t<tr>\r\n\t\t<td><span class=\"aspNetDisabled\"><input id=\"cbxl2_0\" type=\"checkbox\" name=\"cbxl2$0\" checked=\"checked\" disabled=\"disabled\" value=\"x\" /><label for=\"cbxl2_0\">x</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span class=\"aspNetDisabled\"><input id=\"cbxl2_1\" type=\"checkbox\" name=\"cbxl2$1\" disabled=\"disabled\" value=\"y\" /><label for=\"cbxl2_1\">y</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span class=\"aspNetDisabled\"><input id=\"cbxl2_2\" type=\"checkbox\" name=\"cbxl2$2\" checked=\"checked\" disabled=\"disabled\" value=\"z\" /><label for=\"cbxl2_2\">z</label></span></td>\r\n\t</tr>\r\n</table>"; string origHtmlThird = "<table id=\"cbxl2\" class=\"aspNetDisabled\">\r\n\t<tr>\r\n\t\t<td><span class=\"aspNetDisabled\"><input id=\"cbxl2_0\" type=\"checkbox\" name=\"cbxl2$0\" checked=\"checked\" disabled=\"disabled\" value=\"x\" /><label for=\"cbxl2_0\">x</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span class=\"aspNetDisabled\"><input id=\"cbxl2_1\" type=\"checkbox\" name=\"cbxl2$1\" disabled=\"disabled\" value=\"y\" /><label for=\"cbxl2_1\">y</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span class=\"aspNetDisabled\"><input id=\"cbxl2_2\" type=\"checkbox\" name=\"cbxl2$2\" checked=\"checked\" disabled=\"disabled\" value=\"z\" /><label for=\"cbxl2_2\">z</label></span></td>\r\n\t</tr>\r\n</table>"; #else string origHtmlFirst = "<table id=\"cbxl2\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><input id=\"cbxl2_0\" type=\"checkbox\" name=\"cbxl2$0\" /><label for=\"cbxl2_0\">x</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl2_1\" type=\"checkbox\" name=\"cbxl2$1\" /><label for=\"cbxl2_1\">y</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl2_2\" type=\"checkbox\" name=\"cbxl2$2\" /><label for=\"cbxl2_2\">z</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlSecond = "<table id=\"cbxl2\" disabled=\"disabled\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><span disabled=\"disabled\"><input id=\"cbxl2_0\" type=\"checkbox\" name=\"cbxl2$0\" checked=\"checked\" disabled=\"disabled\" /><label for=\"cbxl2_0\">x</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span disabled=\"disabled\"><input id=\"cbxl2_1\" type=\"checkbox\" name=\"cbxl2$1\" disabled=\"disabled\" /><label for=\"cbxl2_1\">y</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span disabled=\"disabled\"><input id=\"cbxl2_2\" type=\"checkbox\" name=\"cbxl2$2\" checked=\"checked\" disabled=\"disabled\" /><label for=\"cbxl2_2\">z</label></span></td>\r\n\t</tr>\r\n</table>"; string origHtmlThird = "<table id=\"cbxl2\" disabled=\"disabled\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><span disabled=\"disabled\"><input id=\"cbxl2_0\" type=\"checkbox\" name=\"cbxl2$0\" checked=\"checked\" disabled=\"disabled\" /><label for=\"cbxl2_0\">x</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span disabled=\"disabled\"><input id=\"cbxl2_1\" type=\"checkbox\" name=\"cbxl2$1\" disabled=\"disabled\" /><label for=\"cbxl2_1\">y</label></span></td>\r\n\t</tr><tr>\r\n\t\t<td><span disabled=\"disabled\"><input id=\"cbxl2_2\" type=\"checkbox\" name=\"cbxl2$2\" checked=\"checked\" disabled=\"disabled\" /><label for=\"cbxl2_2\">z</label></span></td>\r\n\t</tr>\r\n</table>"; #endif string html = t.Run (); string listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlFirst, listHtml, "#A1"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("cbxl2$0"); fr.Controls ["cbxl2$0"].Value = "on"; fr.Controls.Add ("cbxl2$2"); fr.Controls ["cbxl2$2"].Value = "on"; fr.Controls.Add ("ctl01"); fr.Controls ["ctl01"].Value = "Click to toggle enable status above"; t.Request = fr; html = t.Run (); listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlSecond, listHtml, "#A2"); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("ctl02"); fr.Controls ["ctl02"].Value = "Click to refresh page"; t.Request = fr; html = t.Run (); listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlThird, listHtml, "#A3"); }
public void CheckBoxList_Bug377703_1 () { WebTest t = new WebTest ("CheckBoxList_Bug377703_1.aspx"); t.Invoker = PageInvoker.CreateOnInit (CheckBoxList_Bug377703_1_OnInit); #if NET_4_0 string origHtmlFirst = "<table id=\"cbxl1\">\r\n\t<tr>\r\n\t\t<td><input id=\"cbxl1_0\" type=\"checkbox\" name=\"cbxl1$0\" value=\"x\" /><label for=\"cbxl1_0\">x</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_1\" type=\"checkbox\" name=\"cbxl1$1\" value=\"y\" /><label for=\"cbxl1_1\">y</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_2\" type=\"checkbox\" name=\"cbxl1$2\" value=\"z\" /><label for=\"cbxl1_2\">z</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlSecond = "<table id=\"cbxl1\">\r\n\t<tr>\r\n\t\t<td><input id=\"cbxl1_0\" type=\"checkbox\" name=\"cbxl1$0\" checked=\"checked\" value=\"x\" /><label for=\"cbxl1_0\">x</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_1\" type=\"checkbox\" name=\"cbxl1$1\" value=\"y\" /><label for=\"cbxl1_1\">y</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_2\" type=\"checkbox\" name=\"cbxl1$2\" value=\"z\" /><label for=\"cbxl1_2\">z</label></td>\r\n\t</tr>\r\n</table>"; #else string origHtmlFirst = "<table id=\"cbxl1\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><input id=\"cbxl1_0\" type=\"checkbox\" name=\"cbxl1$0\" /><label for=\"cbxl1_0\">x</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_1\" type=\"checkbox\" name=\"cbxl1$1\" /><label for=\"cbxl1_1\">y</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_2\" type=\"checkbox\" name=\"cbxl1$2\" /><label for=\"cbxl1_2\">z</label></td>\r\n\t</tr>\r\n</table>"; string origHtmlSecond = "<table id=\"cbxl1\" border=\"0\">\r\n\t<tr>\r\n\t\t<td><input id=\"cbxl1_0\" type=\"checkbox\" name=\"cbxl1$0\" checked=\"checked\" /><label for=\"cbxl1_0\">x</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_1\" type=\"checkbox\" name=\"cbxl1$1\" /><label for=\"cbxl1_1\">y</label></td>\r\n\t</tr><tr>\r\n\t\t<td><input id=\"cbxl1_2\" type=\"checkbox\" name=\"cbxl1$2\" /><label for=\"cbxl1_2\">z</label></td>\r\n\t</tr>\r\n</table>"; #endif string html = t.Run (); string listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlFirst, listHtml, "#A1"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("cbxl1$0"); fr.Controls ["cbxl1$0"].Value = "on"; fr.Controls.Add ("ctl01"); fr.Controls ["ctl01"].Value = "Click me twice to have the first Item become empty"; t.Request = fr; html = t.Run (); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("cbxl1$0"); fr.Controls ["cbxl1$0"].Value = "on"; fr.Controls.Add ("ctl01"); fr.Controls ["ctl01"].Value = "Click me twice to have the first Item become empty"; t.Request = fr; html = t.Run (); listHtml = HtmlDiff.GetControlFromPageHtml (html); HtmlDiff.AssertAreEqual (origHtmlSecond, listHtml, "#A2"); }
public void Wizard_PostBack() { WebTest t = new WebTest (); PageDelegates pd = new PageDelegates (); pd.PreInit = _postback; pd.PreRenderComplete = _readControl; t.Invoker = new PageInvoker (pd); string result = t.Run (); if (result.IndexOf ("Start") < 0) Assert.Fail ("Rendering fault"); ArrayList list = t.UserData as ArrayList; Assert.IsNotNull (list, "PostBackDataNotCreated"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = list[1].ToString(); fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; result = t.Run (); if (result.IndexOf ("StepType") < 0) Assert.Fail ("MovedToStep1"); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = list[2].ToString (); fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; result = t.Run (); if (result.IndexOf ("AutoType") < 0) Assert.Fail ("MovedToStep2"); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = list[3].ToString (); fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; result = t.Run (); if (result.IndexOf ("FinishType") < 0) Assert.Fail ("MovedToStep3"); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = list[4].ToString (); fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; result = t.Run (); if (result.IndexOf ("CompleteType") < 0) Assert.Fail ("MovedToStep4"); }
public void DetailsView_InsertPostback () { WebTest t = new WebTest ("DetailsViewDataActions.aspx"); t.Invoker = PageInvoker.CreateOnLoad (InsertPostback_Load); string pageHTML = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1"; fr.Controls["__EVENTARGUMENT"].Value = "New$0"; t.Request = fr; pageHTML = t.Run (); string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td><input name=\"DetailsView1$ctl01\" type=\"text\" title=\"ID\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td><input name=\"DetailsView1$ctl02\" type=\"text\" title=\"FName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td><input name=\"DetailsView1$ctl03\" type=\"text\" title=\"LName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1$ctl04','')\">Insert</a> <a href=\"javascript:__doPostBack('DetailsView1','Cancel$-1')\">Cancel</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; #else string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td><input name=\"DetailsView1$ctl01\" type=\"text\" title=\"ID\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td><input name=\"DetailsView1$ctl02\" type=\"text\" title=\"FName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td><input name=\"DetailsView1$ctl03\" type=\"text\" title=\"LName\" /></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1$ctl04','')\">Insert</a> <a href=\"javascript:__doPostBack('DetailsView1','Cancel$-1')\">Cancel</a></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; #endif HtmlDiff.AssertAreEqual (origHtmlValue, renderedHtml, "InsertDataPostback"); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("DetailsView1$ctl01"); fr.Controls.Add ("DetailsView1$ctl02"); fr.Controls.Add ("DetailsView1$ctl03"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1$ctl04"; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["DetailsView1$ctl01"].Value = "123"; fr.Controls["DetailsView1$ctl02"].Value = "123"; fr.Controls["DetailsView1$ctl03"].Value = "123"; t.Request = fr; pageHTML = t.Run (); // Checking for insert event fired. ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ItemCommand", eventlist[0], "#1"); Assert.AreEqual ("ItemCommand", eventlist[1], "#2"); Assert.AreEqual ("ItemInserting", eventlist[2], "#3"); Assert.AreEqual ("ItemInserted", eventlist[3], "#4"); }
public void FormView_FireEvent_3 () { WebTest t = new WebTest ("FormViewInsertEditDelete.aspx"); t.Invoker = PageInvoker.CreateOnInit (FireEvent_3_Init); t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$NewButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; t.Run (); //Insert new record fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("FormView1$IDInsert"); fr.Controls.Add ("FormView1$FNameInsert"); fr.Controls.Add ("FormView1$LNameInsert"); fr.Controls["FormView1$IDInsert"].Value = "33"; fr.Controls["FormView1$FNameInsert"].Value = "InsertFirstName"; fr.Controls["FormView1$LNameInsert"].Value = "InsertLastName"; fr.Controls["__EVENTTARGET"].Value = "FormView1$InsertButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; t.Run (); ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ItemInserting", eventlist[0], "#1"); Assert.AreEqual ("ItemInserted", eventlist[1], "#2"); }
[Category ("NotDotNet")] // Implementation details in mono public void DetailsView_UpdatePostback () { WebTest t = new WebTest ("DetailsViewDataActions.aspx"); t.Invoker = PageInvoker.CreateOnLoad (UpdatePostback_Load); string pageHTML = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1"; fr.Controls["__EVENTARGUMENT"].Value = "Edit$0"; t.Request = fr; pageHTML = t.Run (); fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("DetailsView1$ctl01"); fr.Controls.Add ("DetailsView1$ctl02"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1$ctl03"; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["DetailsView1$ctl01"].Value = "1"; fr.Controls["DetailsView1$ctl02"].Value = "2"; t.Request = fr; t.Run (); // Checking for insert event fired. ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ItemCommand", eventlist[0], "#1"); Assert.AreEqual ("ItemCommand", eventlist[1], "#2"); Assert.AreEqual ("ItemUpdating", eventlist[2], "#3"); Assert.AreEqual ("ItemUpdated", eventlist[3], "#4"); }
public void FormView_InsertPostback () { WebTest t = new WebTest ("FormViewInsertEditDelete.aspx"); string pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("1001"), "BeforeInsert1"); Assert.AreEqual (true, pageHTML.Contains ("Mahesh"), "BeforeInsert2"); Assert.AreEqual (true, pageHTML.Contains ("Chand"), "BeforeInsert3"); Assert.AreEqual (false, pageHTML.Contains ("Page$4"), "BeforeInsert4"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$NewButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); string newHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); #if NET_4_0 string origHtml = "<table cellspacing=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n Insert ID:\n <input name=\"FormView1$IDInsert\" type=\"text\" id=\"FormView1_IDInsert\" /><br />\n Insert First Name:\n <input name=\"FormView1$FNameInsert\" type=\"text\" id=\"FormView1_FNameInsert\" />\n <br />\n Insert Last Name: \n <input name=\"FormView1$LNameInsert\" type=\"text\" id=\"FormView1_LNameInsert\" />\n <a id=\"FormView1_InsertButton\" href=\"javascript:__doPostBack('FormView1$InsertButton','')\">Insert</a>\n <a id=\"FormView1_CancelInsertButton\" href=\"javascript:__doPostBack('FormView1$CancelInsertButton','')\">Cancel</a>\n </td>\r\n\t</tr>\r\n</table>"; #else string origHtml = "<table cellspacing=\"0\" border=\"0\" id=\"FormView1\" style=\"border-collapse:collapse;\">\r\n\t<tr>\r\n\t\t<td colspan=\"2\">\n Insert ID:\n <input name=\"FormView1$IDInsert\" type=\"text\" id=\"FormView1_IDInsert\" /><br />\n Insert First Name:\n <input name=\"FormView1$FNameInsert\" type=\"text\" id=\"FormView1_FNameInsert\" />\n <br />\n Insert Last Name: \n <input name=\"FormView1$LNameInsert\" type=\"text\" id=\"FormView1_LNameInsert\" />\n <a id=\"FormView1_InsertButton\" href=\"javascript:__doPostBack('FormView1$InsertButton','')\">Insert</a>\n <a id=\"FormView1_CancelInsertButton\" href=\"javascript:__doPostBack('FormView1$CancelInsertButton','')\">Cancel</a>\n </td>\r\n\t</tr>\r\n</table>"; #endif HtmlDiff.AssertAreEqual (origHtml, newHtml, "InsertPostback"); //Insert new record fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("FormView1$IDInsert"); fr.Controls.Add ("FormView1$FNameInsert"); fr.Controls.Add ("FormView1$LNameInsert"); fr.Controls["FormView1$IDInsert"].Value = "33"; fr.Controls["FormView1$FNameInsert"].Value = "InsertFirstName"; fr.Controls["FormView1$LNameInsert"].Value ="InsertLastName"; fr.Controls["__EVENTTARGET"].Value = "FormView1$InsertButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("1001"), "AfterInsert1"); Assert.AreEqual (true, pageHTML.Contains ("Mahesh"), "AfterInsert2"); Assert.AreEqual (true, pageHTML.Contains ("Chand"), "AfterInsert3"); Assert.AreEqual (true, pageHTML.Contains ("Page$4"), "AfterInsert4"); //Checking that the inserted record appears on page 4. fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1"; fr.Controls["__EVENTARGUMENT"].Value = "Page$4"; t.Request = fr; pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("33"), "AfterInsert1"); Assert.AreEqual (true, pageHTML.Contains ("InsertLastName"), "AfterInsert2"); Assert.AreEqual (true, pageHTML.Contains ("InsertFirstName"), "AfterInsert3"); }
public void FormView_DataSourceChangedEvent () { WebTest t = new WebTest(); PageDelegates pd = new PageDelegates (); pd.Load = FormView_Init; pd.PreRenderComplete = FormView_Load; t.Invoker = new PageInvoker (pd); t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = ""; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; t.Run (); if (t.UserData == null) Assert.Fail ("DataSourceChangedEvent#1"); Assert.AreEqual ("Data_rebounded", t.UserData.ToString (), "DataSourceChangedEvent#2"); }
public void Validation_ValidationGroupNotIncluded () { WebTest t = new WebTest (); PageDelegates pd = new PageDelegates (); pd.Load = Validation_Load; pd.PreRender = Validation_PreRender; t.Invoker = new PageInvoker (pd); t.UserData = "ValidationGroupNotIncluded"; string html = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls ["__EVENTTARGET"].Value = (string) t.UserData; fr.Controls ["__EVENTARGUMENT"].Value = ""; t.Request = fr; t.UserData = "ValidationGroupNotIncluded"; html = t.Run (); }
public void FormView_FireEvent_1 () { WebTest t = new WebTest ("FormViewInsertEditDelete.aspx"); t.Invoker = PageInvoker.CreateOnInit (EditPostbackFireEvent_Init); string html = t.Run (); //Edit button postback (change to edit mode - buttons "Update" and "Cancel" should appear. FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$EditButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; html = t.Run (); ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ItemCommand", eventlist[0], "#1"); Assert.AreEqual ("ModeChanging", eventlist[1], "#2"); Assert.AreEqual ("ModeChanged", eventlist[2], "#3"); t.UserData = null; //Update record postback fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("FormView1$FNameEdit"); fr.Controls.Add ("FormView1$LNameEdit"); fr.Controls["__EVENTTARGET"].Value = "FormView1$UpdateButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["FormView1$FNameEdit"].Value = "Merav"; fr.Controls["FormView1$LNameEdit"].Value = "Test"; t.Request = fr; html = t.Run (); eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("ItemCommand", eventlist[0], "#1"); Assert.AreEqual ("ItemUpdating", eventlist[1], "#2"); Assert.AreEqual ("ItemUpdated", eventlist[2], "#3"); Assert.AreEqual ("ModeChanging", eventlist[3], "#4"); Assert.AreEqual ("ModeChanged", eventlist[4], "#5"); }
public void Wizard_PostBackFireEvents_2 () { WebTest t = new WebTest (); PageDelegates pd = new PageDelegates (); pd.PreInit = _postbackEvents; t.Invoker = new PageInvoker (pd); string html = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); // Next fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("Wizard1$StartNavigationTemplateContainerID$StartNextButton"); fr.Controls["__EVENTTARGET"].Value = ""; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["Wizard1$StartNavigationTemplateContainerID$StartNextButton"].Value = "Next"; t.Request = fr; html = t.Run (); Assert.AreEqual ("NextButtonClick", t.UserData.ToString (), "Next"); // Finish fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls.Add ("Wizard1$FinishNavigationTemplateContainerID$FinishButton"); fr.Controls["__EVENTTARGET"].Value = ""; fr.Controls["__EVENTARGUMENT"].Value = ""; fr.Controls["Wizard1$FinishNavigationTemplateContainerID$FinishButton"].Value = "Finish"; t.Request = fr; t.Run (); Assert.AreEqual ("FinishButtonClick", t.UserData.ToString (), "Finish"); }
public void FormView_FireEvent_5 () { WebTest t = new WebTest ("FormViewInsertEditDelete.aspx"); t.Invoker = PageInvoker.CreateOnInit (FireEvent_5_Init); t.Run (); //Delete Item FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1"; fr.Controls["__EVENTARGUMENT"].Value = "Page$2"; t.Request = fr; t.Run (); ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("PageIndexChanging", eventlist[0], "#1"); Assert.AreEqual ("PageIndexChanged", eventlist[1], "#2"); }
public void DetailsView_PagingPostback () { WebTest t = new WebTest ("DetailsViewDataActions.aspx"); t.Invoker = PageInvoker.CreateOnLoad (PagingPostback_Load); string pageHTML = t.Run (); string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); string origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td>1001</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td>Mahesh</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td>Chand</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1','Edit$0')\">Edit</a> <a href=\"javascript:__doPostBack('DetailsView1','Delete$0')\">Delete</a> <a href=\"javascript:__doPostBack('DetailsView1','New$0')\">New</a></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><table>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><span>1</span></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$2')\">2</a></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$3')\">3</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; HtmlDiff.AssertAreEqual (origHtmlValue, renderedHtml, "BeforePagingDataPostback"); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "DetailsView1"; fr.Controls["__EVENTARGUMENT"].Value = "Page$2"; t.Request = fr; pageHTML = t.Run (); renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHTML); origHtmlValue = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"DetailsView1\" style=\"height:50px;width:125px;border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<td>ID</td><td>1002</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>FName</td><td>Melanie</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>LName</td><td>Talmadge</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><a href=\"javascript:__doPostBack('DetailsView1','Edit$1')\">Edit</a> <a href=\"javascript:__doPostBack('DetailsView1','Delete$1')\">Delete</a> <a href=\"javascript:__doPostBack('DetailsView1','New$1')\">New</a></td>\r\n\t\t</tr><tr>\r\n\t\t\t<td colspan=\"2\"><table>\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<td><a href=\"javascript:__doPostBack('DetailsView1','Page$1')\">1</a></td><td><span>2</span></td><td><a href=\"javascript:__doPostBack('DetailsView1','Page$3')\">3</a></td>\r\n\t\t\t\t</tr>\r\n\t\t\t</table></td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>"; HtmlDiff.AssertAreEqual (origHtmlValue, renderedHtml, "AfterPagingDataPostback"); // Checking for change index event fired. ArrayList eventlist = t.UserData as ArrayList; if (eventlist == null) Assert.Fail ("User data does not been created fail"); Assert.AreEqual ("PageIndexChanging", eventlist[0], "#1"); Assert.AreEqual ("PageIndexChanged", eventlist[1], "#2"); }
public void FormView_DeleteAndEmptyTemplatePostback () { WebTest t = new WebTest ("FormViewInsertEditDelete.aspx"); string pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("1001"), "BeforeDelete1"); Assert.AreEqual (true, pageHTML.Contains ("Mahesh"), "BeforeDelete2"); Assert.AreEqual (true, pageHTML.Contains ("Chand"), "BeforeDelete3"); Assert.AreEqual (true, pageHTML.Contains ("Page$3"), "BeforeDelete4"); //Delete First Item FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$DeleteButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("1002"), "AfterFirstDelete1"); Assert.AreEqual (true, pageHTML.Contains ("Talmadge"), "AfterFirstDelete2"); Assert.AreEqual (true, pageHTML.Contains ("Melanie"), "AfterFirstDelete3"); Assert.AreEqual (true, pageHTML.Contains ("Page$2"), "AfterFirstDelete4"); Assert.AreEqual (false, pageHTML.Contains ("Page$3"), "AfterFirstDelete5"); //Delete second item fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$DeleteButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("1003"), "AfterSecondDelete1"); Assert.AreEqual (true, pageHTML.Contains ("Bansal"), "AfterSecondDelete2"); Assert.AreEqual (true, pageHTML.Contains ("Vinay"), "AfterSecondDelete3"); Assert.AreEqual (false, pageHTML.Contains ("Page$2"), "AfterSecondDelete4"); //Delete last item and checking that the EmptyDataTemplate appears. fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "FormView1$DeleteButton"; fr.Controls["__EVENTARGUMENT"].Value = ""; t.Request = fr; pageHTML = t.Run (); Assert.AreEqual (true, pageHTML.Contains ("FormView1_Label1"), "EmptyTemplateTest1"); Assert.AreEqual (true, pageHTML.Contains ("The Database is empty"), "EmptyTemplateTest2"); }
[Category ("NotDotNet")] // implementation specific public void Menu_PostBack () { PageDelegates pd = new PageDelegates (); pd.Init = Menu_SetTableMode; WebTest t = new WebTest ("PostBackMenuTest.aspx"); t.Invoker = new PageInvoker (pd); string str = t.Run (); FormRequest fr = new FormRequest (t.Response, "form1"); fr.Controls.Add ("__EVENTTARGET"); fr.Controls.Add ("__EVENTARGUMENT"); fr.Controls["__EVENTTARGET"].Value = "Menu1"; fr.Controls ["__EVENTARGUMENT"].Value = "0_1"; t.Request = fr; pd.PreRender = _MenuItemsPost; t.Invoker = new PageInvoker (pd); t.Run (); }