public void ConstructorLevel_Deny_Unrestricted () { StorePermission p = new StorePermission (StorePermissionFlags.AllFlags); Assert.AreEqual (StorePermissionFlags.AllFlags, p.Flags, "Flags"); Assert.IsTrue (p.IsUnrestricted (), "IsUnrestricted"); Assert.IsNotNull (p.Copy (), "Copy"); SecurityElement se = p.ToXml (); Assert.IsNotNull (se, "ToXml"); p.FromXml (se); Assert.IsNotNull (p.Intersect (p), "Intersect"); Assert.IsTrue (p.IsSubsetOf (p), "IsSubsetOf"); Assert.IsNotNull (p.Union (p), "Union"); }
public void ConstructorState_Deny_Unrestricted () { StorePermission p = new StorePermission (PermissionState.None); Assert.AreEqual (StorePermissionFlags.NoFlags, p.Flags, "Flags"); Assert.IsFalse (p.IsUnrestricted (), "IsUnrestricted"); SecurityElement se = p.ToXml (); Assert.IsNotNull (se, "ToXml"); p.FromXml (se); Assert.IsTrue (p.IsSubsetOf (p), "IsSubsetOf"); // strange behaviour of Copy under MS fx 2.0 (returns null for NoFlags) p.Copy (); p.Intersect (p); p.Union (p); }
public void IsSubset_Unrestricted () { // IsSubset with unrestricted // a. source (this) is unrestricted -> target is never a subset StorePermission sp1 = new StorePermission (PermissionState.Unrestricted); StorePermission sp2 = new StorePermission (PermissionState.None); for (int i = 0; i < (int) StorePermissionFlags.AllFlags - 1; i++) { // 8 isn't a valid value (so we exclude it from the rest of the loop) if ((i & 8) == 8) continue; sp2.Flags = (StorePermissionFlags) i; Assert.IsFalse (sp1.IsSubsetOf (sp2), "target " + sp2.Flags.ToString ()); } // exception of AllLevel sp2.Flags = StorePermissionFlags.AllFlags; Assert.IsTrue (sp1.IsSubsetOf (sp2), "target AllLevel"); // b. destination (target) is unrestricted -> target is always a subset for (int i = 0; i < (int) StorePermissionFlags.AllFlags; i++) { // 8 isn't a valid value (so we exclude it from the rest of the loop) if ((i & 8) == 8) continue; sp2.Flags = (StorePermissionFlags) i; Assert.IsTrue (sp2.IsSubsetOf (sp1), "source " + sp2.Flags.ToString ()); } }
public void IsSubset_Self () { StorePermission sp = new StorePermission (PermissionState.None); for (int i = 1; i < (int) StorePermissionFlags.AllFlags; i++) { // 8 isn't a valid value (so we exclude it from the rest of the loop) if ((i & 8) == 8) continue; sp.Flags = (StorePermissionFlags) i; Assert.IsTrue (sp.IsSubsetOf (sp), sp.Flags.ToString ()); } }