Ejemplo n.º 1
0
        public void CleanProperties()
        {
            TestCheckBox c = new TestCheckBox();

            c.Text = "text";
            Assert.AreEqual("text", c.Text, "Text");
            c.AutoPostBack = true;
            c.TextAlign    = TextAlign.Left;
            c.Checked      = true;

            Assert.AreEqual(4, c.StateBag.Count, "ViewState.Count");
            Assert.AreEqual(0, c.Attributes.Count, "Attributes.Count");

            c.Text         = null;
            c.AutoPostBack = false;
            c.TextAlign    = TextAlign.Right;
            c.Checked      = false;

            // If Text is null it is removed from the ViewState
            Assert.AreEqual(3, c.StateBag.Count, "ViewState.Count-2");
            // This was failing on mono, because the
            // viewstate is holding an int not an enum.
            // (it passes on ms)
            Assert.AreEqual(TextAlign.Right, c.StateBag["TextAlign"], "TextAlign");
            Assert.AreEqual(0, c.Attributes.Count, "Attributes.Count-2");
        }
Ejemplo n.º 2
0
        public void Render()
        {
            TestCheckBox c = new TestCheckBox();

            c.ID   = "ID";
            c.Text = "Text";

            c.TextAlign = TextAlign.Left;
            Assert.AreEqual(@"<label for=""ID"">Text</label><input id=""ID"" type=""checkbox"" name=""ID"" />", c.Render(), "R#1");
            c.TextAlign = TextAlign.Right;
            Assert.AreEqual(@"<input id=""ID"" type=""checkbox"" name=""ID"" /><label for=""ID"">Text</label>", c.Render(), "R#2");

            c.Attributes ["style"] = "color:red;";
            c.TextAlign            = TextAlign.Left;
            Assert.AreEqual(@"<span style=""color:red;""><label for=""ID"">Text</label><input id=""ID"" type=""checkbox"" name=""ID"" /></span>",
                            c.Render(), "R#3");

            c.TextAlign = TextAlign.Right;
            Assert.AreEqual(@"<span style=""color:red;""><input id=""ID"" type=""checkbox"" name=""ID"" /><label for=""ID"">Text</label></span>",
                            c.Render(), "R#4");

            c.Attributes ["style"] = null;

            c.ForeColor = Color.Red;
            c.TextAlign = TextAlign.Left;
            Assert.AreEqual(@"<span style=""color:Red;""><label for=""ID"">Text</label><input id=""ID"" type=""checkbox"" name=""ID"" /></span>",
                            c.Render(), "R#4");

            c.TextAlign = TextAlign.Right;
            Assert.AreEqual(@"<span style=""color:Red;""><input id=""ID"" type=""checkbox"" name=""ID"" /><label for=""ID"">Text</label></span>",
                            c.Render(), "R#6");
        }
Ejemplo n.º 3
0
        public void InputAttributesTest()
        {
            TestCheckBox c = new TestCheckBox();

            c.InputAttributes.Add("Atribute", "Test");
            string html = c.Render();

            HtmlDiff.AssertAreEqual("<input type=\"checkbox\" Atribute=\"Test\" />", html, "Input Attribute fail");
        }
Ejemplo n.º 4
0
        public void LabelAttributesTest_2()
        {
            TestCheckBox c = new TestCheckBox();

            c.LabelAttributes.Add("Atribute", "Test");
            string html = c.Render();

            HtmlDiff.AssertAreEqual("<input type=\"checkbox\" />", html, "Label Attributes fail#2");
        }
Ejemplo n.º 5
0
        public void LabelAttributesTest_1()
        {
            TestCheckBox c = new TestCheckBox();

            c.ID   = "Check";
            c.Text = "CheckBoxText";
            c.LabelAttributes.Add("Atribute", "Test");
            string html = c.Render();

            HtmlDiff.AssertAreEqual("<input id=\"Check\" type=\"checkbox\" name=\"Check\" /><label for=\"Check\" Atribute=\"Test\">CheckBoxText</label>", html, "Label Attributes fail#1");
        }
Ejemplo n.º 6
0
        public void InputAttributesTest2()
        {
            TestCheckBox c = new TestCheckBox();

            c.InputAttributes.Add("value", "value1");
            c.Text    = "Title";
            c.Checked = true;
            string origHtml = "<input id=\"\" type=\"checkbox\" checked=\"checked\" value=\"value1\" /><label for=\"\">Title</label>";
            string html     = c.Render();

            HtmlDiff.AssertAreEqual(origHtml, html, "#A1");
        }
