Exemplo n.º 1
0
		public void DefaultProperties ()
		{
			TestTableCell td = new TestTableCell ();
			Assert.AreEqual (0, td.Attributes.Count, "Attributes.Count");
			Assert.AreEqual (0, td.StateBag.Count, "ViewState.Count");

			Assert.AreEqual (0, td.ColumnSpan, "ColumnSpan");
			Assert.AreEqual (HorizontalAlign.NotSet, td.HorizontalAlign, "HorizontalAlign");
			Assert.AreEqual (0, td.RowSpan, "RowSpan");
			Assert.AreEqual (String.Empty, td.Text, "Text");
			Assert.AreEqual (VerticalAlign.NotSet, td.VerticalAlign, "VerticalAlign");
			Assert.IsTrue (td.Wrap, "Wrap");
			Assert.AreEqual (0, td.AssociatedHeaderCellID.Length, "AssociatedHeaderCellID");
			Assert.AreEqual ("td", td.Tag, "TagName");
			Assert.AreEqual (0, td.Attributes.Count, "Attributes.Count-2");
			Assert.AreEqual (0, td.StateBag.Count, "ViewState.Count-2");
		}
Exemplo n.º 2
0
		public void NullProperties ()
		{
			TestTableCell td = new TestTableCell ();
			td.ColumnSpan = 0;
			Assert.AreEqual (0, td.ColumnSpan, "ColumnSpan");
			td.HorizontalAlign = HorizontalAlign.NotSet;
			Assert.AreEqual (HorizontalAlign.NotSet, td.HorizontalAlign, "HorizontalAlign");
			td.RowSpan = 0;
			Assert.AreEqual (0, td.RowSpan, "RowSpan");
			td.Text = null;
			Assert.AreEqual (String.Empty, td.Text, "Text");
			td.VerticalAlign = VerticalAlign.NotSet;
			Assert.AreEqual (VerticalAlign.NotSet, td.VerticalAlign, "VerticalAlign");
			td.Wrap = true;
			Assert.IsTrue (td.Wrap, "Wrap");
			td.AssociatedHeaderCellID = new string[0];
			Assert.AreEqual (0, td.AssociatedHeaderCellID.Length, "AssociatedHeaderCellID");
			Assert.AreEqual (6, td.StateBag.Count, "ViewState.Count-1");
			Assert.AreEqual (0, td.Attributes.Count, "Attributes.Count");
			// note: nothing is removed (no need for CleanProperties test)
		}
Exemplo n.º 3
0
		public void Text_Add_Controls ()
		{
			TestTableCell td = new TestTableCell ();
			td.Text = "Mono";
			Assert.AreEqual ("Mono", td.Text, "Text");
			Assert.IsFalse (td.HasControls (), "!HasControls");
			// then add 10 more controls
			for (int i = 0; i < 10; i++)
				td.Add (new Table ());
			Assert.AreEqual (11, td.Controls.Count, "11");
			// Text was moved into a LiteralControl
			Assert.IsTrue ((td.Controls[0] is LiteralControl), "LiteralControl");
			// and removed from property
			Assert.AreEqual (String.Empty, td.Text, "Test-2");
		}
Exemplo n.º 4
0
		public void PropertyOrControls ()
		{
			TestTableCell tc = new TestTableCell ();
			tc.Controls.Add (new LiteralControl ("hola"));
			tc.StateBag ["Text"] = "adios";
			string str = tc.Render ();
			Assert.AreEqual (1, tc.Controls.Count, "#01");
			Assert.IsTrue (-1 != str.IndexOf ("hola"), "#02");
			Assert.IsTrue (-1 == str.IndexOf ("adios"), "#03");

			tc = new TestTableCell ();
			tc.StateBag ["Text"] = "adios";
			str = tc.Render ();
			Assert.AreEqual (0, tc.Controls.Count, "#04");
			Assert.IsTrue (-1 == str.IndexOf ("hola"), "#05");
			Assert.IsTrue (-1 != str.IndexOf ("adios"), "#06");
		}
Exemplo n.º 5
0
		public void Add_LiteralControl_Literal_And_Control ()
		{
			TestTableCell td = new TestTableCell ();
			// this is moved into the (empty) Text property
			td.Add (new LiteralControl ("Mono2"));
			Assert.IsFalse (td.HasControls (), "HasControls");
			td.Add (new TableCell ());
			Assert.AreEqual (2, td.Controls.Count, "NControls");
			Assert.AreEqual (typeof (LiteralControl), td.Controls [0].GetType (), "type 1");
			Assert.AreEqual (typeof (TableCell), td.Controls [1].GetType (), "type 2");
		}
Exemplo n.º 6
0
		public void HasControls_Text ()
		{
			TestTableCell td = new TestTableCell ();
			for (int i = 0; i < 10; i++)
				td.Add (new Table ());
			Assert.AreEqual (10, td.Controls.Count, "10");
			// this removes all existing controls and set the Text property
			td.Text = "Mono";
			Assert.AreEqual ("Mono", td.Text, "Text");
			Assert.AreEqual (0, td.Controls.Count, "0");
		}
