コード例 #1
0
ファイル: Helpers.cs プロジェクト: raj581/Marvin
        public static void ExtractAndCompareCodeFromHtml(string html, string original, string msg)
        {
            string rendered = ExtractCodeFromHtml(html);

            HtmlDiff.AssertAreEqual(original, rendered, msg);
        }
コード例 #2
0
ファイル: CheckBoxListTest.cs プロジェクト: raj581/Marvin
        public void CheckBoxList_Bug600415()
        {
            WebTest t              = new WebTest("CheckBoxList_Bug600415.aspx");
            string  origHtmlFirst  = @"<table id=""checkBoxList"" border=""0"">
	<tr>

		<td><input id=""checkBoxList_0"" type=""checkbox"" name=""checkBoxList$0"" checked=""checked"" /><label for=""checkBoxList_0"">Item 1</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_1"" type=""checkbox"" name=""checkBoxList$1"" /><label for=""checkBoxList_1"">Item 2</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_2"" type=""checkbox"" name=""checkBoxList$2"" checked=""checked"" /><label for=""checkBoxList_2"">Item 3</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_3"" type=""checkbox"" name=""checkBoxList$3"" /><label for=""checkBoxList_3"">Item 4</label></td>

	</tr>
</table>";
            string  origHtmlSecond = @"<table id=""checkBoxList"" border=""0"">
	<tr>

		<td><input id=""checkBoxList_0"" type=""checkbox"" name=""checkBoxList$0"" /><label for=""checkBoxList_0"">Item 1</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_1"" type=""checkbox"" name=""checkBoxList$1"" /><label for=""checkBoxList_1"">Item 2</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_2"" type=""checkbox"" name=""checkBoxList$2"" /><label for=""checkBoxList_2"">Item 3</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_3"" type=""checkbox"" name=""checkBoxList$3"" /><label for=""checkBoxList_3"">Item 4</label></td>

	</tr>
</table>";
            string  origHtmlThird  = @"<table id=""checkBoxList"" border=""0"">
	<tr>

		<td><input id=""checkBoxList_0"" type=""checkbox"" name=""checkBoxList$0"" checked=""checked"" /><label for=""checkBoxList_0"">Item 1</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_1"" type=""checkbox"" name=""checkBoxList$1"" checked=""checked"" /><label for=""checkBoxList_1"">Item 2</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_2"" type=""checkbox"" name=""checkBoxList$2"" checked=""checked"" /><label for=""checkBoxList_2"">Item 3</label></td>
	</tr><tr>
		<td><input id=""checkBoxList_3"" type=""checkbox"" name=""checkBoxList$3"" checked=""checked"" /><label for=""checkBoxList_3"">Item 4</label></td>

	</tr>
</table>";
            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");
        }
