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;
36 using MonoTests.SystemWeb.Framework;
37 using MonoTests.stand_alone.WebHarness;
39 namespace MonoTests.System.Web.UI.HtmlControls {
41 public class TestHtmlImage : HtmlImage {
43 public HtmlTextWriter GetWriter ()
45 StringWriter text = new StringWriter ();
46 HtmlTextWriter writer = new HtmlTextWriter (text);
47 base.RenderAttributes (writer);
53 public class HtmlImageTest {
56 public void DefaultProperties ()
58 HtmlImage img = new HtmlImage ();
59 Assert.AreEqual (0, img.Attributes.Count, "Attributes.Count");
61 Assert.AreEqual (String.Empty, img.Align, "Align");
62 Assert.AreEqual (String.Empty, img.Alt, "Alt");
63 Assert.AreEqual (-1, img.Border, "Border");
64 Assert.AreEqual (-1, img.Height, "Height");
65 Assert.AreEqual (String.Empty, img.Src, "Src");
66 Assert.AreEqual (-1, img.Width, "Width");
68 Assert.AreEqual ("img", img.TagName, "TagName");
72 public void NullProperties ()
74 HtmlImage img = new HtmlImage ();
77 Assert.AreEqual (String.Empty, img.Align, "Align");
79 Assert.AreEqual (String.Empty, img.Alt, "Alt");
81 Assert.AreEqual (-1, img.Border, "Border");
83 Assert.AreEqual (-1, img.Height, "Height");
85 Assert.AreEqual (String.Empty, img.Src, "Src");
87 Assert.AreEqual (-1, img.Width, "Width");
89 Assert.AreEqual (0, img.Attributes.Count, "Attributes.Count");
93 public void Negative ()
95 HtmlImage img = new HtmlImage ();
101 Assert.AreEqual (3, img.Attributes.Count, "First Attributes Count");
107 Assert.AreEqual (-10, img.Border, "Border");
108 Assert.AreEqual (-20, img.Height, "Height");
109 Assert.AreEqual (-30, img.Width, "Width");
111 Assert.AreEqual (3, img.Attributes.Count, "Second Attributes Count");
115 public void EmptySrc ()
117 TestHtmlImage img = new TestHtmlImage ();
119 img.Src = String.Empty;
121 HtmlTextWriter writer = img.GetWriter ();
122 Assert.AreEqual (" /", writer.InnerWriter.ToString ());
126 [Category ("NunitWeb")]
127 public void RenderAttributes ()
129 new WebTest (PageInvoker.CreateOnLoad (new PageDelegate (DoRenderAttributes))).Run ();
132 public static void DoRenderAttributes (Page p)
134 TestHtmlImage img = new TestHtmlImage ();
143 Assert.AreEqual (6, img.Attributes.Count, "Attributes.Count");
145 HtmlTextWriter writer = img.GetWriter ();
146 Assert.AreEqual (" src=\"*5<&*\" align=\"*1*\" alt=\"*2*\" border=\"3\" height=\"4\" width=\"6\" /", writer.InnerWriter.ToString ());