Exemplo n.º 7
0
		public void Add_LiteralControl_Literal_And_Literal ()
		{
			TestTableCell td = new TestTableCell ();
			// this is moved into the (empty) Text property
			td.Add (new LiteralControl ("Mono"));
			Assert.IsFalse (td.HasControls (), "!HasControls");
			Assert.AreEqual ("Mono", td.Text, "Text");
			td.Add (new LiteralControl ("Mono2"));
			Assert.IsFalse (td.HasControls (), "HasControls-2");
			Assert.AreEqual ("MonoMono2", td.Text, "Text");
			Assert.AreEqual (0, td.Controls.Count, "NControls");
		}
Exemplo n.º 8
0
		public void Add_LiteralControl_Text ()
		{
			TestTableCell td = new TestTableCell ();
			// this is moved into the (empty) Text property
			td.Add (new LiteralControl ("Mono"));
			Assert.IsFalse (td.HasControls (), "!HasControls");
			Assert.AreEqual ("Mono", td.Text, "Text");
			// this replace the current Text property
			td.Text = "Go Mono";
			Assert.IsFalse (td.HasControls (), "!HasControls-2");
			Assert.AreEqual ("Go Mono", td.Text, "Text-2");
		}
Exemplo n.º 9
0
		public void Text_Add_LiteralControl ()
		{
			TestTableCell td = new TestTableCell ();
			td.Text = "Mono";
			Assert.AreEqual ("Mono", td.Text, "Text-1");
			Assert.IsFalse (td.HasControls (), "!HasControls");
			// this replace the current Text property
			td.Add (new LiteralControl ("Go Mono"));
			Assert.IsFalse (td.HasControls (), "!HasControls-2");
			Assert.AreEqual ("Go Mono", td.Text, "Text-2");
		}
Exemplo n.º 10
0
		public void CreateControlStyle ()
		{
			TestTableCell td = new TestTableCell ();
			td.HorizontalAlign = HorizontalAlign.Left;
			td.VerticalAlign = VerticalAlign.Bottom;
			td.Wrap = false;

			TableItemStyle tis = (TableItemStyle)td.GetStyle ();
			// is it live ?
			tis.HorizontalAlign = HorizontalAlign.Right;
			Assert.AreEqual (HorizontalAlign.Right, td.HorizontalAlign, "HorizontalAlign-2");
			tis.VerticalAlign = VerticalAlign.Top;
			Assert.AreEqual (VerticalAlign.Top, td.VerticalAlign, "VerticalAlign-2");
			tis.Wrap = false;
			Assert.IsFalse (tis.Wrap, "Wrap-2");
		}
Exemplo n.º 11
0
		public void Render ()
		{
			TestTableCell td = new TestTableCell ();
			string s = td.Render ();
			Assert.AreEqual ("<td></td>", s, "empty/default");

			// case varies with fx versions
			td.HorizontalAlign = HorizontalAlign.Left;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" align=\"left\"") > 0), "HorizontalAlign.Left");
			td.HorizontalAlign = HorizontalAlign.Center;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" align=\"center\"") > 0), "HorizontalAlign.Center");
			td.HorizontalAlign = HorizontalAlign.Right;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" align=\"right\"") > 0), "HorizontalAlign.Justify");
			td.HorizontalAlign = HorizontalAlign.Justify;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" align=\"justify\"") > 0), "HorizontalAlign.Justify");
			td.HorizontalAlign = HorizontalAlign.NotSet;

			td.VerticalAlign = VerticalAlign.Top;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" valign=\"top\"") > 0), "VerticalAlign.Top");
			td.VerticalAlign = VerticalAlign.Middle;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" valign=\"middle\"") > 0), "VerticalAlign.Middle");
			td.VerticalAlign = VerticalAlign.Bottom;
			s = td.Render ();
			Assert.IsTrue ((s.ToLower ().IndexOf (" valign=\"bottom\"") > 0), "VerticalAlign.Bottom");
			td.VerticalAlign = VerticalAlign.NotSet;

			td.ColumnSpan = 1;
			s = td.Render ();
			Assert.AreEqual ("<td colspan=\"1\"></td>", s, "ColumnSpan");
			td.ColumnSpan = 0;

			td.RowSpan = 1;
			s = td.Render ();
			Assert.AreEqual ("<td rowspan=\"1\"></td>", s, "RowSpan");
			td.RowSpan = 0;

			td.Text = "text";
			s = td.Render ();
			Assert.AreEqual ("<td>text</td>", s, "Text");
			td.Text = null;

			td.Wrap = false;
			s = td.Render ();
			Assert.AreEqual ("<td style=\"white-space:nowrap;\"></td>", s, "Wrap");

			// it seems that rendering with AssociatedHeaderCellID property set
			// isn't (at least easyly) possible even if we build a whole table
			// with a page... it keeps throwing NullReferenceException. Even in a
			// web page using that property makes it easy to throw exceptions :(
			td.Wrap = true;
		}