Ver Fonte

2005-09-15 Sebastien Pouliot <[email protected]>

	* Html32TextWriterCas.cs: New. CAS unit tests.
	* HtmlTextWriterCas.cs: New. CAS unit tests.
	* ImageClickEventArgsCas.cs: New. CAS unit tests.
	* LiteralControlCas.cs: New. CAS unit tests.
	* LosFormatterCas.cs: New. CAS unit tests.
	* ObjectConverterCas.cs: New. CAS unit tests.
	* ObjectTagBuilderCas.cs: New. CAS unit tests.
	* PageCas.cs: New. CAS unit tests.
	* PairCas.cs: New. CAS unit tests.


svn path=/trunk/mcs/; revision=50089
Sebastien Pouliot há 20 anos atrás
pai
commit
ea15b3dca2

+ 12 - 0
mcs/class/System.Web/Test/System.Web.UI/ChangeLog

@@ -1,3 +1,15 @@
+2005-09-15  Sebastien Pouliot  <[email protected]> 
+
+	* Html32TextWriterCas.cs: New. CAS unit tests.
+	* HtmlTextWriterCas.cs: New. CAS unit tests.
+	* ImageClickEventArgsCas.cs: New. CAS unit tests.
+	* LiteralControlCas.cs: New. CAS unit tests.
+	* LosFormatterCas.cs: New. CAS unit tests.
+	* ObjectConverterCas.cs: New. CAS unit tests.
+	* ObjectTagBuilderCas.cs: New. CAS unit tests.
+	* PageCas.cs: New. CAS unit tests.
+	* PairCas.cs: New. CAS unit tests.
+
 2005-09-14  Sebastien Pouliot  <[email protected]> 
  
 	* DataBinderCas.cs: New. CAS unit tests.

+ 96 - 0
mcs/class/System.Web/Test/System.Web.UI/Html32TextWriterCas.cs

@@ -0,0 +1,96 @@
+//
+// Html32TextWriterCas.cs - CAS unit tests for System.Web.UI.Html32TextWriter
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class Html32TextWriterCas : AspNetHostingMinimal {
+
+		private StringWriter sw;
+
+		[TestFixtureSetUp]
+		public void FixtureSetUp ()
+		{
+			sw = new StringWriter ();
+		}
+
+		private void Deny_Unrestricted (Html32TextWriter htw)
+		{
+#if NET_2_0
+			htw.ShouldPerformDivTableSubstitution = true;
+			Assert.IsTrue (htw.ShouldPerformDivTableSubstitution, "ShouldPerformDivTableSubstitution");
+			htw.SupportsBold = true;
+			Assert.IsTrue (htw.SupportsBold, "SupportsBold");
+			htw.SupportsItalic = true;
+			Assert.IsTrue (htw.SupportsItalic, "SupportsItalic");
+#endif
+			htw.RenderBeginTag (HtmlTextWriterTag.Table);
+			htw.RenderBeginTag ("<tr>");
+			htw.RenderEndTag ();
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor1_Deny_Unrestricted ()
+		{
+			Html32TextWriter htw = new Html32TextWriter (sw);
+			Deny_Unrestricted (htw);
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor2_Deny_Unrestricted ()
+		{
+			Html32TextWriter htw = new Html32TextWriter (sw, String.Empty);
+			Deny_Unrestricted (htw);
+		}
+
+		// LinkDemand
+
+		public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+		{
+			ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (TextWriter) });
+			Assert.IsNotNull (ci, ".ctor(TextWriter)");
+			return ci.Invoke (new object[1] { sw });
+		}
+
+		public override Type Type {
+			get { return typeof (Html32TextWriter); }
+		}
+	}
+}

+ 145 - 0
mcs/class/System.Web/Test/System.Web.UI/HtmlTextWriterCas.cs

