public void DropDownListBorderStyleCheck() { DropDownListTestClass d; d = new DropDownListTestClass(); d.BorderStyle = (BorderStyle)Int32.MinValue; }
public void DropDownListProperties() { DropDownListTestClass d; d = new DropDownListTestClass(); Assert.AreEqual(Color.Empty, d.BorderColor, "P1"); d.BorderColor = Color.Red; Assert.AreEqual(Color.Red, d.BorderColor, "P2"); Assert.AreEqual(BorderStyle.NotSet, d.BorderStyle, "P3"); d.BorderStyle = BorderStyle.Dotted; Assert.AreEqual(BorderStyle.Dotted, d.BorderStyle, "P4"); Assert.AreEqual(Unit.Empty, d.BorderWidth, "P5"); d.BorderWidth = new Unit(1); Assert.AreEqual("1px", d.BorderWidth.ToString(), "P6"); Assert.AreEqual(-1, d.SelectedIndex, "P7"); d.Items.Add(new ListItem("text1", "value1")); d.Items.Add(new ListItem("text2", "value2")); d.SelectedIndex = 1; Assert.AreEqual(1, d.SelectedIndex, "P8"); Assert.AreEqual(string.Empty, d.ToolTip, "P9"); d.ToolTip = "blah"; Assert.AreEqual("blah", d.ToolTip, "P10"); }
public void DropDownNullWriterTest() { DropDownListTestClass d; d = new DropDownListTestClass(); d.AddAttributesToRender(null); }
public void TestValueFieldAndTextFormat() { DropDownListTestClass ddl = new DropDownListTestClass(); ddl.DataSource = GetExampleData(); ddl.DataValueField = "Company"; ddl.DataTextFormatString = "This shouldn't show up = {0}"; ddl.DataBind(); #if NET_2_0 string exp = @"<select> <option value=""Novell Inc."">Novell Inc.</option> <option value=""Microsoft Corp."">Microsoft Corp.</option> <option value=""Google"">Google</option> </select>"; #else string exp = @"<select name> <option value=""Novell Inc."">Novell Inc.</option> <option value=""Microsoft Corp."">Microsoft Corp.</option> <option value=""Google"">Google</option> </select>"; #endif HtmlDiff.AssertAreEqual(exp, ddl.Render(), "TestValueFieldAndTextFormat"); }
public void DropDownNamingTest() { NamingContainer container = new NamingContainer(); DropDownListTestClass child = new DropDownListTestClass(); #if NET_2_0 Assert.AreEqual("<select>\n\n</select>", child.Render(), "N1"); #else Assert.AreEqual("<select name>\n\n</select>", child.Render(), "N1"); #endif container.Controls.Add(child); // don't assume the generated id string s = child.Render(); Assert.IsTrue(s.StartsWith("<select name=\""), "N2a"); Assert.IsTrue(s.EndsWith("\">\n\n</select>"), "N2b"); container.ID = "naming"; s = child.Render(); Assert.IsTrue(s.StartsWith("<select name=\"naming"), "N3a"); Assert.IsTrue(s.EndsWith("\">\n\n</select>"), "N3b"); child.ID = "fooid"; s = child.Render(); Assert.IsTrue(s.StartsWith("<select name=\"naming"), "N4a"); Assert.IsTrue(s.EndsWith("fooid\" id=\"naming_fooid\">\n\n</select>"), "N4b"); }
public void DropDownListSelectedCheck() { DropDownListTestClass d; d = new DropDownListTestClass(); d.SelectedIndex = 2; // No exception thrown!!! Assert.AreEqual(-1, d.SelectedIndex, "S1"); }
public void DropDownListNull() { DropDownListTestClass d; d = new DropDownListTestClass(); // We want to surve the next two calls d.RenderContents(null); }
public void HtmlEncodeItem() { DropDownListTestClass d = new DropDownListTestClass(); d.Items.Add(new ListItem("text1", "<hola>")); string html = d.Render(); Assert.IsTrue(html.IndexOf("<hola>") == -1, "#01"); Assert.IsTrue(html.IndexOf("<hola>") != -1, "#02"); }
public void DropDownList_Defaults() { DropDownListTestClass d = new DropDownListTestClass(); Assert.AreEqual(Color.Empty, d.BackColor, "D1"); Assert.AreEqual(Color.Empty, d.BorderColor, "D2"); Assert.AreEqual(BorderStyle.NotSet, d.BorderStyle, "D3"); Assert.AreEqual(Unit.Empty, d.BorderWidth, "D4"); Assert.AreEqual(-1, d.SelectedIndex, "D5"); Assert.AreEqual(string.Empty, d.ToolTip, "D6"); Assert.AreEqual(0, d.Items.Count, "D7"); }
public void DropDownListDoubleSelectCheck() { DropDownListTestClass d; d = new DropDownListTestClass(); d.Items.Add(new ListItem("text1", "value1")); d.Items.Add(new ListItem("text2", "value2")); d.SelectedIndex = 1; Assert.AreEqual(1, d.SelectedIndex, "DS1"); d.Items[0].Selected = true; d.Items[1].Selected = true; Assert.AreEqual("<select name>\n\t<option selected=\"selected\" value=\"value1\">text1</option>\n\t<option selected=\"selected\" value=\"value2\">text2</option>\n\n</select>", d.Render(), "DS1"); }
public static void DropDownList_Init(Page p) { DropDownListTestClass dl = new DropDownListTestClass(); DS data = new DS(); p.Controls.Add(dl); p.Controls.Add(data); data.TypeName = typeof(DS).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.ID = "Data"; dl.DataBinding += new EventHandler(data_DataBinding); dl.DataSourceID = "Data"; }
public void DropDownListBasic() { DropDownListTestClass d = new DropDownListTestClass(); Assert.AreEqual("<select>\n\n</select>", d.Render(), "B1"); d.ID = "blah"; Assert.AreEqual("<select name=\"blah\" id=\"blah\">\n\n</select>", d.Render(), "B2"); Assert.AreEqual(false, d.IsTrackingVS(), "B3"); d.SetTrackingVS(); Assert.AreEqual(true, d.IsTrackingVS(), "B4"); d.Items.Add(new ListItem("text1", "value1")); Assert.AreEqual(1, d.Items.Count, "B5"); d.Items.Add(new ListItem("text2", "value2")); Assert.AreEqual(2, d.Items.Count, "B6"); d.SelectedIndex = 1; Assert.AreEqual("<select name=\"blah\" id=\"blah\">\n\t<option value=\"value1\">text1</option>\n\t<option selected=\"selected\" value=\"value2\">text2</option>\n\n</select>", d.Render(), "B7"); }
public static void DropDownList_Init (Page p) { DropDownListTestClass dl = new DropDownListTestClass (); DS data = new DS (); p.Controls.Add (dl); p.Controls.Add (data); data.TypeName = typeof (DS).AssemblyQualifiedName; data.SelectMethod = "GetList"; data.ID = "Data"; dl.DataBinding += new EventHandler (data_DataBinding); dl.DataSourceID = "Data"; }
public void DropDownListBasic () { DropDownListTestClass d = new DropDownListTestClass (); #if NET_2_0 Assert.AreEqual ("<select>\n\n</select>", d.Render (), "B1"); #else Assert.AreEqual("<select name>\n\n</select>", d.Render(), "B1"); #endif d.ID = "blah"; Assert.AreEqual("<select name=\"blah\" id=\"blah\">\n\n</select>", d.Render(), "B2"); Assert.AreEqual(false, d.IsTrackingVS(), "B3"); d.SetTrackingVS(); Assert.AreEqual(true, d.IsTrackingVS(), "B4"); d.Items.Add(new ListItem("text1", "value1")); Assert.AreEqual(1, d.Items.Count, "B5"); d.Items.Add(new ListItem("text2", "value2")); Assert.AreEqual(2, d.Items.Count, "B6"); d.SelectedIndex = 1; Assert.AreEqual("<select name=\"blah\" id=\"blah\">\n\t<option value=\"value1\">text1</option>\n\t<option selected=\"selected\" value=\"value2\">text2</option>\n\n</select>", d.Render(), "B7"); }
public void DropDownListProperties () { DropDownListTestClass d; d = new DropDownListTestClass (); Assert.AreEqual(Color.Empty, d.BorderColor, "P1"); d.BorderColor = Color.Red; Assert.AreEqual(Color.Red, d.BorderColor, "P2"); Assert.AreEqual(BorderStyle.NotSet, d.BorderStyle, "P3"); d.BorderStyle = BorderStyle.Dotted; Assert.AreEqual(BorderStyle.Dotted, d.BorderStyle, "P4"); Assert.AreEqual(Unit.Empty, d.BorderWidth, "P5"); d.BorderWidth = new Unit(1); Assert.AreEqual("1px", d.BorderWidth.ToString(), "P6"); Assert.AreEqual(-1, d.SelectedIndex, "P7"); d.Items.Add(new ListItem("text1", "value1")); d.Items.Add(new ListItem("text2", "value2")); d.SelectedIndex = 1; Assert.AreEqual(1, d.SelectedIndex, "P8"); Assert.AreEqual(string.Empty, d.ToolTip, "P9"); d.ToolTip = "blah"; #if NET_2_0 Assert.AreEqual ("blah", d.ToolTip, "P10"); #else Assert.AreEqual(string.Empty, d.ToolTip, "P10"); #endif }
public void DropDownListDoubleSelectCheck () { DropDownListTestClass d; d = new DropDownListTestClass (); d.Items.Add(new ListItem("text1", "value1")); d.Items.Add(new ListItem("text2", "value2")); d.SelectedIndex = 1; Assert.AreEqual(1, d.SelectedIndex, "DS1"); d.Items[0].Selected = true; d.Items[1].Selected = true; Assert.AreEqual("<select name>\n\t<option selected=\"selected\" value=\"value1\">text1</option>\n\t<option selected=\"selected\" value=\"value2\">text2</option>\n\n</select>", d.Render(), "DS1"); }
public void DropDownListBorderStyleCheck () { DropDownListTestClass d; d = new DropDownListTestClass (); d.BorderStyle = (BorderStyle)Int32.MinValue; }
public void DropDownListSelectedCheck () { DropDownListTestClass d; d = new DropDownListTestClass (); d.SelectedIndex = 2; // No exception thrown!!! Assert.AreEqual(-1, d.SelectedIndex, "S1"); }
public void DropDownNullWriterTest () { DropDownListTestClass d; d = new DropDownListTestClass (); d.AddAttributesToRender(null); }
public void DropDownList_Defaults () { DropDownListTestClass d = new DropDownListTestClass (); Assert.AreEqual (Color.Empty, d.BackColor, "D1"); Assert.AreEqual (Color.Empty, d.BorderColor, "D2"); Assert.AreEqual (BorderStyle.NotSet, d.BorderStyle, "D3"); Assert.AreEqual (Unit.Empty, d.BorderWidth, "D4"); Assert.AreEqual (-1, d.SelectedIndex, "D5"); Assert.AreEqual (string.Empty, d.ToolTip, "D6"); Assert.AreEqual (0, d.Items.Count, "D7"); }
public void HtmlEncodeItem () { DropDownListTestClass d = new DropDownListTestClass (); d.Items.Add(new ListItem ("text1", "<hola>")); string html = d.Render(); Assert.IsTrue (html.IndexOf ("<hola>") == -1, "#01"); Assert.IsTrue (html.IndexOf ("<hola>") != -1, "#02"); }
public void TestValueFieldAndTextFormat () { DropDownListTestClass ddl = new DropDownListTestClass (); ddl.DataSource = GetExampleData (); ddl.DataValueField = "Company"; ddl.DataTextFormatString = "This shouldn't show up = {0}"; ddl.DataBind (); #if NET_2_0 string exp = @"<select> <option value=""Novell Inc."">Novell Inc.</option> <option value=""Microsoft Corp."">Microsoft Corp.</option> <option value=""Google"">Google</option> </select>"; #else string exp = @"<select name> <option value=""Novell Inc."">Novell Inc.</option> <option value=""Microsoft Corp."">Microsoft Corp.</option> <option value=""Google"">Google</option> </select>"; #endif HtmlDiff.AssertAreEqual(exp, ddl.Render(), "TestValueFieldAndTextFormat"); }
public void DropDownNamingTest () { NamingContainer container = new NamingContainer (); DropDownListTestClass child = new DropDownListTestClass (); #if NET_2_0 Assert.AreEqual ("<select>\n\n</select>", child.Render (), "N1"); #else Assert.AreEqual ("<select name>\n\n</select>", child.Render (), "N1"); #endif container.Controls.Add (child); // don't assume the generated id string s = child.Render (); Assert.IsTrue (s.StartsWith ("<select name=\""), "N2a"); Assert.IsTrue (s.EndsWith ("\">\n\n</select>"), "N2b"); container.ID = "naming"; s = child.Render (); Assert.IsTrue (s.StartsWith ("<select name=\"naming"), "N3a"); Assert.IsTrue (s.EndsWith ("\">\n\n</select>"), "N3b"); child.ID = "fooid"; s = child.Render (); Assert.IsTrue (s.StartsWith ("<select name=\"naming"), "N4a"); Assert.IsTrue (s.EndsWith ("fooid\" id=\"naming_fooid\">\n\n</select>"), "N4b"); }
public void DropDownListNull () { DropDownListTestClass d; d = new DropDownListTestClass (); // We want to surve the next two calls d.RenderContents(null); }