Ejemplo n.º 7
0
        public void NullProperties()
        {
            TestCheckBox c = new TestCheckBox();

            c.Text = null;
            Assert.AreEqual(String.Empty, c.Text, "Text");
            c.TextAlign = TextAlign.Right;
            Assert.AreEqual(TextAlign.Right, c.TextAlign, "TextAlign");
            c.AutoPostBack = true;
            Assert.IsTrue(c.AutoPostBack, "AutoPostBack");
            c.Checked = true;
            Assert.IsTrue(c.Checked, "Checked");

            Assert.AreEqual(0, c.Attributes.Count, "Attributes.Count");
            Assert.AreEqual(3, c.StateBag.Count, "ViewState.Count-1");
        }
Ejemplo n.º 8
0
        public void CheckboxViewstateTextNull()
        {
            TestCheckBox c = new TestCheckBox();

            c.Text = "text";
            c.TrackState();
            c.Text = null;
            Assert.AreEqual("", c.Text);
            object o = c.SaveState();

            c      = new TestCheckBox();
            c.Text = "text";
            c.TrackState();
            c.LoadState(o);
            Assert.AreEqual("", c.Text);
        }
Ejemplo n.º 9
0
        public void DefaultProperties()
        {
            TestCheckBox c = new TestCheckBox();

            Assert.AreEqual(0, c.Attributes.Count, "Attributes.Count");

            Assert.IsFalse(c.AutoPostBack, "AutoPostBack");
            Assert.IsFalse(c.Checked, "Checked");
            Assert.AreEqual(String.Empty, c.Text, "Text");
            Assert.AreEqual(TextAlign.Right, c.TextAlign, "TextAlign");

            Assert.AreEqual(0, c.Attributes.Count, "Attributes.Count-2");

            Assert.IsFalse(c.CausesValidation, "CausesValidation");
            Assert.AreEqual(String.Empty, c.ValidationGroup, "ValidationGroup");
        }
Ejemplo n.º 10
0
        public void CheckboxViewstateValidation()
        {
            // for some reason, MS doesn't save the validation
            // properties to the viewstate for the Checkbox
            // control.  why not?
            TestCheckBox o = new TestCheckBox();

            o.ValidationGroup  = "VG1";
            o.CausesValidation = true;
            o.TrackState();
            Assert.AreEqual("VG1", o.ValidationGroup, "V1");
            Assert.IsTrue(o.CausesValidation, "V2");
            object       state = o.SaveState();
            TestCheckBox copy  = new TestCheckBox();

            copy.LoadState(state);
            Assert.AreEqual("", copy.ValidationGroup, "V3");
            Assert.IsFalse(copy.CausesValidation, "V4");
        }
Ejemplo n.º 11
0
		public void CheckboxViewstateTextNull ()
		{
			TestCheckBox c = new TestCheckBox ();
			c.Text = "text";
			c.TrackState ();
			c.Text = null;
			Assert.AreEqual ("", c.Text);
			object o = c.SaveState ();
			c = new TestCheckBox ();
			c.Text = "text";
			c.TrackState ();
			c.LoadState (o);
			Assert.AreEqual ("", c.Text);
		}
Ejemplo n.º 12
0
		public void DefaultProperties ()
		{
			TestCheckBox c = new TestCheckBox ();
			
			Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");

			Assert.IsFalse (c.AutoPostBack, "AutoPostBack");
			Assert.IsFalse (c.Checked, "Checked");
			Assert.AreEqual (String.Empty, c.Text, "Text");
			Assert.AreEqual (TextAlign.Right, c.TextAlign, "TextAlign");
			
			Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count-2");

#if NET_2_0
			Assert.IsFalse (c.CausesValidation, "CausesValidation");
			Assert.AreEqual (String.Empty, c.ValidationGroup, "ValidationGroup");
#endif
		}
		public void InputAttributesTest2 ()
		{
			TestCheckBox c = new TestCheckBox ();
			c.InputAttributes.Add ("value", "value1");
			c.Text = "Title";
			c.Checked = true;
#if NET_4_0
			string origHtml = "<input id=\"\" type=\"checkbox\" checked=\"checked\" value=\"value1\" /><label for=\"\">Title</label>";
#else
			string origHtml = "<input type=\"checkbox\" checked=\"checked\" value=\"value1\" /><label for>Title</label>";
#endif
			string html = c.Render ();
			HtmlDiff.AssertAreEqual (origHtml, html, "#A1");
		}
Ejemplo n.º 14
0
		public void LabelAttributesTest_1 ()
		{
			TestCheckBox c = new TestCheckBox ();
			c.ID = "Check";
			c.Text = "CheckBoxText";
			c.LabelAttributes.Add ("Atribute", "Test");
			string html = c.Render ();
			HtmlDiff.AssertAreEqual ("<input id=\"Check\" type=\"checkbox\" name=\"Check\" /><label for=\"Check\" Atribute=\"Test\">CheckBoxText</label>", html, "Label Attributes fail#1");
		}