@@ -0,0 +1,145 @@
+//
+// HtmlTextWriterCas.cs - CAS unit tests for System.Web.UI.HtmlTextWriter
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class HtmlTextWriterCas : AspNetHostingMinimal {
+
+		private StringWriter sw;
+
+		[SetUp]
+		public override void SetUp ()
+		{
+			base.SetUp ();
+			sw = new StringWriter ();
+		}
+
+		private void Deny_Unrestricted (HtmlTextWriter htw)
+		{
+			Assert.IsTrue (htw.Indent >= 0, "Indent");
+			Assert.AreSame (sw, htw.InnerWriter, "InnerWriter");
+			htw.NewLine = Environment.NewLine;
+			Assert.IsNotNull (htw.NewLine, "NewLine");
+
+			htw.AddAttribute (HtmlTextWriterAttribute.Bgcolor, "blue");
+			htw.AddAttribute (HtmlTextWriterAttribute.Bgcolor, "blue", false);
+			htw.AddAttribute ("align", "left");
+			htw.AddAttribute ("align", "left", false);
+
+			htw.AddStyleAttribute (HtmlTextWriterStyle.BackgroundColor, "blue");
+			htw.AddStyleAttribute ("left", "1");
+
+			htw.RenderBeginTag (HtmlTextWriterTag.Table);
+			htw.RenderBeginTag ("<tr>");
+			htw.RenderEndTag ();
+
+			htw.WriteAttribute ("align", "left");
+			htw.WriteAttribute ("align", "left", false);
+			htw.WriteBeginTag ("table");
+			htw.WriteEndTag ("table");
+			htw.WriteFullBeginTag ("div");
+
+			htw.WriteStyleAttribute ("left", "2");
+			htw.WriteStyleAttribute ("left", "3", false);
+
+			htw.Write (new char[1], 0, 1);
+			htw.Write ((double)1.0);
+			htw.Write (Char.MinValue);
+			htw.Write (new char[1]);
+			htw.Write ((int)1);
+			htw.Write ("{0}", 1);
+			htw.Write ("{0}{1}", 1, 2);
+			htw.Write ("{0}{1}{2}", 1, 2, 3);
+			htw.Write (String.Empty);
+			htw.Write ((long)1);
+			htw.Write (this);
+			htw.Write ((float)1.0);
+			htw.Write (false);
+
+			htw.WriteLine (new char[1], 0, 1);
+			htw.WriteLine ((double)1.0);
+			htw.WriteLine (Char.MinValue);
+			htw.WriteLine (new char[1]);
+			htw.WriteLine ((int)1);
+			htw.WriteLine ("{0}", 1);
+			htw.WriteLine ("{0}{1}", 1, 2);
+			htw.WriteLine ("{0}{1}{2}", 1, 2, 3);
+			htw.WriteLine (String.Empty);
+			htw.WriteLine ((long)1);
+			htw.WriteLine (this);
+			htw.WriteLine ((float)1.0);
+			htw.WriteLine (false);
+			htw.WriteLine ((uint)0);
+			htw.WriteLine ();
+			htw.WriteLineNoTabs (String.Empty);
+
+			htw.Flush ();
+			htw.Close ();
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor1_Deny_Unrestricted ()
+		{
+			HtmlTextWriter htw = new HtmlTextWriter (sw);
+			Deny_Unrestricted (htw);
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor2_Deny_Unrestricted ()
+		{
+			HtmlTextWriter htw = new HtmlTextWriter (sw, String.Empty);
+			Deny_Unrestricted (htw);
+		}
+
+		// LinkDemand
+
+		public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+		{
+			ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (TextWriter) });
+			Assert.IsNotNull (ci, ".ctor(TextWriter)");
+			return ci.Invoke (new object[1] { sw });
+		}
+
+		public override Type Type {
+			get { return typeof (HtmlTextWriter); }
+		}
+	}
+}

+ 66 - 0
mcs/class/System.Web/Test/System.Web.UI/ImageClickEventArgsCas.cs

