Example #1
0
        public void DropDownListBorderStyleCheck()
        {
            DropDownListTestClass d;

            d             = new DropDownListTestClass();
            d.BorderStyle = (BorderStyle)Int32.MinValue;
        }
Example #2
0
        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");
        }
Example #3
0
        public void DropDownNullWriterTest()
        {
            DropDownListTestClass d;

            d = new DropDownListTestClass();
            d.AddAttributesToRender(null);
        }
Example #4
0
        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");
        }
Example #5
0
        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");
        }
Example #6
0
        public void DropDownListSelectedCheck()
        {
            DropDownListTestClass d;

            d = new DropDownListTestClass();
            d.SelectedIndex = 2;                // No exception thrown!!!
            Assert.AreEqual(-1, d.SelectedIndex, "S1");
        }
Example #7
0
        public void DropDownListNull()
        {
            DropDownListTestClass d;

            d = new DropDownListTestClass();

            // We want to surve the next two calls
            d.RenderContents(null);
        }
Example #8
0
        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("&lt;hola>") != -1, "#02");
        }
Example #9
0
        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");
        }
Example #10
0
        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");
        }
Example #11
0
        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";
        }
Example #12
0
        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");
        }
Example #13
0
		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";
		}
Example #14
0
		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");
		}
Example #15
0
		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
		}
Example #16
0
		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");
		}
Example #17
0
		public void DropDownListBorderStyleCheck () {
			DropDownListTestClass	d;

			d = new DropDownListTestClass ();
			d.BorderStyle = (BorderStyle)Int32.MinValue;
		}
Example #18
0
		public void DropDownListSelectedCheck () {
			DropDownListTestClass	d;

			d = new DropDownListTestClass ();
			d.SelectedIndex = 2;	// No exception thrown!!!
			Assert.AreEqual(-1, d.SelectedIndex, "S1");
		}
Example #19
0
		public void DropDownNullWriterTest () {
			DropDownListTestClass	d;

			d = new DropDownListTestClass ();
			d.AddAttributesToRender(null);
		}
Example #20
0
		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");
		}
Example #21
0
		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 ("&lt;hola>") != -1, "#02");
		}
Example #22
0
		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");
		}
Example #23
0
		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");
		}
Example #24
0
		public void DropDownListNull () {
			DropDownListTestClass	d;

			d = new DropDownListTestClass ();

			// We want to surve the next two calls
			d.RenderContents(null);
		}