2005-09-15 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 15 Sep 2005 20:53:23 +0000 (20:53 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 15 Sep 2005 20:53:23 +0000 (20:53 -0000)
* ParseChildrenAttributeCas.cs: New. CAS unit tests.
* PartialCachingAttributeCas.cs: New. CAS unit tests.
* PersistChildrenAttributeCas.cs: New. CAS unit tests.
* PersistenceModeAttributeCas.cs: New. CAS unit tests.
* PropertyConverterCas.cs: New. CAS unit tests.
* RootBuilderCas.cs: New. CAS unit tests.
* StateBagCas.cs: New. CAS unit tests.
* StateItemCas.cs: New. CAS unit tests.
* StaticPartialCachingControlCas.cs: New. CAS unit tests.

svn path=/trunk/mcs/; revision=50104

mcs/class/System.Web/Test/System.Web.UI/ChangeLog
mcs/class/System.Web/Test/System.Web.UI/ParseChildrenAttributeCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/PartialCachingAttributeCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/PersistChildrenAttributeCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/PersistenceModeAttributeCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/PropertyConverterCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/RootBuilderCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/StateBagCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/StateItemCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.UI/StaticPartialCachingControlCas.cs [new file with mode: 0644]

index e5011669906cd74148c3ec430aa401e7e146959e..cefc329864b28c4cbf9e4df83831cdff4929ecbc 100644 (file)
@@ -1,3 +1,15 @@
+2005-09-15  Sebastien Pouliot  <sebastien@ximian.com>
+       * ParseChildrenAttributeCas.cs: New. CAS unit tests.
+       * PartialCachingAttributeCas.cs: New. CAS unit tests.
+       * PersistChildrenAttributeCas.cs: New. CAS unit tests.
+       * PersistenceModeAttributeCas.cs: New. CAS unit tests.
+       * PropertyConverterCas.cs: New. CAS unit tests.
+       * RootBuilderCas.cs: New. CAS unit tests.
+       * StateBagCas.cs: New. CAS unit tests.
+       * StateItemCas.cs: New. CAS unit tests.
+       * StaticPartialCachingControlCas.cs: New. CAS unit tests.
+
 2005-09-15  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * Html32TextWriterCas.cs: New. CAS unit tests.
diff --git a/mcs/class/System.Web/Test/System.Web.UI/ParseChildrenAttributeCas.cs b/mcs/class/System.Web/Test/System.Web.UI/ParseChildrenAttributeCas.cs
new file mode 100644 (file)
index 0000000..f4797d1
--- /dev/null
@@ -0,0 +1,123 @@
+//
+// ParseChildrenAttributeCas.cs 
+//     - CAS unit tests for System.Web.UI.ParseChildrenAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 ParseChildrenAttributeCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor_Deny_Unrestricted ()
+               {
+                       ParseChildrenAttribute pca = new ParseChildrenAttribute ();
+                       Assert.IsFalse (pca.ChildrenAsProperties, "ChildrenAsProperties");
+                       Assert.AreEqual (String.Empty, pca.DefaultProperty, "DefaultProperty");
+                       Assert.IsTrue (pca.Equals (pca), "Equals");
+                       Assert.IsTrue (pca.IsDefaultAttribute (), "IsDefaultAttribute");
+                       // this throws a NullReferenceException on MS 2.0 beta2
+                       // Assert.IsTrue (pca.GetHashCode () != 0, "GetHashCode"); // likely
+#if NET_2_0
+                       Assert.AreEqual (typeof (Control), pca.ChildControlType, "ChildControlType");
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void CtorBool_Deny_Unrestricted ()
+               {
+                       ParseChildrenAttribute pca = new ParseChildrenAttribute (true);
+                       Assert.IsTrue (pca.ChildrenAsProperties, "ChildrenAsProperties");
+                       Assert.AreEqual (String.Empty, pca.DefaultProperty, "DefaultProperty");
+                       Assert.IsTrue (pca.Equals (pca), "Equals");
+                       Assert.IsFalse (pca.IsDefaultAttribute (), "IsDefaultAttribute");
+                       Assert.IsTrue (pca.GetHashCode () != 0, "GetHashCode"); // likely
+#if NET_2_0
+                       Assert.AreEqual (typeof (Control), pca.ChildControlType, "ChildControlType");
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void CtorBoolString_Deny_Unrestricted ()
+               {
+                       ParseChildrenAttribute pca = new ParseChildrenAttribute (true, "mono");
+                       Assert.IsTrue (pca.ChildrenAsProperties, "ChildrenAsProperties");
+                       Assert.AreEqual ("mono", pca.DefaultProperty, "DefaultProperty");
+                       Assert.IsTrue (pca.Equals (pca), "Equals");
+                       Assert.IsFalse (pca.IsDefaultAttribute (), "IsDefaultAttribute");
+                       Assert.IsTrue (pca.GetHashCode () != 0, "GetHashCode"); // likely
+#if NET_2_0
+                       Assert.AreEqual (typeof (Control), pca.ChildControlType, "ChildControlType");
+#endif
+               }
+
+#if NET_2_0
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void CtorType_Deny_Unrestricted ()
+               {
+                       ParseChildrenAttribute pca = new ParseChildrenAttribute (typeof (string));
+                       Assert.IsFalse (pca.ChildrenAsProperties, "ChildrenAsProperties");
+                       Assert.AreEqual (String.Empty, pca.DefaultProperty, "DefaultProperty");
+                       Assert.IsTrue (pca.Equals (pca), "Equals");
+                       Assert.IsFalse (pca.IsDefaultAttribute (), "IsDefaultAttribute");
+                       Assert.IsTrue (pca.GetHashCode () != 0, "GetHashCode"); // likely
+                       Assert.AreEqual (typeof (string), pca.ChildControlType, "ChildControlType");
+               }
+#endif
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Static_Deny_Unrestricted ()
+               {
+                       Assert.IsNotNull (ParseChildrenAttribute.Default, "Default");
+#if NET_2_0
+                       Assert.IsNotNull (ParseChildrenAttribute.ParseAsChildren, "ParseAsChildren");
+                       Assert.IsNotNull (ParseChildrenAttribute.ParseAsProperties, "ParseAsProperties");
+#endif
+               }
+
+               // LinkDemand
+
+               public override Type Type {
+                       get { return typeof (ParseChildrenAttribute); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/PartialCachingAttributeCas.cs b/mcs/class/System.Web/Test/System.Web.UI/PartialCachingAttributeCas.cs
new file mode 100644 (file)
index 0000000..214e440
--- /dev/null
@@ -0,0 +1,118 @@
+//
+// PartialCachingAttributeCas.cs 
+//     - CAS unit tests for System.Web.UI.PartialCachingAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 PartialCachingAttributeCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor1_Deny_Unrestricted ()
+               {
+                       PartialCachingAttribute pca = new PartialCachingAttribute (Int32.MinValue);
+                       Assert.AreEqual (Int32.MinValue, pca.Duration, "Duration");
+                       Assert.IsNull (pca.VaryByControls, "VaryByControls");
+                       Assert.IsNull (pca.VaryByCustom, "VaryByCustom");
+                       Assert.IsNull (pca.VaryByParams, "VaryByParams");
+#if NET_2_0
+                       Assert.IsNull (pca.SqlDependency, "SqlDependency");
+#endif
+                       Assert.IsFalse (pca.Shared, "Shared");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor4_Deny_Unrestricted ()
+               {
+                       PartialCachingAttribute pca = new PartialCachingAttribute (Int32.MaxValue, "1", "2", "3");
+                       Assert.AreEqual (Int32.MaxValue, pca.Duration, "Duration");
+                       Assert.AreEqual ("2", pca.VaryByControls, "VaryByControls");
+                       Assert.AreEqual ("3", pca.VaryByCustom, "VaryByCustom");
+                       Assert.AreEqual ("1", pca.VaryByParams, "VaryByParams");
+#if NET_2_0
+                       Assert.IsNull (pca.SqlDependency, "SqlDependency");
+#endif
+                       Assert.IsFalse (pca.Shared, "Shared");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor5_Deny_Unrestricted ()
+               {
+                       PartialCachingAttribute pca = new PartialCachingAttribute (0, "a", "b", "c", true);
+                       Assert.AreEqual (0, pca.Duration, "Duration");
+                       Assert.AreEqual ("b", pca.VaryByControls, "VaryByControls");
+                       Assert.AreEqual ("c", pca.VaryByCustom, "VaryByCustom");
+                       Assert.AreEqual ("a", pca.VaryByParams, "VaryByParams");
+#if NET_2_0
+                       Assert.IsNull (pca.SqlDependency, "SqlDependency");
+#endif
+                       Assert.IsTrue (pca.Shared, "Shared");
+               }
+
+#if NET_2_0
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor6_Deny_Unrestricted ()
+               {
+                       PartialCachingAttribute pca = new PartialCachingAttribute (0, "a", "b", "c", "sql", false);
+                       Assert.AreEqual (0, pca.Duration, "Duration");
+                       Assert.AreEqual ("b", pca.VaryByControls, "VaryByControls");
+                       Assert.AreEqual ("c", pca.VaryByCustom, "VaryByCustom");
+                       Assert.AreEqual ("a", pca.VaryByParams, "VaryByParams");
+                       Assert.AreEqual ("sql", pca.SqlDependency, "SqlDependency");
+                       Assert.IsFalse (pca.Shared, "Shared");
+               }
+#endif
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (int) });
+                       Assert.IsNotNull (ci, ".ctor(int)");
+                       return ci.Invoke (new object[1] { 0 });
+               }
+
+               public override Type Type {
+                       get { return typeof (PartialCachingAttribute); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/PersistChildrenAttributeCas.cs b/mcs/class/System.Web/Test/System.Web.UI/PersistChildrenAttributeCas.cs
new file mode 100644 (file)
index 0000000..9b3bce0
--- /dev/null
@@ -0,0 +1,93 @@
+//
+// PersistChildrenAttributeCas.cs 
+//     - CAS unit tests for System.Web.UI.PersistChildrenAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 PersistChildrenAttributeCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor1_Deny_Unrestricted ()
+               {
+                       PersistChildrenAttribute pca = new PersistChildrenAttribute (true);
+                       Assert.IsTrue (pca.Persist, "Persist");
+#if NET_2_0
+                       Assert.IsFalse (pca.UsesCustomPersistence, "UsesCustomPersistence");
+#endif
+                       Assert.IsTrue (pca.Equals (pca), "Equals");
+                       Assert.IsTrue (pca.IsDefaultAttribute (), "IsDefaultAttribute");
+               }
+
+#if NET_2_0
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor2_Deny_Unrestricted ()
+               {
+                       PersistChildrenAttribute pca = new PersistChildrenAttribute (false, true);
+                       Assert.IsFalse (pca.Persist, "Persist");
+                       Assert.IsTrue (pca.UsesCustomPersistence, "UsesCustomPersistence");
+                       Assert.IsTrue (pca.Equals (pca), "Equals");
+                       Assert.IsFalse (pca.IsDefaultAttribute (), "IsDefaultAttribute");
+               }
+#endif
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Static_Deny_Unrestricted ()
+               {
+                       Assert.IsNotNull (PersistChildrenAttribute.Default, "Default");
+                       Assert.IsNotNull (PersistChildrenAttribute.Yes, "Yes");
+                       Assert.IsNotNull (PersistChildrenAttribute.No, "No");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (bool) });
+                       Assert.IsNotNull (ci, ".ctor(bool)");
+                       return ci.Invoke (new object[1] { false });
+               }
+
+               public override Type Type {
+                       get { return typeof (PersistChildrenAttribute); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/PersistenceModeAttributeCas.cs b/mcs/class/System.Web/Test/System.Web.UI/PersistenceModeAttributeCas.cs
new file mode 100644 (file)
index 0000000..578e4b1
--- /dev/null
@@ -0,0 +1,79 @@
+//
+// PersistenceModeAttributeCas.cs 
+//     - CAS unit tests for System.Web.UI.PersistenceModeAttribute
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 PersistenceModeAttributeCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Deny_Unrestricted ()
+               {
+                       PersistenceModeAttribute pma = new PersistenceModeAttribute (PersistenceMode.Attribute);
+                       Assert.AreEqual (PersistenceMode.Attribute, pma.Mode, "Mode");
+                       Assert.IsTrue (pma.Equals (pma), "Equals");
+                       Assert.IsTrue (pma.IsDefaultAttribute (), "IsDefaultAttribute");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Static_Deny_Unrestricted ()
+               {
+                       Assert.IsNotNull (PersistenceModeAttribute.Default, "Default");
+                       Assert.IsNotNull (PersistenceModeAttribute.Attribute, "Attribute");
+                       Assert.IsNotNull (PersistenceModeAttribute.EncodedInnerDefaultProperty, "EncodedInnerDefaultProperty");
+                       Assert.IsNotNull (PersistenceModeAttribute.InnerDefaultProperty, "InnerDefaultProperty");
+                       Assert.IsNotNull (PersistenceModeAttribute.InnerProperty, "InnerProperty");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (PersistenceMode) });
+                       Assert.IsNotNull (ci, ".ctor(PersistenceMode)");
+                       return ci.Invoke (new object[1] { PersistenceMode.Attribute });
+               }
+
+               public override Type Type {
+                       get { return typeof (PersistenceModeAttribute); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/PropertyConverterCas.cs b/mcs/class/System.Web/Test/System.Web.UI/PropertyConverterCas.cs
new file mode 100644 (file)
index 0000000..545f569
--- /dev/null
@@ -0,0 +1,68 @@
+//
+// PropertyConverterCas.cs 
+//     - CAS unit tests for System.Web.UI.PropertyConverter
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 PropertyConverterCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void StaticMethods_Deny_Unrestricted ()
+               {
+                       Assert.AreEqual (SecurityAction.Demand, PropertyConverter.EnumFromString (typeof (SecurityAction), "Demand"), "EnumFromString");
+                       Assert.AreEqual ("Demand", PropertyConverter.EnumToString (typeof (SecurityAction), SecurityAction.Demand), "EnumToString");
+                       Assert.AreEqual (String.Empty, PropertyConverter.ObjectFromString (typeof (string), null, String.Empty), "ObjectFromString");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       // static class 2.0 / no public ctor before (1.x)
+                       MethodInfo mi = this.Type.GetMethod ("EnumToString");
+                       Assert.IsNotNull (mi, "EnumToString");
+                       return mi.Invoke (null, new object[2] { typeof(SecurityAction), SecurityAction.Demand });
+               }
+
+               public override Type Type {
+                       get { return typeof (PropertyConverter); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/RootBuilderCas.cs b/mcs/class/System.Web/Test/System.Web.UI/RootBuilderCas.cs
new file mode 100644 (file)
index 0000000..2d98836
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// RootBuilderCas.cs - CAS unit tests for System.Web.UI.RootBuilder
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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.Collections;
+using System.Reflection;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.HtmlControls;
+
+namespace MonoCasTests.System.Web.UI {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class RootBuilderCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor1_Deny_Unrestricted ()
+               {
+                       RootBuilder rb = new RootBuilder (new PageParser ());
+                       try {
+                               rb.GetChildControlType (null, null);
+                       }
+                       catch (ArgumentNullException) {
+                               // mono and ms 1.x
+                       }
+                       catch (NullReferenceException) {
+                               // ms 2.0 - more likely parameters don't change this result
+                       }
+#if NET_2_0
+                       Assert.IsNotNull (rb.BuiltObjects, "BuiltObjects");
+#endif
+               }
+
+#if NET_2_0
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Ctor0_Deny_Unrestricted ()
+               {
+                       RootBuilder rb = new RootBuilder ();
+                       Assert.IsNotNull (rb.BuiltObjects, "BuiltObjects");
+               }
+#endif
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (TemplateParser) });
+                       Assert.IsNotNull (ci, ".ctor(TemplateParser)");
+                       return ci.Invoke (new object[1] { null });
+               }
+
+               public override Type Type {
+                       get { return typeof (RootBuilder); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/StateBagCas.cs b/mcs/class/System.Web/Test/System.Web.UI/StateBagCas.cs
new file mode 100644 (file)
index 0000000..371fbfd
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// StateBagCas.cs - CAS unit tests for System.Web.UI.StateBag
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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.Collections;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.UI;
+
+namespace MonoCasTests.System.Web.UI {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class StateBagCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Deny_Unrestricted ()
+               {
+                       StateBag bag = new StateBag (true);
+                       Assert.IsNotNull (bag.Add ("key", "value"), "Add");
+                       Assert.AreEqual (1, bag.Count, "Count");
+                       Assert.IsNotNull (bag.GetEnumerator (), "GetEnumerator");
+                       bag.SetItemDirty ("key", true);
+                       Assert.IsTrue (bag.IsItemDirty ("key"), "IsItemDirty");
+                       bag.Remove ("key");
+
+                       bag.Clear ();
+                       bag["key"] = "value";
+                       Assert.IsNotNull (bag["key"], "this[string]");
+                       Assert.IsNotNull (bag.Keys, "Keys");
+                       Assert.IsNotNull (bag.Values, "Values");
+#if NET_2_0
+                       bag.SetDirty (true);
+#endif
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void IStateManager_Deny_Unrestricted ()
+               {
+                       IStateManager sm = new StateBag ();
+                       Assert.IsFalse (sm.IsTrackingViewState, "IsTrackingViewState");
+                       object state = sm.SaveViewState ();
+                       sm.LoadViewState (state);
+                       sm.TrackViewState ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void IDictionary_Deny_Unrestricted ()
+               {
+                       IDictionary d = new StateBag ();
+                       d.Add ("key", "value");
+                       Assert.IsTrue (d.Contains ("key"), "Contains");
+                       Assert.AreEqual (1, d.Count, "Count");
+                       d.Remove ("key");
+                       d["key"] = "value";
+                       Assert.AreEqual ("value", d["key"], "this[string]");
+                       d.Clear ();
+                       Assert.IsFalse (d.IsFixedSize, "IsFixedSize");
+                       Assert.IsFalse (d.IsReadOnly, "IsReadOnly");
+
+                       ICollection c = (d as ICollection);
+                       Assert.IsFalse (c.IsSynchronized, "IsSynchronized");
+                       Assert.IsNotNull (c.SyncRoot, "SyncRoot");
+               }
+
+               // LinkDemand
+
+               public override Type Type {
+                       get { return typeof (StateBag); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/StateItemCas.cs b/mcs/class/System.Web/Test/System.Web.UI/StateItemCas.cs
new file mode 100644 (file)
index 0000000..6c343c6
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// StateItemCas.cs - CAS unit tests for System.Web.UI.StateItem
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 StateItemCas : AspNetHostingMinimal {
+
+               private StateItem item;
+
+               [TestFixtureSetUp]
+               public void FixtureSetup ()
+               {
+                       item = new StateBag ().Add ("key", "value");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Deny_Unrestricted ()
+               {
+                       Assert.IsFalse (item.IsDirty, "IsDirty");
+                       item.IsDirty = true;
+                       Assert.AreEqual ("value", item.Value);
+                       item.Value = null;
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       MethodInfo mi = this.Type.GetProperty ("IsDirty").GetGetMethod ();
+                       Assert.IsNotNull (mi, ".ctor(TemplateParser)");
+                       return mi.Invoke (item, null);
+               }
+
+               public override Type Type {
+                       get { return typeof (StateItem); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.UI/StaticPartialCachingControlCas.cs b/mcs/class/System.Web/Test/System.Web.UI/StaticPartialCachingControlCas.cs
new file mode 100644 (file)
index 0000000..2859177
--- /dev/null
@@ -0,0 +1,74 @@
+//
+// StaticPartialCachingControlCas.cs 
+//     - CAS unit tests for System.Web.UI.StaticPartialCachingControl
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// 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 StaticPartialCachingControlCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor_Deny_Unrestricted ()
+               {
+                       new StaticPartialCachingControl (null, null, 0, null, null, null, null);
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void BuildCachedControl_Deny_Unrestricted ()
+               {
+                       Control parent = new Control ();
+                       StaticPartialCachingControl.BuildCachedControl (parent, null, null, 0, null, null, null, null);
+                       Assert.AreEqual (1, parent.Controls.Count, "Count");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[7] { typeof (string), typeof (string),
+                               typeof (int), typeof (string), typeof (string), typeof (string), typeof (BuildMethod) });
+                       Assert.IsNotNull (ci, ".ctor(2xstring,int,3xstring,BuildMethod)");
+                       return ci.Invoke (new object[7] { null, null, null, null, null, null, null });
+               }
+
+               public override Type Type {
+                       get { return typeof (StaticPartialCachingControl); }
+               }
+       }
+}