TableTest.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. //
  2. // TableTest.cs
  3. // - Unit tests for System.Web.UI.WebControls.Table
  4. //
  5. // Author:
  6. // Sebastien Pouliot <[email protected]>
  7. //
  8. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  9. //
  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:
  17. //
  18. // The above copyright notice and this permission notice shall be
  19. // included in all copies or substantial portions of the Software.
  20. //
  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.
  28. //
  29. using System;
  30. using System.IO;
  31. using System.Web;
  32. using System.Web.UI;
  33. using System.Web.UI.WebControls;
  34. using NUnit.Framework;
  35. namespace MonoTests.System.Web.UI.WebControls {
  36. public class TestTable : Table {
  37. public string Tag {
  38. get { return base.TagName; }
  39. }
  40. public StateBag StateBag {
  41. get { return base.ViewState; }
  42. }
  43. public string Render ()
  44. {
  45. StringWriter sw = new StringWriter ();
  46. sw.NewLine = "\n";
  47. HtmlTextWriter writer = new HtmlTextWriter (sw);
  48. base.Render (writer);
  49. return writer.InnerWriter.ToString ();
  50. }
  51. public Style GetStyle ()
  52. {
  53. return base.CreateControlStyle ();
  54. }
  55. }
  56. [TestFixture]
  57. public class TableTest {
  58. private const string imageUrl = "http://www.mono-project.com/stylesheets/images.wiki.png";
  59. private HtmlTextWriter GetWriter ()
  60. {
  61. StringWriter sw = new StringWriter ();
  62. sw.NewLine = "\n";
  63. return new HtmlTextWriter (sw);
  64. }
  65. [Test]
  66. public void DefaultProperties ()
  67. {
  68. TestTable t = new TestTable ();
  69. Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count");
  70. Assert.AreEqual (0, t.StateBag.Count, "ViewState.Count");
  71. Assert.AreEqual (String.Empty, t.BackImageUrl, "BackImageUrl");
  72. Assert.AreEqual (String.Empty, t.Caption, "Caption");
  73. Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "CaptionAlign");
  74. Assert.AreEqual (-1, t.CellPadding, "CellPadding");
  75. Assert.AreEqual (-1, t.CellSpacing, "CellSpacing");
  76. Assert.AreEqual (GridLines.None, t.GridLines, "GridLines");
  77. Assert.AreEqual (HorizontalAlign.NotSet, t.HorizontalAlign, "HorizontalAlign");
  78. Assert.AreEqual (0, t.Rows.Count, "Rows.Count");
  79. Assert.AreEqual ("table", t.Tag, "TagName");
  80. Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count-2");
  81. Assert.AreEqual (0, t.StateBag.Count, "ViewState.Count-2");
  82. }
  83. [Test]
  84. public void NullProperties ()
  85. {
  86. TestTable t = new TestTable ();
  87. t.BackImageUrl = String.Empty; // doesn't accept null, see specific test
  88. Assert.AreEqual (String.Empty, t.BackImageUrl, "BackImageUrl");
  89. t.Caption = null; // doesn't get added to ViewState
  90. Assert.AreEqual (String.Empty, t.Caption, "Caption");
  91. t.CaptionAlign = TableCaptionAlign.NotSet;
  92. Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "CaptionAlign");
  93. t.CellPadding = -1;
  94. Assert.AreEqual (-1, t.CellPadding, "CellPadding");
  95. t.CellSpacing = -1;
  96. Assert.AreEqual (-1, t.CellSpacing, "CellSpacing");
  97. t.GridLines = GridLines.None;
  98. Assert.AreEqual (GridLines.None, t.GridLines, "GridLines");
  99. t.HorizontalAlign = HorizontalAlign.NotSet;
  100. Assert.AreEqual (HorizontalAlign.NotSet, t.HorizontalAlign, "HorizontalAlign");
  101. Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count");
  102. Assert.AreEqual (6, t.StateBag.Count, "ViewState.Count-1");
  103. }
  104. [Test]
  105. public void CleanProperties ()
  106. {
  107. TestTable t = new TestTable ();
  108. t.BackImageUrl = imageUrl;
  109. Assert.AreEqual (imageUrl, t.BackImageUrl, "BackImageUrl");
  110. t.Caption = "Mono";
  111. Assert.AreEqual ("Mono", t.Caption, "Caption");
  112. t.CaptionAlign = TableCaptionAlign.Top;
  113. Assert.AreEqual (TableCaptionAlign.Top, t.CaptionAlign, "CaptionAlign");
  114. t.CellPadding = 1;
  115. Assert.AreEqual (1, t.CellPadding, "CellPadding");
  116. t.CellSpacing = 2;
  117. Assert.AreEqual (2, t.CellSpacing, "CellSpacing");
  118. t.GridLines = GridLines.Both;
  119. Assert.AreEqual (GridLines.Both, t.GridLines, "GridLines");
  120. t.HorizontalAlign = HorizontalAlign.Justify;
  121. Assert.AreEqual (HorizontalAlign.Justify, t.HorizontalAlign, "HorizontalAlign");
  122. Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count");
  123. Assert.AreEqual (7, t.StateBag.Count, "ViewState.Count");
  124. t.BackImageUrl = String.Empty; // doesn't accept null, see specific test
  125. Assert.AreEqual (String.Empty, t.BackImageUrl, "-BackImageUrl");
  126. t.Caption = null; // removed
  127. Assert.AreEqual (String.Empty, t.Caption, "-Caption");
  128. t.CaptionAlign = TableCaptionAlign.NotSet;
  129. Assert.AreEqual (TableCaptionAlign.NotSet, t.CaptionAlign, "-CaptionAlign");
  130. t.CellPadding = -1;
  131. Assert.AreEqual (-1, t.CellPadding, "-CellPadding");
  132. t.CellSpacing = -1;
  133. Assert.AreEqual (-1, t.CellSpacing, "-CellSpacing");
  134. t.GridLines = GridLines.None;
  135. Assert.AreEqual (GridLines.None, t.GridLines, "-GridLines");
  136. t.HorizontalAlign = HorizontalAlign.NotSet;
  137. Assert.AreEqual (HorizontalAlign.NotSet, t.HorizontalAlign, "-HorizontalAlign");
  138. Assert.AreEqual (0, t.Attributes.Count, "Attributes.Count-1");
  139. Assert.AreEqual (6, t.StateBag.Count, "ViewState.Count-1");
  140. }
  141. [Test]
  142. // LAMESPEC: undocumented (all others property I've seen takes null as the default value)
  143. [ExpectedException (typeof (ArgumentNullException))]
  144. public void BackImageUrl_Null ()
  145. {
  146. Table t = new Table ();
  147. t.BackImageUrl = null;
  148. }
  149. [Test]
  150. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  151. public void CaptionAlign_Invalid ()
  152. {
  153. Table t = new Table ();
  154. t.CaptionAlign = (TableCaptionAlign)Int32.MinValue;
  155. }
  156. [Test]
  157. // LAMESPEC: undocumented exception but similar to Image
  158. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  159. public void GridLines_Invalid ()
  160. {
  161. Table t = new Table ();
  162. t.GridLines = (GridLines)Int32.MinValue;
  163. }
  164. [Test]
  165. // LAMESPEC: undocumented exception but similar to Image
  166. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  167. public void HorizontalAlign_Invalid ()
  168. {
  169. Table t = new Table ();
  170. t.HorizontalAlign = (HorizontalAlign)Int32.MinValue;
  171. }
  172. [Test]
  173. public void BorderWidth ()
  174. {
  175. Table t = new Table ();
  176. Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.None");
  177. t.GridLines = GridLines.Horizontal;
  178. Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.Horizontal");
  179. t.GridLines = GridLines.Vertical;
  180. Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.Vertical");
  181. t.GridLines = GridLines.Both;
  182. Assert.AreEqual (0, t.BorderWidth.Value, "GridLines.Both");
  183. // note: but border="1" when rendered
  184. }
  185. [Test]
  186. public void Render ()
  187. {
  188. TestTable t = new TestTable ();
  189. string s = t.Render ();
  190. Assert.AreEqual ("<table border=\"0\">\n\n</table>", s, "empty/default");
  191. t.CellPadding = 1;
  192. s = t.Render ();
  193. Assert.AreEqual ("<table cellpadding=\"1\" border=\"0\">\n\n</table>", s, "CellPadding");
  194. t.CellPadding = -1;
  195. t.CellSpacing = 2;
  196. s = t.Render ();
  197. Assert.AreEqual ("<table cellspacing=\"2\" border=\"0\">\n\n</table>", s, "CellSpacing");
  198. t.CellSpacing = -1;
  199. t.GridLines = GridLines.Horizontal;
  200. s = t.Render ();
  201. Assert.AreEqual ("<table rules=\"rows\" border=\"1\">\n\n</table>", s, "GridLines.Horizontal");
  202. t.GridLines = GridLines.Vertical;
  203. s = t.Render ();
  204. Assert.AreEqual ("<table rules=\"cols\" border=\"1\">\n\n</table>", s, "GridLines.Vertical");
  205. t.GridLines = GridLines.Both;
  206. s = t.Render ();
  207. Assert.AreEqual ("<table rules=\"all\" border=\"1\">\n\n</table>", s, "GridLines.Both");
  208. t.GridLines = GridLines.None;
  209. t.BorderWidth = new Unit (2);
  210. s = t.Render ();
  211. Assert.IsTrue ((s.IndexOf ("border=\"0\"") > 0), "border=0/2");
  212. t.GridLines = GridLines.Horizontal;
  213. s = t.Render ();
  214. Assert.IsTrue ((s.IndexOf ("rules=\"rows\" border=\"2\"") > 0), "2/GridLines.Horizontal");
  215. t.GridLines = GridLines.Vertical;
  216. s = t.Render ();
  217. Assert.IsTrue ((s.IndexOf ("rules=\"cols\" border=\"2\"") > 0), "2/GridLines.Vertical");
  218. t.GridLines = GridLines.Both;
  219. s = t.Render ();
  220. Assert.IsTrue ((s.IndexOf ("rules=\"all\" border=\"2\"") > 0), "2/GridLines.Both");
  221. t.GridLines = GridLines.None;
  222. t.BorderWidth = new Unit ();
  223. t.HorizontalAlign = HorizontalAlign.Left;
  224. s = t.Render ();
  225. Assert.AreEqual ("<table align=\"left\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Left");
  226. t.HorizontalAlign = HorizontalAlign.Center;
  227. s = t.Render ();
  228. Assert.AreEqual ("<table align=\"center\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Center");
  229. t.HorizontalAlign = HorizontalAlign.Right;
  230. s = t.Render ();
  231. Assert.AreEqual ("<table align=\"right\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Right");
  232. t.HorizontalAlign = HorizontalAlign.Justify;
  233. s = t.Render ();
  234. Assert.AreEqual ("<table align=\"justify\" border=\"0\">\n\n</table>", s.ToLower (), "HorizontalAlign.Justify");
  235. t.HorizontalAlign = HorizontalAlign.NotSet;
  236. t.Caption = "mono";
  237. s = t.Render ();
  238. Assert.AreEqual ("<table border=\"0\">\n\t<caption>\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption");
  239. t.CaptionAlign = TableCaptionAlign.Top;
  240. s = t.Render ();
  241. Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"top\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Top");
  242. t.CaptionAlign = TableCaptionAlign.Bottom;
  243. s = t.Render ();
  244. Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"bottom\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Bottom");
  245. t.CaptionAlign = TableCaptionAlign.Right;
  246. s = t.Render ();
  247. Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"right\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Right");
  248. t.CaptionAlign = TableCaptionAlign.Left;
  249. s = t.Render ();
  250. Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"left\">\n\t\tmono\n\t</caption>\n</table>", s.ToLower (), "Caption/Left");
  251. t.Caption = null;
  252. s = t.Render ();
  253. Assert.AreEqual ("<table border=\"0\">\n\n</table>", s, "CaptionAlign without Caption");
  254. t.CaptionAlign = TableCaptionAlign.NotSet;
  255. t.BackImageUrl = imageUrl;
  256. s = t.Render ();
  257. Assert.AreEqual ("<table border=\"0\" style=\"background-image:url(http://www.mono-project.com/stylesheets/images.wiki.png);\">\n\n</table>", s, "BackImageUrl");
  258. t.BackImageUrl = String.Empty;
  259. }
  260. [Test]
  261. public void CreateControlStyle ()
  262. {
  263. TestTable t = new TestTable ();
  264. t.BackImageUrl = imageUrl;
  265. t.CellPadding = 1;
  266. t.CellSpacing = 2;
  267. t.GridLines = GridLines.Horizontal;
  268. t.HorizontalAlign = HorizontalAlign.Left;
  269. TableStyle ts = (TableStyle)t.GetStyle ();
  270. // is it live ?
  271. ts.BackImageUrl = "mono";
  272. Assert.AreEqual ("mono", t.BackImageUrl, "BackImageUrl-2");
  273. ts.CellPadding = Int32.MaxValue;
  274. Assert.AreEqual (Int32.MaxValue, t.CellPadding, "CellPadding-2");
  275. ts.CellSpacing = 0;
  276. Assert.AreEqual (0, t.CellSpacing, "CellSpacing-2");
  277. ts.GridLines = GridLines.Vertical;
  278. Assert.AreEqual (GridLines.Vertical, t.GridLines, "GridLines-2");
  279. ts.HorizontalAlign = HorizontalAlign.Right;
  280. Assert.AreEqual (HorizontalAlign.Right, t.HorizontalAlign, "HorizontalAlign-2");
  281. }
  282. private string Adjust (string s)
  283. {
  284. // right now Mono doesn't generate the exact same indentation/lines as MS implementation
  285. // and different fx versions have different casing for enums
  286. return s.Replace ("\n", "").Replace ("\t", "").ToLower ();
  287. }
  288. [Test]
  289. public void Rows ()
  290. {
  291. TestTable t = new TestTable ();
  292. Assert.AreEqual (0, t.Rows.Count, "0");
  293. TableRow tr = new TableRow ();
  294. t.Rows.Add (tr);
  295. Assert.AreEqual (1, t.Rows.Count, "r1");
  296. Assert.AreEqual (1, t.Controls.Count, "c1");
  297. string s = t.Render ();
  298. Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr>\n\n\t</tr>\n</table>"), Adjust (s), "tr-1");
  299. // change instance properties
  300. tr.HorizontalAlign = HorizontalAlign.Justify;
  301. s = t.Render ();
  302. Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-1j");
  303. // add it again (same instance)
  304. t.Rows.Add (tr);
  305. Assert.AreEqual (1, t.Rows.Count, "t1bis");
  306. Assert.AreEqual (1, t.Controls.Count, "c1bis");
  307. s = t.Render ();
  308. Assert.AreEqual (Adjust ("<table border=\"0\">\n\t<tr align=\"justify\">\n\n\t</tr>\n</table>"), Adjust (s), "tr-1bis");
  309. tr.HorizontalAlign = HorizontalAlign.NotSet;
  310. tr = new TableRow ();
  311. tr.HorizontalAlign = HorizontalAlign.Justify;
  312. t.Rows.Add (tr);
  313. Assert.AreEqual (2, t.Rows.Count, "r2");
  314. Assert.AreEqual (2, t.Controls.Count, "c2");
  315. s = t.Render ();
  316. 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");
  317. tr = new TableRow ();
  318. tr.VerticalAlign = VerticalAlign.Bottom;
  319. t.Controls.Add (tr);
  320. Assert.AreEqual (3, t.Rows.Count, "r3");
  321. Assert.AreEqual (3, t.Controls.Count, "c3");
  322. s = t.Render ();
  323. 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");
  324. t.Caption = "caption";
  325. s = t.Render ();
  326. 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");
  327. }
  328. [Test]
  329. [ExpectedException (typeof (NullReferenceException))]
  330. public void ControlsAdd_Null ()
  331. {
  332. new Table ().Controls.Add (null);
  333. }
  334. [Test]
  335. [ExpectedException (typeof (ArgumentException))]
  336. public void ControlsAdd_LiteralControl ()
  337. {
  338. new Table ().Controls.Add (new LiteralControl ("mono"));
  339. }
  340. [Test]
  341. public void ControlsAdd_TableRow ()
  342. {
  343. Table t = new Table ();
  344. t.Controls.Add (new TableRow ());
  345. Assert.AreEqual (1, t.Controls.Count, "Controls");
  346. Assert.AreEqual (1, t.Rows.Count, "Rows");
  347. }
  348. [Test]
  349. public void ControlsAdd_TestTableRow ()
  350. {
  351. Table t = new Table ();
  352. t.Controls.Add (new TestTableRow ());
  353. Assert.AreEqual (1, t.Controls.Count, "Controls");
  354. Assert.AreEqual (1, t.Rows.Count, "Rows");
  355. }
  356. [Test]
  357. [ExpectedException (typeof (NullReferenceException))]
  358. public void ControlsAddAt_Null ()
  359. {
  360. new Table ().Controls.AddAt (0, null);
  361. }
  362. [Test]
  363. [ExpectedException (typeof (ArgumentOutOfRangeException))]
  364. public void ControlsAddAt_Negative ()
  365. {
  366. new Table ().Controls.AddAt (Int32.MinValue, new TableRow ());
  367. }
  368. [Test]
  369. [ExpectedException (typeof (ArgumentException))]
  370. public void ControlsAddAt_LiteralControl ()
  371. {
  372. new Table ().Controls.AddAt (0, new LiteralControl ("mono"));
  373. }
  374. [Test]
  375. public void ControlsAddAt_TableRow ()
  376. {
  377. Table t = new Table ();
  378. t.Controls.AddAt (0, new TableRow ());
  379. Assert.AreEqual (1, t.Controls.Count, "Controls");
  380. Assert.AreEqual (1, t.Rows.Count, "Rows");
  381. }
  382. [Test]
  383. public void ControlsAddAt_TestTableRow ()
  384. {
  385. Table t = new Table ();
  386. t.Controls.AddAt (0, new TestTableRow ());
  387. Assert.AreEqual (1, t.Controls.Count, "Controls");
  388. Assert.AreEqual (1, t.Rows.Count, "Rows");
  389. }
  390. [Test]
  391. [ExpectedException (typeof (NullReferenceException))]
  392. public void RenderBeginTag_Null ()
  393. {
  394. Table t = new Table ();
  395. t.RenderBeginTag (null);
  396. }
  397. [Test]
  398. public void RenderBeginTag_Empty ()
  399. {
  400. HtmlTextWriter writer = GetWriter ();
  401. Table t = new Table ();
  402. t.RenderBeginTag (writer);
  403. string s = writer.InnerWriter.ToString ();
  404. Assert.AreEqual ("<table border=\"0\">\n", s, "empty");
  405. }
  406. [Test]
  407. public void RenderBeginTag_Attributes ()
  408. {
  409. HtmlTextWriter writer = GetWriter ();
  410. Table t = new Table ();
  411. t.CellPadding = 1;
  412. t.RenderBeginTag (writer);
  413. string s = writer.InnerWriter.ToString ();
  414. Assert.AreEqual ("<table cellpadding=\"1\" border=\"0\">\n", s, "CellPadding");
  415. }
  416. [Test]
  417. public void RenderBeginTag_Caption ()
  418. {
  419. HtmlTextWriter writer = GetWriter ();
  420. Table t = new Table ();
  421. t.Caption = "caption";
  422. t.RenderBeginTag (writer);
  423. string s = writer.InnerWriter.ToString ();
  424. Assert.AreEqual ("<table border=\"0\">\n\t<caption>\n\t\tcaption\n\t</caption>", s, "caption");
  425. }
  426. [Test]
  427. public void RenderBeginTag_Caption_Align ()
  428. {
  429. HtmlTextWriter writer = GetWriter ();
  430. Table t = new Table ();
  431. t.Caption = "caption";
  432. t.CaptionAlign = TableCaptionAlign.Top;
  433. t.RenderBeginTag (writer);
  434. string s = writer.InnerWriter.ToString ();
  435. Assert.AreEqual ("<table border=\"0\">\n\t<caption align=\"top\">\n\t\tcaption\n\t</caption>", s.ToLower (), "caption");
  436. }
  437. [Test]
  438. public void RenderBeginTag_Row ()
  439. {
  440. HtmlTextWriter writer = GetWriter ();
  441. Table t = new Table ();
  442. t.Rows.Add (new TableRow ());
  443. t.RenderBeginTag (writer);
  444. string s = writer.InnerWriter.ToString ();
  445. Assert.AreEqual ("<table border=\"0\">\n", s, "tr");
  446. }
  447. }
  448. }