@@ -0,0 +1,66 @@
+//
+// ImageClickEventArgsCas.cs 
+//	- CAS unit tests for System.Web.UI.ImageClickEventArgs
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Reflection;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class ImageClickEventArgsCas : AspNetHostingMinimal {
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Deny_Unrestricted ()
+		{
+			ImageClickEventArgs icea = new ImageClickEventArgs (0, 0);
+			Assert.AreEqual (0, icea.X, "X");
+			Assert.AreEqual (0, icea.Y, "Y");
+		}
+
+		// LinkDemand
+
+		public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+		{
+			ConstructorInfo ci = this.Type.GetConstructor (new Type[2] { typeof (int), typeof (int) });
+			Assert.IsNotNull (ci, ".ctor(int,int)");
+			return ci.Invoke (new object[2] { 0, 0 });
+		}
+
+		public override Type Type {
+			get { return typeof (ImageClickEventArgs); }
+		}
+	}
+}

+ 67 - 0
mcs/class/System.Web/Test/System.Web.UI/LiteralControlCas.cs

@@ -0,0 +1,67 @@
+//
+// LiteralControlCas.cs 
+//	- CAS unit tests for System.Web.UI.LiteralControlCas
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class LiteralControlCas : AspNetHostingMinimal {
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor0_Deny_Unrestricted ()
+		{
+			LiteralControl lc = new LiteralControl ();
+			Assert.IsNull (lc.Text, "Text");
+			lc.Text = "mono";
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor1_Deny_Unrestricted ()
+		{
+			LiteralControl lc = new LiteralControl ("mono");
+			Assert.AreEqual ("mono", lc.Text, "Text");
+			lc.Text = String.Empty;
+		}
+
+		// LinkDemand
+
+		public override Type Type {
+			get { return typeof (LiteralControl); }
+		}
+	}
+}

+ 85 - 0
mcs/class/System.Web/Test/System.Web.UI/LosFormatterCas.cs

@@ -0,0 +1,85 @@
+//
+// LosFormatterCas.cs - CAS unit tests for System.Web.UI.LosFormatter
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class LosFormatterCas : AspNetHostingMinimal {
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor0_Deny_Unrestricted ()
+		{
+			LosFormatter lf = new LosFormatter ();
+
+			MemoryStream ms = new MemoryStream ();
+			lf.Serialize (ms, "mono");
+			ms.Position = 0;
+			Assert.IsNotNull (lf.Deserialize (ms), "Deserialize(Stream)");
+
+			StringWriter sw = new StringWriter ();
+			lf.Serialize (sw, "mono");
+			string s = sw.ToString ();
+			StringReader sr = new StringReader (s);
+			Assert.IsNotNull (lf.Deserialize (sr), "Deserialize(TextReader)");
+
+			Assert.IsNotNull (lf.Deserialize (s), "Deserialize(string)");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void CtorBoolString_Deny_Unrestricted ()
+		{
+			LosFormatter lf = new LosFormatter (true, String.Empty);
+		}
+
+#if NET_2_0
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void CtorBoolByteArray_Deny_Unrestricted ()
+		{
+			LosFormatter lf = new LosFormatter (true, (byte[])null);
+		}
+#endif
+
+		// LinkDemand
+
+		public override Type Type {
+			get { return typeof (LosFormatter); }
+		}
+	}
+}

+ 67 - 0
mcs/class/System.Web/Test/System.Web.UI/ObjectConverterCas.cs

@@ -0,0 +1,67 @@
+//
+// ObjectConverterCas.cs - CAS unit tests for System.Web.UI.ObjectConverter
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class ObjectConverterCas : AspNetHostingMinimal {
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Constructor ()
+		{
+			new ObjectConverter ();
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void ConvertValue_Deny_Unrestricted ()
+		{
+			try {
+				ObjectConverter.ConvertValue (String.Empty, typeof (String), String.Empty);
+			}
+			catch (NotImplementedException) {
+			}
+		}
+
+		// LinkDemand
+
+		public override Type Type {
+			get { return typeof (ObjectConverter); }
+		}
+	}
+}