コード例 #3
0
        public void InitializeEditCell()
        {
#if NET_4_0
            string origHtml = "<table><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" />&nbsp;<input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
#else
            string origHtml = "<table border=\"0\"><tr><td>&nbsp;</td><td>&nbsp;</td><td>one</td><td>two</td><td>three</td></tr><tr><td><a>Update</a>&nbsp;<a>Cancel</a></td><td><input name=\"sucker$ctl02$ctl00\" type=\"submit\" value=\"Refresh\" />&nbsp;<input name=\"sucker$ctl02$ctl01\" type=\"submit\" value=\"Abbrechen\" /></td><td><input name=\"sucker$ctl02$ctl02\" type=\"text\" value=\"1\" /></td><td><input name=\"sucker$ctl02$ctl03\" type=\"text\" value=\"2\" /></td><td><input name=\"sucker$ctl02$ctl04\" type=\"text\" value=\"3\" /></td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
#endif
            DataGridTest      p     = new DataGridTest();
            DataTable         table = new DataTable();
            EditCommandColumn e;
            string            markup;

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.LinkButton;
            e.CancelText = "Cancel";
            e.EditText   = "Edit";
            e.UpdateText = "Update";

            table.Columns.Add(new DataColumn("one", typeof(string)));
            table.Columns.Add(new DataColumn("two", typeof(string)));
            table.Columns.Add(new DataColumn("three", typeof(string)));
            table.Rows.Add(new object [] { "1", "2", "3" });

            p.DataSource = new DataView(table);
            p.Columns.Add(e);

            e            = new EditCommandColumn();
            e.ButtonType = ButtonColumnType.PushButton;
            e.CancelText = "Abbrechen";
            e.EditText   = "Bearbeiten";
            e.UpdateText = "Refresh";
            p.Columns.Add(e);

            // Force the ListItemType to be EditItem so we can test rendering the UpdateText/CancelText render
            p.EditItemIndex = 0;

            // This will trigger EditCommandColumn.InitializeCell
            p.CreateControls(true);
            p.ID = "sucker";

            StringBuilder sb = new StringBuilder();
            GetHierarchy(p.Controls, 0, sb);
            string h = sb.ToString();
            int    x = h.IndexOf(".TextBox");
            // These are from the BoundColumns
            Assert.IsTrue(x != -1, "textbox1");
            x = h.IndexOf(".TextBox", x + 1);
            Assert.IsTrue(x != -1, "textbox2");
            x = h.IndexOf(".TextBox", x + 1);
            Assert.IsTrue(x != -1, "textbox3");
            x = h.IndexOf(".TextBox", x + 1);
            Assert.IsTrue(x == -1, "textbox-end");

            markup = ControlMarkup(p.Controls[0]);
            markup = markup.Replace("\t", "");
            markup = markup.Replace("\r", "");
            markup = markup.Replace("\n", "");

//Console.WriteLine("Markup:>{0}<", markup);
            Assert.AreEqual(2, p.Columns.Count, "I1");

            HtmlDiff.AssertAreEqual(origHtml, markup, "I2");
        }
コード例 #4
0
ファイル: CheckBoxListTest.cs プロジェクト: raj581/Marvin
        public void CheckBoxList_Bug377703_2()
        {
            WebTest t = new WebTest("CheckBoxList_Bug377703_2.aspx");

            t.Invoker = PageInvoker.CreateOnInit(CheckBoxList_Bug377703_2_OnInit);
            string origHtmlFirst  = @"<table id=""cbxl2"" border=""0"">
	<tr>
		<td><input id=""cbxl2_0"" type=""checkbox"" name=""cbxl2$0"" /><label for=""cbxl2_0"">x</label></td>

	</tr><tr>
		<td><input id=""cbxl2_1"" type=""checkbox"" name=""cbxl2$1"" /><label for=""cbxl2_1"">y</label></td>
	</tr><tr>
		<td><input id=""cbxl2_2"" type=""checkbox"" name=""cbxl2$2"" /><label for=""cbxl2_2"">z</label></td>
	</tr>
</table>";
            string origHtmlSecond = @"<table id=""cbxl2"" disabled=""disabled"" border=""0"">
	<tr>
		<td><span disabled=""disabled""><input id=""cbxl2_0"" type=""checkbox"" name=""cbxl2$0"" disabled=""disabled"" checked=""checked"" /><label for=""cbxl2_0"">x</label></span></td>

	</tr><tr>
		<td><span disabled=""disabled""><input id=""cbxl2_1"" type=""checkbox"" name=""cbxl2$1"" disabled=""disabled"" /><label for=""cbxl2_1"">y</label></span></td>
	</tr><tr>
		<td><span disabled=""disabled""><input id=""cbxl2_2"" type=""checkbox"" name=""cbxl2$2"" disabled=""disabled"" checked=""checked"" /><label for=""cbxl2_2"">z</label></span></td>
	</tr>
</table>";
            string origHtmlThird  = @"<table id=""cbxl2"" disabled=""disabled"" border=""0"">
	<tr>
		<td><span disabled=""disabled""><input id=""cbxl2_0"" type=""checkbox"" name=""cbxl2$0"" disabled=""disabled"" checked=""checked"" /><label for=""cbxl2_0"">x</label></span></td>

	</tr><tr>
		<td><span disabled=""disabled""><input id=""cbxl2_1"" type=""checkbox"" name=""cbxl2$1"" disabled=""disabled"" /><label for=""cbxl2_1"">y</label></span></td>
	</tr><tr>
		<td><span disabled=""disabled""><input id=""cbxl2_2"" type=""checkbox"" name=""cbxl2$2"" disabled=""disabled"" checked=""checked"" /><label for=""cbxl2_2"">z</label></span></td>
	</tr>
</table>";
            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");
        }