3 // - Unit tests for System.Web.UI.WebControls.Table
6 // Sebastien Pouliot <sebastien@ximian.com>
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 using System.Web.UI.WebControls;
35 using MonoTests.SystemWeb.Framework;
37 using NUnit.Framework;
38 using MonoTests.stand_alone.WebHarness;
40 namespace MonoTests.System.Web.UI.WebControls {
42 public class TestTable : Table {
45 get { return base.TagName; }
48 public StateBag StateBag {
49 get { return base.ViewState; }
52 public string Render ()
54 StringWriter sw = new StringWriter ();
56 HtmlTextWriter writer = new HtmlTextWriter (sw);
58 return writer.InnerWriter.ToString ();
61 public Style GetStyle ()
63 return base.CreateControlStyle ();
65 protected override void RaisePostBackEvent (string argument)
67 WebTest.CurrentTest.UserData = "RaisePostBackEvent";
68 base.RaisePostBackEvent (argument);
74 public class TableTest {
76 private const string imageUrl = "http://www.mono-project.com/stylesheets/images.wiki.png";
77 private const string localImageUrl = "foo.jpg";
79 private HtmlTextWriter GetWriter ()
81 StringWriter sw = new StringWriter ();
83 return new HtmlTextWriter (sw);
87 public void DefaultProperties ()
89 TestTable t = new TestTable ();
90 Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count");
91 Assert.AreEqual (0, t.StateBag.Count, "ViewState.Count");
93 Assert.AreEqual (String.Empty, t.BackImageUrl, "BackImageUrl");
94 Assert.AreEqual (String.Empty, t.Caption, "Caption");
95 Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "CaptionAlign");
96 Assert.AreEqual (-1, t.CellPadding, "CellPadding");
97 Assert.AreEqual (-1, t.CellSpacing, "CellSpacing");
98 Assert.AreEqual (GridLines.None, t.GridLines, "GridLines");
99 Assert.AreEqual (HorizontalAlign.NotSet, t.HorizontalAlign, "HorizontalAlign");
100 Assert.AreEqual (0, t.Rows.Count, "Rows.Count");
102 Assert.AreEqual ("table", t.Tag, "TagName");
103 Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count-2");
104 Assert.AreEqual (0, t.StateBag.Count, "ViewState.Count-2");
105 Assert.AreEqual (String.Empty, t.Caption, "Caption");
106 Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "CaptionAlign");
110 public void Caption ()
112 TestTable t = new TestTable ();
113 t.Caption = "CaptionText";
114 string html = t.Render ();
116 string orig = "<table>\n\t<caption>\n\t\tCaptionText\n\t</caption>\n</table>";
118 string orig = "<table border=\"0\">\n\t<caption>\n\t\tCaptionText\n\t</caption>\n</table>";
120 HtmlDiff.AssertAreEqual (orig, html, "Caption");
124 public void CaptionAlign ()
126 TestTable t = new TestTable ();
127 t.Caption = "CaptionText";
128 t.CaptionAlign = TableCaptionAlign.Left;
129 string html = t.Render ();
131 string orig = "<table>\n\t<caption align=\"Left\">\n\t\tCaptionText\n\t</caption>\n</table>";
133 string orig = "<table border=\"0\">\n\t<caption align=\"Left\">\n\t\tCaptionText\n\t</caption>\n</table>";
135 HtmlDiff.AssertAreEqual (orig, html, "CaptionAlign");
138 public void NullProperties ()
140 TestTable t = new TestTable ();
141 t.BackImageUrl = String.Empty; // doesn't accept null, see specific test
142 Assert.AreEqual (String.Empty, t.BackImageUrl, "BackImageUrl");
143 t.Caption = null; // doesn't get added to ViewState
144 Assert.AreEqual (String.Empty, t.Caption, "Caption");
145 t.CaptionAlign = TableCaptionAlign.NotSet;
146 Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "CaptionAlign");
148 Assert.AreEqual (-1, t.CellPadding, "CellPadding");
150 Assert.AreEqual (-1, t.CellSpacing, "CellSpacing");
151 t.GridLines = GridLines.None;
152 Assert.AreEqual (GridLines.None, t.GridLines, "GridLines");
153 t.HorizontalAlign = HorizontalAlign.NotSet;
154 Assert.AreEqual (HorizontalAlign.NotSet, t.HorizontalAlign, "HorizontalAlign");
156 Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count");
157 Assert.AreEqual (6, t.StateBag.Count, "ViewState.Count-1");
161 public void CleanProperties ()
163 TestTable t = new TestTable ();
164 t.BackImageUrl = imageUrl;
165 Assert.AreEqual (imageUrl, t.BackImageUrl, "BackImageUrl");
167 Assert.AreEqual ("Mono", t.Caption, "Caption");
168 t.CaptionAlign = TableCaptionAlign.Top;
169 Assert.AreEqual (TableCaptionAlign.Top, t.CaptionAlign, "CaptionAlign");
171 Assert.AreEqual (1, t.CellPadding, "CellPadding");
173 Assert.AreEqual (2, t.CellSpacing, "CellSpacing");
174 t.GridLines = GridLines.Both;
175 Assert.AreEqual (GridLines.Both, t.GridLines, "GridLines");
176 t.HorizontalAlign = HorizontalAlign.Justify;
177 Assert.AreEqual (HorizontalAlign.Justify, t.HorizontalAlign, "HorizontalAlign");
178 Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count");
179 Assert.AreEqual (7, t.StateBag.Count, "ViewState.Count");
181 t.BackImageUrl = String.Empty; // doesn't accept null, see specific test
182 Assert.AreEqual (String.Empty, t.BackImageUrl, "-BackImageUrl");
183 t.Caption = null; // removed
184 Assert.AreEqual (String.Empty, t.Caption, "-Caption");
185 t.CaptionAlign = TableCaptionAlign.NotSet;
186 Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "-CaptionAlign");
188 Assert.AreEqual (-1, t.CellPadding, "-CellPadding");
190 Assert.AreEqual (-1, t.CellSpacing, "-CellSpacing");
191 t.GridLines = GridLines.None;
192 Assert.AreEqual (GridLines.None, t.GridLines, "-GridLines");
193 t.HorizontalAlign = HorizontalAlign.NotSet;
194 Assert.AreEqual (HorizontalAlign.NotSet, t.HorizontalAlign, "-HorizontalAlign");
196 Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count-1");
197 Assert.AreEqual (6, t.StateBag.Count, "ViewState.Count-1");
201 // LAMESPEC: undocumented (all others property I've seen takes null as the default value)
202 [ExpectedException (typeof (ArgumentNullException))]
203 public void BackImageUrl_Null ()
205 Table t = new Table ();
206 t.BackImageUrl = null;
210 [ExpectedException (typeof (ArgumentOutOfRangeException))]
211 public void CaptionAlign_Invalid ()
213 Table t = new Table ();
214 t.CaptionAlign = (TableCaptionAlign)Int32.MinValue;
218 // LAMESPEC: undocumented exception but similar to Image
219 [ExpectedException (typeof (ArgumentOutOfRangeException))]
220 public void GridLines_Invalid ()
222 Table t = new Table ();
223 t.GridLines = (GridLines)Int32.MinValue;
227 // LAMESPEC: undocumented exception but similar to Image
228 [ExpectedException (typeof (ArgumentOutOfRangeException))]
229 public void HorizontalAlign_Invalid ()
231 Table t = new Table ();
232 t.HorizontalAlign = (HorizontalAlign)Int32.MinValue;
236 public void BorderWidth ()
238 Table t = new Table ();
239 Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.None");
240 t.GridLines = GridLines.Horizontal;
241 Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.Horizontal");
242 t.GridLines = GridLines.Vertical;
243 Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.Vertical");
244 t.GridLines = GridLines.Both;
245 Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.Both");
246 // note: but border="1" when rendered
250 public void Render ()
252 TestTable t = new TestTable ();
253 string s = t.Render ();
255 Assert.AreEqual ("<table>\n\n</table>", s, "empty/default");
257 Assert.AreEqual ("<table border=\"0\">\n\n</table>", s, "empty/default");
263 Assert.AreEqual ("<table cellpadding=\"1\">\n\n</table>", s, "CellPadding");
265 Assert.AreEqual ("<table cellpadding=\"1\" border=\"0\">\n\n</table>", s, "CellPadding");
272 Assert.AreEqual ("<table cellspacing=\"2\">\n\n</table>", s, "CellSpacing");
274 Assert.AreEqual ("<table cellspacing=\"2\" border=\"0\">\n\n</table>", s, "CellSpacing");
278 t.GridLines = GridLines.Horizontal;
280 Assert.AreEqual ("<table rules=\"rows\" border=\"1\">\n\n</table>", s, "GridLines.Horizontal");
281 t.GridLines = GridLines.Vertical;
283 Assert.AreEqual ("<table rules=\"cols\" border=\"1\">\n\n</table>", s, "GridLines.Vertical");
284 t.GridLines = GridLines.Both;
286 Assert.AreEqual ("<table rules=\"all\" border=\"1\">\n\n</table>", s, "GridLines.Both");
287 t.GridLines = GridLines.None;
289 t.BorderWidth = new Unit (2);
292 Assert.IsTrue ((s.IndexOf ("\"border-width:2px;border-style:solid;\"") > 0), "border=0/2");
294 Assert.IsTrue ((s.IndexOf ("border=\"0\"") > 0), "border=0/2");
296 t.GridLines = GridLines.Horizontal;
299 Console.WriteLine (s);
300 Assert.IsTrue ((s.IndexOf ("rules=\"rows\" style=\"border-width:2px;border-style:solid;\"") > 0), "2/GridLines.Horizontal");
302 Assert.IsTrue ((s.IndexOf ("rules=\"rows\" border=\"2\"") > 0), "2/GridLines.Horizontal");
304 t.GridLines = GridLines.Vertical;
307 Assert.IsTrue ((s.IndexOf ("rules=\"cols\" style=\"border-width:2px;border-style:solid;\"") > 0), "2/GridLines.Vertical");
309 Assert.IsTrue ((s.IndexOf ("rules=\"cols\" border=\"2\"") > 0), "2/GridLines.Vertical");
311 t.GridLines = GridLines.Both;
314 Assert.IsTrue ((s.IndexOf ("rules=\"all\" style=\"border-width:2px;border-style:solid;\"") > 0), "2/GridLines.Both");
316 Assert.IsTrue ((s.IndexOf ("rules=\"all\" border=\"2\"") > 0), "2/GridLines.Both");
318 t.GridLines = GridLines.None;
319 t.BorderWidth = new Unit ();
321 t.HorizontalAlign = HorizontalAlign.Left;
324 Assert.AreEqual ("<table align=\"left\">\n\n</table>", s.ToLower (), "HorizontalAlign.Left");
326 Assert.AreEqual ("<table align=\"left\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Left");
328 t.HorizontalAlign = HorizontalAlign.Center;
331 Assert.AreEqual ("<table align=\"center\">\n\n</table>", s.ToLower (), "HorizontalAlign.Center");
333 Assert.AreEqual ("<table align=\"center\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Center");
335 t.HorizontalAlign = HorizontalAlign.Right;
338 Assert.AreEqual ("<table align=\"right\">\n\n</table>", s.ToLower (), "HorizontalAlign.Right");
340 Assert.AreEqual ("<table align=\"right\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Right");
342 t.HorizontalAlign = HorizontalAlign.Justify;
345 Assert.AreEqual ("<table align=\"justify\">\n\n</table>", s.ToLower (), "HorizontalAlign.Justify");
347 Assert.AreEqual ("<table align=\"justify\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Justify");
349 t.HorizontalAlign = HorizontalAlign.NotSet;
354 Assert.AreEqual ("<table>\n\t<caption>\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption");
356 Assert.AreEqual ("<table border=\"0\">\n\t<caption>\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption");
359 t.CaptionAlign = TableCaptionAlign.Top;
362 Assert.AreEqual ("<table>\n\t<caption align=\"top\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Top");
364 Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"top\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Top");
366 t.CaptionAlign = TableCaptionAlign.Bottom;
369 Assert.AreEqual ("<table>\n\t<caption align=\"bottom\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Bottom");
371 Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"bottom\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Bottom");
373 t.CaptionAlign = TableCaptionAlign.Right;
376 Assert.AreEqual ("<table>\n\t<caption align=\"right\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Right");
378 Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"right\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Right");
380 t.CaptionAlign = TableCaptionAlign.Left;
383 Assert.AreEqual ("<table>\n\t<caption align=\"left\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Left");
385 Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"left\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Left");
390 Assert.AreEqual ("<table>\n\n</table>", s, "CaptionAlign without Caption");
392 Assert.AreEqual ("<table border=\"0\">\n\n</table>", s, "CaptionAlign without Caption");
394 t.CaptionAlign = TableCaptionAlign.NotSet;
396 t.BackImageUrl = imageUrl;
399 Assert.AreEqual ("<table style=\"background-image:url(http://www.mono-project.com/stylesheets/images.wiki.png);\">\n\n</table>", s, "BackImageUrl");
401 Assert.AreEqual ("<table border=\"0\" style=\"background-image:url(http://www.mono-project.com/stylesheets/images.wiki.png);\">\n\n</table>", s, "BackImageUrl");
403 t.BackImageUrl = localImageUrl;
406 Assert.AreEqual ("<table style=\"background-image:url(foo.jpg);\">\n\n</table>", s, "BackImageUrl");
408 Assert.AreEqual ("<table border=\"0\" style=\"background-image:url(foo.jpg);\">\n\n</table>", s, "BackImageUrl");
410 t.BackImageUrl = String.Empty;
414 [Category ("NunitWeb")]
415 public void RenderInAspxPage ()
417 WebTest t = new WebTest (PageInvoker.CreateOnLoad (RenderInAspxPage_OnLoad));
418 string res = t.Run ();
420 Assert.IsTrue (res.IndexOf ("<table id=\"MagicID_A1C3\" style=\"background-image:url(foo.jpg);\"") != -1, res);
422 Assert.IsTrue (res.IndexOf ("<table id=\"MagicID_A1C3\" border=\"0\" style=\"background-image:url(foo.jpg);\"")!= -1, res);
426 public static void RenderInAspxPage_OnLoad (Page p)
428 Table t = new Table ();
429 t.BackImageUrl = "foo.jpg";
430 t.ID = "MagicID_A1C3";
431 p.Form.Controls.Add (t);
436 public void CreateControlStyle ()
438 TestTable t = new TestTable ();
439 t.BackImageUrl = imageUrl;
442 t.GridLines = GridLines.Horizontal;
443 t.HorizontalAlign = HorizontalAlign.Left;
445 TableStyle ts = (TableStyle)t.GetStyle ();
447 ts.BackImageUrl = "mono";
448 Assert.AreEqual ("mono", t.BackImageUrl, "BackImageUrl-2");
449 ts.CellPadding = Int32.MaxValue;
450 Assert.AreEqual (Int32.MaxValue, t.CellPadding, "CellPadding-2");
452 Assert.AreEqual (0, t.CellSpacing, "CellSpacing-2");
453 ts.GridLines = GridLines.Vertical;
454 Assert.AreEqual (GridLines.Vertical, t.GridLines, "GridLines-2");
455 ts.HorizontalAlign = HorizontalAlign.Right;
456 Assert.AreEqual (HorizontalAlign.Right, t.HorizontalAlign, "HorizontalAlign-2");
459 private string Adjust (string s)
461 // right now Mono doesn't generate the exact same indentation/lines as MS implementation
462 // and different fx versions have different casing for enums
463 return s.Replace ("\n", "").Replace ("\t", "").ToLower ();
469 TestTable t = new TestTable ();
470 Assert.AreEqual (0, t.Rows.Count, "0");
471 TableRow tr = new TableRow ();
474 Assert.AreEqual (1, t.Rows.Count, "r1");
475 Assert.AreEqual (1, t.Controls.Count, "c1");
476 string s = t.Render ();
478 Assert.AreEqual (Adjust ("<table>\n\t<tr>\n\n\t</tr>\n</table>"), Adjust (s), "tr-1");
480 Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr>\n\n\t</tr>\n</table>"), Adjust (s), "tr-1");
483 // change instance properties
484 tr.HorizontalAlign = HorizontalAlign.Justify;
487 Assert.AreEqual (Adjust ("<table>\n\t<tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-1j");
489 Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-1j");
492 // add it again (same instance)
494 Assert.AreEqual (1, t.Rows.Count, "t1bis");
495 Assert.AreEqual (1, t.Controls.Count, "c1bis");
498 Assert.AreEqual (Adjust ("<table>\n\t<tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-1bis");
500 Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-1bis");
502 tr.HorizontalAlign = HorizontalAlign.NotSet;
504 tr = new TableRow ();
505 tr.HorizontalAlign = HorizontalAlign.Justify;
507 Assert.AreEqual (2, t.Rows.Count, "r2");
508 Assert.AreEqual (2, t.Controls.Count, "c2");
511 Assert.AreEqual (Adjust ("<table>\n\t<tr>\n\n\t</tr><tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-2");
513 Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr>\n\n\t</tr><tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-2");
516 tr = new TableRow ();
517 tr.VerticalAlign = VerticalAlign.Bottom;
519 Assert.AreEqual (3, t.Rows.Count, "r3");
520 Assert.AreEqual (3, t.Controls.Count, "c3");
523 Assert.AreEqual (Adjust ("<table>\n\t<tr>\n\n\t</tr><tr align=\"justify\">\n\n\t</tr><tr valign=\"bottom\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-3");
525 Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr>\n\n\t</tr><tr align=\"justify\">\n\n\t</tr><tr valign=\"bottom\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-3");
528 t.Caption = "caption";
531 Assert.AreEqual (Adjust ("<table>\n\t<caption>\n\t\tcaption\n\t</caption><tr>\n\n\t</tr><tr align=\"justify\">\n\n\t</tr><tr valign=\"bottom\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-2c");
533 Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<caption>\n\t\tcaption\n\t</caption><tr>\n\n\t</tr><tr align=\"justify\">\n\n\t</tr><tr valign=\"bottom\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-2c");
538 [ExpectedException (typeof (NullReferenceException))]
539 public void ControlsAdd_Null ()
541 new Table ().Controls.Add (null);
545 [ExpectedException (typeof (ArgumentException))]
546 public void ControlsAdd_LiteralControl ()
548 new Table ().Controls.Add (new LiteralControl ("mono"));
552 public void ControlsAdd_TableRow ()
554 Table t = new Table ();
555 t.Controls.Add (new TableRow ());
556 Assert.AreEqual (1, t.Controls.Count, "Controls");
557 Assert.AreEqual (1, t.Rows.Count, "Rows");
561 public void ControlsAdd_TestTableRow ()
563 Table t = new Table ();
564 t.Controls.Add (new TestTableRow ());
565 Assert.AreEqual (1, t.Controls.Count, "Controls");
566 Assert.AreEqual (1, t.Rows.Count, "Rows");
570 [ExpectedException (typeof (NullReferenceException))]
571 public void ControlsAddAt_Null ()
573 new Table ().Controls.AddAt (0, null);
577 [ExpectedException (typeof (ArgumentOutOfRangeException))]
578 public void ControlsAddAt_Negative ()
580 new Table ().Controls.AddAt (Int32.MinValue, new TableRow ());
584 [ExpectedException (typeof (ArgumentException))]
585 public void ControlsAddAt_LiteralControl ()
587 new Table ().Controls.AddAt (0, new LiteralControl ("mono"));
591 public void ControlsAddAt_TableRow ()
593 Table t = new Table ();
594 t.Controls.AddAt (0, new TableRow ());
595 Assert.AreEqual (1, t.Controls.Count, "Controls");
596 Assert.AreEqual (1, t.Rows.Count, "Rows");
600 public void ControlsAddAt_TestTableRow ()
602 Table t = new Table ();
603 t.Controls.AddAt (0, new TestTableRow ());
604 Assert.AreEqual (1, t.Controls.Count, "Controls");
605 Assert.AreEqual (1, t.Rows.Count, "Rows");
609 [ExpectedException (typeof (NullReferenceException))]
610 public void RenderBeginTag_Null ()
612 Table t = new Table ();
613 t.RenderBeginTag (null);
617 public void RenderBeginTag_Empty ()
619 HtmlTextWriter writer = GetWriter ();
620 Table t = new Table ();
621 t.RenderBeginTag (writer);
622 string s = writer.InnerWriter.ToString ();
624 Assert.AreEqual ("<table>\n", s, "empty");
626 Assert.AreEqual ("<table border=\"0\">\n", s, "empty");
631 public void RenderBeginTag_Attributes ()
633 HtmlTextWriter writer = GetWriter ();
634 Table t = new Table ();
636 t.RenderBeginTag (writer);
637 string s = writer.InnerWriter.ToString ();
639 Assert.AreEqual ("<table cellpadding=\"1\">\n", s, "CellPadding");
641 Assert.AreEqual ("<table cellpadding=\"1\" border=\"0\">\n", s, "CellPadding");
646 public void RenderBeginTag_Caption ()
648 HtmlTextWriter writer = GetWriter ();
649 Table t = new Table ();
650 t.Caption = "caption";
651 t.RenderBeginTag (writer);
652 string s = writer.InnerWriter.ToString ();
654 Assert.AreEqual ("<table>\n\t<caption>\n\t\tcaption\n\t</caption>", s, "caption");
656 Assert.AreEqual ("<table border=\"0\">\n\t<caption>\n\t\tcaption\n\t</caption>", s, "caption");
661 public void RenderBeginTag_Caption_Align ()
663 HtmlTextWriter writer = GetWriter ();
664 Table t = new Table ();
665 t.Caption = "caption";
666 t.CaptionAlign = TableCaptionAlign.Top;
667 t.RenderBeginTag (writer);
668 string s = writer.InnerWriter.ToString ();
670 Assert.AreEqual ("<table>\n\t<caption align=\"top\">\n\t\tcaption\n\t</caption>", s.ToLower (), "caption");
672 Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"top\">\n\t\tcaption\n\t</caption>", s.ToLower (), "caption");
677 public void RenderBeginTag_Row ()
679 HtmlTextWriter writer = GetWriter ();
680 Table t = new Table ();
681 t.Rows.Add (new TableRow ());
682 t.RenderBeginTag (writer);
683 string s = writer.InnerWriter.ToString ();
685 Assert.AreEqual ("<table>\n", s, "tr");
687 Assert.AreEqual ("<table border=\"0\">\n", s, "tr");
692 [Category("NunitWeb")] // Note: No event fired , only flow been checked.
693 public void RaisePostBackEvent ()
695 WebTest t = new WebTest (PageInvoker.CreateOnLoad (RaisePostBackEvent__Init));
696 string str = t.Run ();
697 FormRequest fr = new FormRequest (t.Response, "form1");
698 fr.Controls.Add ("__EVENTTARGET");
699 fr.Controls.Add ("__EVENTARGUMENT");
700 fr.Controls["__EVENTTARGET"].Value = "Table";
701 fr.Controls["__EVENTARGUMENT"].Value = "";
704 Assert.AreEqual ("RaisePostBackEvent", (String) t.UserData, "RaisePostBackEvent");
707 public static void RaisePostBackEvent__Init (Page page)
709 TestTable t = new TestTable ();
711 page.Form.Controls.Add (t);
714 [TestFixtureTearDown]
715 public void TearDown ()