Ejemplo n.º 15
0
		public void InputAttributesTest ()
		{
			TestCheckBox c = new TestCheckBox ();
			c.InputAttributes.Add ("Atribute", "Test");
		 	string html = c.Render ();
			HtmlDiff.AssertAreEqual ("<input type=\"checkbox\" Atribute=\"Test\" />", html, "Input Attribute fail");
		}
Ejemplo n.º 16
0
		public void LabelAttributesTest_2 ()
		{
			TestCheckBox c = new TestCheckBox ();
			c.LabelAttributes.Add ("Atribute", "Test");
			string html = c.Render ();
			HtmlDiff.AssertAreEqual ("<input type=\"checkbox\" />", html, "Label Attributes fail#2");
		}
Ejemplo n.º 17
0
		public void NullProperties ()
		{
			TestCheckBox c = new TestCheckBox ();
			
			c.Text = null;
			Assert.AreEqual (String.Empty, c.Text, "Text");
			c.TextAlign = TextAlign.Right;
			Assert.AreEqual (TextAlign.Right, c.TextAlign, "TextAlign");
			c.AutoPostBack = true;
			Assert.IsTrue (c.AutoPostBack, "AutoPostBack");
			c.Checked = true;
			Assert.IsTrue (c.Checked, "Checked");
			
			Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");
			Assert.AreEqual (3, c.StateBag.Count, "ViewState.Count-1");
		}
Ejemplo n.º 18
0
		public void CleanProperties ()
		{
			TestCheckBox c = new TestCheckBox ();

			c.Text = "text";
			Assert.AreEqual ("text", c.Text, "Text");
			c.AutoPostBack = true;
			c.TextAlign = TextAlign.Left;
			c.Checked = true;

			Assert.AreEqual (4, c.StateBag.Count, "ViewState.Count");
			Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");

			c.Text = null;
			c.AutoPostBack = false;
			c.TextAlign = TextAlign.Right;
			c.Checked = false;

			// If Text is null it is removed from the ViewState
			Assert.AreEqual (3, c.StateBag.Count, "ViewState.Count-2");
			// This was failing on mono, because the
			// viewstate is holding an int not an enum.
			// (it passes on ms)
			Assert.AreEqual (TextAlign.Right, c.StateBag["TextAlign"], "TextAlign");
			Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count-2");
		}
Ejemplo n.º 19
0
		public void CheckboxViewstateValidation ()
		{
			// for some reason, MS doesn't save the validation
			// properties to the viewstate for the Checkbox
			// control.  why not?
			TestCheckBox o = new TestCheckBox ();
			o.ValidationGroup = "VG1";
			o.CausesValidation = true;
			o.TrackState ();
			Assert.AreEqual ("VG1", o.ValidationGroup, "V1");
			Assert.IsTrue (o.CausesValidation, "V2");
			object state = o.SaveState ();
			TestCheckBox copy = new TestCheckBox ();
			copy.LoadState (state);
			Assert.AreEqual ("", copy.ValidationGroup, "V3");
			Assert.IsFalse (copy.CausesValidation, "V4");
		}
Ejemplo n.º 20
0
		public void Render ()
		{
			TestCheckBox c = new TestCheckBox ();
			c.ID = "ID";
			c.Text = "Text";

			c.TextAlign = TextAlign.Left;
			Assert.AreEqual (@"<label for=""ID"">Text</label><input id=""ID"" type=""checkbox"" name=""ID"" />", c.Render (), "R#1");
			c.TextAlign = TextAlign.Right;
			Assert.AreEqual (@"<input id=""ID"" type=""checkbox"" name=""ID"" /><label for=""ID"">Text</label>", c.Render (), "R#2");

			c.Attributes ["style"] = "color:red;";
			c.TextAlign = TextAlign.Left;
			Assert.AreEqual (@"<span style=""color:red;""><label for=""ID"">Text</label><input id=""ID"" type=""checkbox"" name=""ID"" /></span>",
					c.Render (), "R#3");
			
			c.TextAlign = TextAlign.Right;
			Assert.AreEqual (@"<span style=""color:red;""><input id=""ID"" type=""checkbox"" name=""ID"" /><label for=""ID"">Text</label></span>",
					c.Render (), "R#4");

			c.Attributes ["style"] = null;

			c.ForeColor = Color.Red;
			c.TextAlign = TextAlign.Left;
			Assert.AreEqual (@"<span style=""color:Red;""><label for=""ID"">Text</label><input id=""ID"" type=""checkbox"" name=""ID"" /></span>",
					c.Render (), "R#4");
			
			c.TextAlign = TextAlign.Right;
			Assert.AreEqual (@"<span style=""color:Red;""><input id=""ID"" type=""checkbox"" name=""ID"" /><label for=""ID"">Text</label></span>",
					c.Render (), "R#6");	
		}