[LoongArch64] Part-5:add loongarch support in some files for LoongArch64. (#21769)
[mono-project.git] / mcs / class / System.Web / Test / System.Web.UI / HtmlTextWriterCas.cs
blobf8d19d862b05b6409e4b11eeb868d0cb3214c7d7
1 //
2 // HtmlTextWriterCas.cs - CAS unit tests for System.Web.UI.HtmlTextWriter
3 //
4 // Author:
5 // Sebastien Pouliot <sebastien@ximian.com>
6 //
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using NUnit.Framework;
31 using System;
32 using System.IO;
33 using System.Reflection;
34 using System.Security.Permissions;
35 using System.Web;
36 using System.Web.UI;
38 namespace MonoCasTests.System.Web.UI {
40 [TestFixture]
41 [Category ("CAS")]
42 public class HtmlTextWriterCas : AspNetHostingMinimal {
44 private StringWriter sw;
46 [SetUp]
47 public override void SetUp ()
49 base.SetUp ();
50 sw = new StringWriter ();
53 private void Deny_Unrestricted (HtmlTextWriter htw)
55 Assert.IsTrue (htw.Indent >= 0, "Indent");
56 Assert.AreSame (sw, htw.InnerWriter, "InnerWriter");
57 htw.NewLine = Environment.NewLine;
58 Assert.IsNotNull (htw.NewLine, "NewLine");
60 htw.AddAttribute (HtmlTextWriterAttribute.Bgcolor, "blue");
61 htw.AddAttribute (HtmlTextWriterAttribute.Bgcolor, "blue", false);
62 htw.AddAttribute ("align", "left");
63 htw.AddAttribute ("align", "left", false);
65 htw.AddStyleAttribute (HtmlTextWriterStyle.BackgroundColor, "blue");
66 htw.AddStyleAttribute ("left", "1");
68 htw.RenderBeginTag (HtmlTextWriterTag.Table);
69 htw.RenderBeginTag ("<tr>");
70 htw.RenderEndTag ();
72 htw.WriteAttribute ("align", "left");
73 htw.WriteAttribute ("align", "left", false);
74 htw.WriteBeginTag ("table");
75 htw.WriteEndTag ("table");
76 htw.WriteFullBeginTag ("div");
78 htw.WriteStyleAttribute ("left", "2");
79 htw.WriteStyleAttribute ("left", "3", false);
81 htw.Write (new char[1], 0, 1);
82 htw.Write ((double)1.0);
83 htw.Write (Char.MinValue);
84 htw.Write (new char[1]);
85 htw.Write ((int)1);
86 htw.Write ("{0}", 1);
87 htw.Write ("{0}{1}", 1, 2);
88 htw.Write ("{0}{1}{2}", 1, 2, 3);
89 htw.Write (String.Empty);
90 htw.Write ((long)1);
91 htw.Write (this);
92 htw.Write ((float)1.0);
93 htw.Write (false);
95 htw.WriteLine (new char[1], 0, 1);
96 htw.WriteLine ((double)1.0);
97 htw.WriteLine (Char.MinValue);
98 htw.WriteLine (new char[1]);
99 htw.WriteLine ((int)1);
100 htw.WriteLine ("{0}", 1);
101 htw.WriteLine ("{0}{1}", 1, 2);
102 htw.WriteLine ("{0}{1}{2}", 1, 2, 3);
103 htw.WriteLine (String.Empty);
104 htw.WriteLine ((long)1);
105 htw.WriteLine (this);
106 htw.WriteLine ((float)1.0);
107 htw.WriteLine (false);
108 htw.WriteLine ((uint)0);
109 htw.WriteLine ();
110 htw.WriteLineNoTabs (String.Empty);
112 htw.Flush ();
113 htw.Close ();
116 [Test]
117 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
118 public void Ctor1_Deny_Unrestricted ()
120 HtmlTextWriter htw = new HtmlTextWriter (sw);
121 Deny_Unrestricted (htw);
124 [Test]
125 [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
126 public void Ctor2_Deny_Unrestricted ()
128 HtmlTextWriter htw = new HtmlTextWriter (sw, String.Empty);
129 Deny_Unrestricted (htw);
132 // LinkDemand
134 public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
136 ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (TextWriter) });
137 Assert.IsNotNull (ci, ".ctor(TextWriter)");
138 return ci.Invoke (new object[1] { sw });
141 public override Type Type {
142 get { return typeof (HtmlTextWriter); }