public void Default () { ReflectionPermissionAttribute a = new ReflectionPermissionAttribute (SecurityAction.Assert); Assert.AreEqual (ReflectionPermissionFlag.NoFlags, a.Flags, "Flags"); Assert.IsFalse (a.MemberAccess, "MemberAccess"); Assert.IsFalse (a.ReflectionEmit, "ReflectionEmit"); Assert.IsFalse (a.TypeInformation, "TypeInformation"); Assert.AreEqual (a.ToString (), a.TypeId.ToString (), "TypeId"); Assert.IsFalse (a.Unrestricted, "Unrestricted"); ReflectionPermission perm = (ReflectionPermission) a.CreatePermission (); Assert.AreEqual (ReflectionPermissionFlag.NoFlags, perm.Flags, "CreatePermission.Flags"); Assert.IsFalse (perm.IsUnrestricted (), "perm.Unrestricted"); }
public void AllFlags () { ReflectionPermissionAttribute attr = new ReflectionPermissionAttribute (SecurityAction.Assert); attr.MemberAccess = true; attr.ReflectionEmit = true; attr.TypeInformation = true; Assert.AreEqual (ReflectionPermissionFlag.AllFlags, attr.Flags, "AllFlags.Flags"); // attribute isn't unrestricted but the created permission is !!! Assert.IsFalse (attr.Unrestricted, "AllFlags.Unrestricted"); Assert.IsTrue (attr.MemberAccess, "AllFlags=MemberAccess"); Assert.IsTrue (attr.ReflectionEmit, "AllFlags=ReflectionEmit"); Assert.IsTrue (attr.TypeInformation, "AllFlags=TypeInformation"); ReflectionPermission p = (ReflectionPermission) attr.CreatePermission (); Assert.AreEqual (ReflectionPermissionFlag.AllFlags, p.Flags, "AllFlags=ReflectionPermission"); Assert.IsTrue (p.IsUnrestricted (), "AllFlags=Unrestricted"); }
public void Unrestricted () { ReflectionPermissionAttribute a = new ReflectionPermissionAttribute (SecurityAction.Assert); a.Unrestricted = true; Assert.AreEqual (ReflectionPermissionFlag.NoFlags, a.Flags, "Unrestricted"); ReflectionPermission perm = (ReflectionPermission) a.CreatePermission (); Assert.AreEqual (ReflectionPermissionFlag.AllFlags, perm.Flags, "CreatePermission.Flags"); }
public void TypeInformation () { ReflectionPermissionAttribute attr = new ReflectionPermissionAttribute (SecurityAction.Assert); attr.TypeInformation = true; Assert.AreEqual (ReflectionPermissionFlag.TypeInformation, attr.Flags, "TypeInformation.Flags"); Assert.IsFalse (attr.Unrestricted, "TypeInformation.Unrestricted"); Assert.IsFalse (attr.MemberAccess, "TypeInformation=MemberAccess"); Assert.IsFalse (attr.ReflectionEmit, "TypeInformation=ReflectionEmit"); Assert.IsTrue (attr.TypeInformation, "TypeInformation=TypeInformation"); ReflectionPermission p = (ReflectionPermission) attr.CreatePermission (); Assert.AreEqual (ReflectionPermissionFlag.TypeInformation, p.Flags, "TypeInformation=TypeInformation"); }