+ 64 - 0
mcs/class/System.Web/Test/System.Web.UI/ObjectTagBuilderCas.cs

@@ -0,0 +1,64 @@
+//
+// ObjectTagBuilderCas.cs - CAS unit tests for System.Web.UI.ObjectTagBuilder
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class ObjectTagBuilderCas : AspNetHostingMinimal {
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Deny_Unrestricted ()
+		{
+			ObjectTagBuilder otb = new ObjectTagBuilder ();
+			otb.AppendLiteralString (String.Empty);
+			otb.AppendSubBuilder (new ControlBuilder ());
+			try {
+				otb.Init (null, null, null, null, null, null);
+			}
+			catch (HttpException) {
+				// missing id
+			}
+		}
+
+		// LinkDemand
+
+		public override Type Type {
+			get { return typeof (ObjectTagBuilder); }
+		}
+	}
+}

+ 352 - 0
mcs/class/System.Web/Test/System.Web.UI/PageCas.cs

@@ -0,0 +1,352 @@
+//
+// PageCas.cs - CAS unit tests for System.Web.UI.Page
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Security;
+using System.Security.Permissions;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.HtmlControls;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class PageCas : AspNetHostingMinimal {
+
+		private Control control;
+		private Page page;
+
+		[TestFixtureSetUp]
+		public void FixtureSetUp ()
+		{
+			control = new Control ();
+			control.ID = "mono";
+			page = new Page ();
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Properties_Deny_Unrestricted ()
+		{
+			Page p = new Page ();
+			Assert.IsNull (p.Application, "Application");
+			p.ClientTarget = "mono";
+			Assert.AreEqual ("mono", p.ClientTarget, "ClientTarget");
+			p.EnableViewState = true;
+			Assert.IsTrue (p.EnableViewState, "EnableViewState");
+			p.ErrorPage = "error.html";
+			Assert.AreEqual ("error.html", p.ErrorPage, "ErrorPage");
+			p.ID = "mono";
+			Assert.AreEqual ("mono", p.ID, "ID");
+			Assert.IsFalse (p.IsPostBack, "IsPostBack");
+			Assert.IsFalse (p.IsReusable, "IsReusable");
+			p.SmartNavigation = false;
+			Assert.IsFalse (p.SmartNavigation, "SmartNavigation");
+			Assert.IsNotNull (p.Validators, "Validators");
+			p.ViewStateUserKey = "mono";
+			Assert.AreEqual ("mono", p.ViewStateUserKey, "ViewStateUserKey");
+			p.Visible = true;
+			Assert.IsTrue (p.Visible, "Visible");
+#if NET_2_0
+			Assert.IsNotNull (p.ClientScript, "ClientScript");
+//			p.CodePage = 0;
+//			Assert.AreEqual (0, p.CodePage, "CodePage");
+//			p.ContentType = "mono";
+//			Assert.AreEqual ("mono", p.ContentType, "ContentType");
+			Assert.IsNotNull (p.Culture, "Culture");
+			Assert.IsNull (p.Form, "Form");
+			Assert.IsNull (p.Header, "Header");
+			Assert.IsFalse (p.IsCallback, "IsCallback");
+			Assert.IsFalse (p.IsCrossPagePostBack, "IsCrossPagePostBack");
+			Assert.IsTrue (p.LCID != 0, "LCID");
+			p.MasterPageFile = String.Empty;
+			Assert.AreEqual (String.Empty, p.MasterPageFile, "MasterPageFile");
+			Assert.IsNull (p.Master, "Master");
+			Assert.IsNull (p.PageAdapter, "PageAdapter");
+			Assert.IsNull (p.PreviousPage, "PreviousPage");
+//			p.ResponseEncoding = Encoding.UTF8.WebName;
+//			Assert.AreEqual (Encoding.UTF8.WebName, p.ResponseEncoding, "ResponseEncoding");
+			p.UICulture = "en-us";
+			Assert.IsNotNull (p.UICulture, "UICulture");
+#endif
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void Cache_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().Cache, "Cache");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void IsValid_Deny_Unrestricted ()
+		{
+			Assert.IsFalse (new Page ().IsValid, "IsValid");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void Request_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().Request, "Request");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void Response_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().Response, "Response");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void Server_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().Server, "Server");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void Session_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().Session, "Session");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void Trace_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().Trace, "Trace");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void User_Deny_Unrestricted ()
+		{
+			Assert.IsNotNull (new Page ().User, "User");
+		}
+#if NET_2_0
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void Buffer_set_Deny_Unrestricted ()
+		{
+			page.Buffer = true;
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (HttpException))]
+		public void Buffer_get_Deny_Unrestricted ()
+		{
+			Assert.IsTrue (page.Buffer, "Buffer");
+		}
+
+		[Test]
+		[SecurityPermission (SecurityAction.Deny, ControlThread = true)]
+		[ExpectedException (typeof (SecurityException))]
+		public void Culture_Deny_ControlThread ()
+		{
+			page.Culture = "fr-ca";
+		}
+
+		[Test]
+		[SecurityPermission (SecurityAction.PermitOnly, ControlThread = true)]
+		public void Culture_PermitOnly_ControlThread ()
+		{
+			page.Culture = "fr-ca";
+		}
+
+		[Test]
+		[SecurityPermission (SecurityAction.Deny, ControlThread = true)]
+		[ExpectedException (typeof (SecurityException))]
+		public void LCID_Deny_ControlThread ()
+		{
+			page.LCID = 0x409;
+		}
+
+		[Test]
+		[SecurityPermission (SecurityAction.PermitOnly, ControlThread = true)]
+		public void LCID_PermitOnly_ControlThread ()
+		{
+			page.LCID = 0x409;
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void TraceEnabled_set_Deny_Unrestricted ()
+		{
+			page.TraceEnabled = false;
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void TraceEnabled_get_Deny_Unrestricted ()
+		{
+			Assert.IsFalse (page.TraceEnabled, "TraceEnabled");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void TraceModeValue_set_Deny_Unrestricted ()
+		{
+			page.TraceModeValue = TraceMode.Default;
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+		public void TraceModeValue_get_Deny_Unrestricted ()
+		{
+			Assert.AreEqual (TraceMode.Default, page.TraceModeValue, "TraceModeValue");
+		}
+#endif
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Methods_Deny_Unrestricted ()
+		{
+			Page p = new Page ();
+			p.DesignerInitialize ();
+			Assert.IsNotNull (p.GetPostBackClientEvent (control, "mono"), "GetPostBackClientEvent");
+			Assert.IsNotNull (p.GetPostBackClientHyperlink (control, "mono"), "GetPostBackClientHyperlink");
+			Assert.IsNotNull (p.GetPostBackEventReference (control), "GetPostBackEventReference(control)");
+			Assert.IsNotNull (p.GetPostBackEventReference (control, "mono"), "GetPostBackEventReference(control,string)");
+			Assert.AreEqual (0, p.GetTypeHashCode (), "GetTypeHashCode");
+			Assert.IsFalse (p.IsClientScriptBlockRegistered ("mono"), "IsClientScriptBlockRegistered");
+			Assert.IsFalse (p.IsStartupScriptRegistered ("mono"), "IsStartupScriptRegistered");
+			p.RegisterArrayDeclaration ("arrayname", "value");
+			p.RegisterClientScriptBlock ("key", "script");
+			p.RegisterHiddenField ("name", "hidden");
+			p.RegisterOnSubmitStatement ("key", "script");
+			p.RegisterRequiresPostBack (new HtmlTextArea ());
+			p.RegisterRequiresRaiseEvent (new HtmlAnchor ());
+			p.RegisterStartupScript ("key", "script");
+			p.Validate ();
+			p.VerifyRenderingInServerForm (control);
+#if NET_2_0
+			p.Controls.Add (control);
+			Assert.IsNotNull (p.FindControl ("mono"), "FindControl");
+			p.RegisterRequiresControlState (control);
+			Assert.IsTrue (p.RequiresControlState (control), "RequiresControlState");
+			p.UnregisterRequiresControlState (control);
+			Assert.IsNotNull (p.GetValidators (String.Empty), "GetValidators");
+			p.Validate (String.Empty);
+#endif
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void MapPath_Deny_Unrestricted ()
+		{
+			try {
+				new Page ().MapPath ("/");
+			}
+			catch (NullReferenceException) {
+				// ms 1.x + 2.0
+			}
+			catch (HttpException) {
+				// mono
+			}
+		}
+
+		[Test]
+		[FileIOPermission (SecurityAction.Deny, Unrestricted = true)]
+#if NET_2_0
+		[ExpectedException (typeof (SecurityException))]
+#else
+		[ExpectedException (typeof (NullReferenceException))]
+#endif
+		public void ProcessRequest_Deny_Unrestricted ()
+		{
+			new Page ().ProcessRequest (new HttpContext (null));
+		}
+
+		[Test]
+		[FileIOPermission (SecurityAction.PermitOnly, Unrestricted = true)]
+#if NET_2_0
+		[ExpectedException (typeof (HttpException))]
+#else
+		// indirect for HttpApplicationState | HttpStaticObjectsCollection
+		[SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+		[ExpectedException (typeof (NullReferenceException))]
+#endif
+		public void ProcessRequest_PermitOnly_FileIOPermission ()
+		{
+			new Page ().ProcessRequest (new HttpContext (null));
+		}
+
+#if NET_2_0
+		private void Handler (object sender, EventArgs e)
+		{
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Events_Deny_Unrestricted ()
+		{
+			Page p = new Page ();
+			p.InitComplete += new EventHandler (Handler);
+			p.LoadComplete += new EventHandler (Handler);
+			p.PreInit += new EventHandler (Handler);
+			p.PreLoad += new EventHandler (Handler);
+			p.PreRenderComplete += new EventHandler (Handler);
+			p.SaveStateComplete += new EventHandler (Handler);
+
+			p.InitComplete -= new EventHandler (Handler);
+			p.LoadComplete -= new EventHandler (Handler);
+			p.PreInit -= new EventHandler (Handler);
+			p.PreLoad -= new EventHandler (Handler);
+			p.PreRenderComplete -= new EventHandler (Handler);
+			p.SaveStateComplete -= new EventHandler (Handler);
+		}
+#endif
+
+		// LinkDemand
+
+		public override Type Type {
+			get { return typeof (Page); }
+		}
+	}
+}

+ 67 - 0
mcs/class/System.Web/Test/System.Web.UI/PairCas.cs

@@ -0,0 +1,67 @@
+//
+// PairCas.cs - CAS unit tests for System.Web.UI.Pair
+//
+// Author:
+//	Sebastien Pouliot  <[email protected]>
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using NUnit.Framework;
+
+using System;
+using System.IO;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+	[TestFixture]
+	[Category ("CAS")]
+	public class PairCas : AspNetHostingMinimal {
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor0_Deny_Unrestricted ()
+		{
+			Pair p = new Pair ();
+			Assert.IsNull (p.First, "First");
+			Assert.IsNull (p.Second, "Second");
+		}
+
+		[Test]
+		[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+		public void Ctor2_Deny_Unrestricted ()
+		{
+			Pair p = new Pair (String.Empty, String.Empty);
+			Assert.IsNotNull (p.First, "First");
+			Assert.IsNotNull (p.Second, "Second");
+		}
+
+		// LinkDemand
+
+		public override Type Type {
+			get { return typeof (Pair); }
+		}
+	}
+}