3 // - Unit tests for System.Web.UI.HtmlControls.HtmlImage
6 // Dick Porter <dick@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 TestHtmlImage : HtmlImage {
41 public HtmlTextWriter GetWriter ()
43 StringWriter text = new StringWriter ();
44 HtmlTextWriter writer = new HtmlTextWriter (text);
45 base.RenderAttributes (writer);
51 public class HtmlImageTest {
54 public void DefaultProperties ()
56 HtmlImage img = new HtmlImage ();
57 Assert.AreEqual (0, img.Attributes.Count, "Attributes.Count");
59 Assert.AreEqual (String.Empty, img.Align, "Align");
60 Assert.AreEqual (String.Empty, img.Alt, "Alt");
61 Assert.AreEqual (-1, img.Border, "Border");
62 Assert.AreEqual (-1, img.Height, "Height");
63 Assert.AreEqual (String.Empty, img.Src, "Src");
64 Assert.AreEqual (-1, img.Width, "Width");
66 Assert.AreEqual ("img", img.TagName, "TagName");
70 public void NullProperties ()
72 HtmlImage img = new HtmlImage ();
75 Assert.AreEqual (String.Empty, img.Align, "Align");
77 Assert.AreEqual (String.Empty, img.Alt, "Alt");
79 Assert.AreEqual (-1, img.Border, "Border");
81 Assert.AreEqual (-1, img.Height, "Height");
83 Assert.AreEqual (String.Empty, img.Src, "Src");
85 Assert.AreEqual (-1, img.Width, "Width");
87 Assert.AreEqual (0, img.Attributes.Count, "Attributes.Count");
91 public void Negative ()
93 HtmlImage img = new HtmlImage ();
99 Assert.AreEqual (3, img.Attributes.Count, "First Attributes Count");
105 Assert.AreEqual (-10, img.Border, "Border");
106 Assert.AreEqual (-20, img.Height, "Height");
107 Assert.AreEqual (-30, img.Width, "Width");
109 Assert.AreEqual (3, img.Attributes.Count, "Second Attributes Count");
113 public void RenderAttributes ()
115 TestHtmlImage img = new TestHtmlImage ();
124 Assert.AreEqual (6, img.Attributes.Count, "Attributes.Count");
126 HtmlTextWriter writer = img.GetWriter ();
127 Assert.AreEqual (" src=\"*5*\" align=\"*1*\" alt=\"*2*\" border=\"3\" height=\"4\" width=\"6\" /", writer.InnerWriter.ToString ());