2 // HtmlTableCellTest.cs
3 // - Unit tests for System.Web.UI.HtmlControls.HtmlTableCell
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.
33 using System.Web.UI.HtmlControls;
35 using NUnit.Framework;
37 namespace MonoTests.System.Web.UI.HtmlControls {
39 public class TestHtmlTableCell : HtmlTableCell {
41 public string Render ()
43 HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
45 return writer.InnerWriter.ToString ();
50 public class HtmlTableCellTest {
53 public void DefaultProperties ()
55 HtmlTableCell c = new HtmlTableCell ();
56 Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");
58 Assert.AreEqual (String.Empty, c.Align, "Align");
59 Assert.AreEqual (String.Empty, c.BgColor, "BgColor");
60 Assert.AreEqual (String.Empty, c.BorderColor, "BorderColor");
61 Assert.AreEqual (-1, c.ColSpan, "ColSpan");
62 Assert.AreEqual (String.Empty, c.Height, "Height");
63 Assert.IsFalse (c.NoWrap, "NoWrap");
64 Assert.AreEqual (-1, c.RowSpan, "RowSpan");
65 Assert.AreEqual (String.Empty, c.VAlign, "VAlign");
66 Assert.AreEqual (String.Empty, c.Width, "Width");
68 Assert.AreEqual ("td", c.TagName, "TagName");
72 public void NullProperties ()
74 HtmlTableCell c = new HtmlTableCell ();
76 Assert.AreEqual (String.Empty, c.Align, "Align");
78 Assert.AreEqual (String.Empty, c.BgColor, "BgColor");
80 Assert.AreEqual (String.Empty, c.BorderColor, "BorderColor");
82 Assert.AreEqual (String.Empty, c.Height, "Height");
84 Assert.AreEqual (String.Empty, c.VAlign, "VAlign");
86 Assert.AreEqual (String.Empty, c.Width, "Width");
88 Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");
92 public void EmptyProperties ()
94 HtmlTableCell c = new HtmlTableCell ();
96 Assert.AreEqual (-1, c.ColSpan, "ColSpan");
98 Assert.AreEqual (-1, c.RowSpan, "RowSpan");
100 Assert.IsFalse (c.NoWrap, "NoWrap");
102 Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");
106 public void CleanProperties ()
108 HtmlTableCell c = new HtmlTableCell ();
110 Assert.AreEqual ("center", c.Align, "Align");
112 Assert.AreEqual (1, c.ColSpan, "Align");
114 Assert.IsTrue (c.NoWrap, "NoWrap");
115 Assert.AreEqual (3, c.Attributes.Count, "3");
118 Assert.AreEqual (String.Empty, c.Align, "-Align");
120 Assert.AreEqual (-1, c.ColSpan, "-ColSpan");
122 Assert.IsFalse (c.NoWrap, "-NoWrap");
123 Assert.AreEqual (0, c.Attributes.Count, "Attributes.Count");
126 private string AdjustLineEndings (string s)
128 return s.Replace ("\r\n", Environment.NewLine);
132 public void Render ()
134 TestHtmlTableCell c = new TestHtmlTableCell ();
137 c.BorderColor = "*3*";
141 Assert.AreEqual (AdjustLineEndings ("<td align=\"*1*\" bgcolor=\"*2*\" bordercolor=\"*3*\" colspan=\"4\" width=\"*5*\"></td>\r\n"), c.Render ());