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"); }
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"); }
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; }
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; }