2005-10-18 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 18 Oct 2005 15:49:22 +0000 (15:49 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 18 Oct 2005 15:49:22 +0000 (15:49 -0000)
* InstanceDescriptorCas.cs: Added more tests for LinkDemand as it just
occured to me that it looked like the LinkDemand was on the class (and
not only on the ctor).

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

mcs/class/System/Test/System.ComponentModel.Design.Serialization/ChangeLog
mcs/class/System/Test/System.ComponentModel.Design.Serialization/InstanceDescriptorCas.cs

index 0a641c19e860f4da64d3b3098cd62846d22d98fb..7255bbf1a373fbce2e202c72779bd5734d8afeeb 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-18  Sebastien Pouliot  <sebastien@ximian.com> 
+       * InstanceDescriptorCas.cs: Added more tests for LinkDemand as it just
+       occured to me that it looked like the LinkDemand was on the class (and
+       not only on the ctor).
+
 2005-10-18  Sebastien Pouliot  <sebastien@ximian.com>
 
        * InstanceDescriptorCas.cs: New. CAS unit tests.
index 5bfb12c21bee31222536a4d891ea4d558f4ebe13..784a8be0b4d871efe351762308ea3f0756d638db 100644 (file)
@@ -67,7 +67,7 @@ namespace MonoCasTests.System.ComponentModel.Design.Serialization {
                [Test]
                [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
                [ExpectedException (typeof (SecurityException))]
-               public void LinkDemand_Deny_Anything ()
+               public void Ctor2_LinkDemand_Deny_Anything ()
                {
                        // denying anything -> not unrestricted
                        Type[] types = new Type[2] { typeof (MemberInfo), typeof (ICollection) };
@@ -78,12 +78,59 @@ namespace MonoCasTests.System.ComponentModel.Design.Serialization {
 
                [Test]
                [PermissionSet (SecurityAction.PermitOnly, Unrestricted = true)]
-               public void LinkDemand_PermitOnly_Unrestricted ()
+               public void Ctor2_LinkDemand_PermitOnly_Unrestricted ()
                {
                        Type[] types = new Type[2] { typeof (MemberInfo), typeof (ICollection) };
                        ConstructorInfo ci = typeof (InstanceDescriptor).GetConstructor (types);
                        Assert.IsNotNull (ci, ".ctor(MemberInfo,ICollection)");
                        Assert.IsNotNull (ci.Invoke (new object[2] { null, new object[] { } }), "invoke");
                }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void Ctor3_LinkDemand_Deny_Anything ()
+               {
+                       // denying anything -> not unrestricted
+                       Type[] types = new Type[3] { typeof (MemberInfo), typeof (ICollection), typeof (bool) };
+                       ConstructorInfo ci = typeof (InstanceDescriptor).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(MemberInfo,ICollection,bool)");
+                       Assert.IsNotNull (ci.Invoke (new object[3] { null, new object[] { }, false }), "invoke");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.PermitOnly, Unrestricted = true)]
+               public void Ctor3_LinkDemand_PermitOnly_Unrestricted ()
+               {
+                       Type[] types = new Type[3] { typeof (MemberInfo), typeof (ICollection), typeof (bool) };
+                       ConstructorInfo ci = typeof (InstanceDescriptor).GetConstructor (types);
+                       Assert.IsNotNull (ci, ".ctor(MemberInfo,ICollection,bool)");
+                       Assert.IsNotNull (ci.Invoke (new object[3] { null, new object[] { }, false }), "invoke");
+               }
+
+               [Test]
+               [EnvironmentPermission (SecurityAction.Deny, Read = "Mono")]
+               [ExpectedException (typeof (SecurityException))]
+               public void Property_LinkDemand_Deny_Anything ()
+               {
+                       InstanceDescriptor id = new InstanceDescriptor (null, new object[] { });
+                       // denying anything -> not unrestricted
+                       Type[] types = new Type[3] { typeof (MemberInfo), typeof (ICollection), typeof (bool) };
+                       MethodInfo mi = typeof (InstanceDescriptor).GetProperty ("IsComplete").GetGetMethod ();
+                       Assert.IsNotNull (mi, "IsComplete)");
+                       Assert.IsTrue ((bool)mi.Invoke (id, null), "invoke");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.PermitOnly, Unrestricted = true)]
+               public void Property_LinkDemand_PermitOnly_Unrestricted ()
+               {
+                       InstanceDescriptor id = new InstanceDescriptor (null, new object[] { });
+                       // denying anything -> not unrestricted
+                       Type[] types = new Type[3] { typeof (MemberInfo), typeof (ICollection), typeof (bool) };
+                       MethodInfo mi = typeof (InstanceDescriptor).GetProperty ("IsComplete").GetGetMethod ();
+                       Assert.IsNotNull (mi, "IsComplete)");
+                       Assert.IsTrue ((bool) mi.Invoke (id, null), "invoke");
+               }
        }
 }