private void CommonTests (AspNetHostingPermission p) { 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 IsSubset_Unrestricted () { // IsSubset with unrestricted // a. source (this) is unrestricted -> target is never a subset AspNetHostingPermission sp1 = new AspNetHostingPermission (PermissionState.Unrestricted); AspNetHostingPermission sp2 = new AspNetHostingPermission (PermissionState.None); foreach (AspNetHostingPermissionLevel ppl in AllLevelExceptUnrestricted) { sp2.Level = ppl; Assert.IsFalse (sp1.IsSubsetOf (sp2), "target " + ppl.ToString ()); } // exception of AllLevel sp2.Level = AspNetHostingPermissionLevel.Unrestricted; Assert.IsTrue (sp1.IsSubsetOf (sp2), "target AllLevel"); // b. destination (target) is unrestricted -> target is always a subset foreach (AspNetHostingPermissionLevel ppl in AllLevel) { sp2.Level = ppl; Assert.IsTrue (sp2.IsSubsetOf (sp1), "source " + ppl.ToString ()); } }
public void IsSubset_Self () { AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None); foreach (AspNetHostingPermissionLevel ppl in AllLevel) { anhp.Level = ppl; AspNetHostingPermission result = (AspNetHostingPermission)anhp.Intersect (anhp); Assert.IsTrue (anhp.IsSubsetOf (anhp), ppl.ToString ()); } }
public void IsSubset_Null () { AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None); Assert.IsTrue (anhp.IsSubsetOf (null), "NoLevel"); foreach (AspNetHostingPermissionLevel ppl in AllLevelExceptNone) { anhp.Level = ppl; Assert.IsFalse (anhp.IsSubsetOf (null), ppl.ToString ()); } }