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 Union_Unrestricted () { // Union with unrestricted is unrestricted AspNetHostingPermission sp1 = new AspNetHostingPermission (PermissionState.Unrestricted); AspNetHostingPermission sp2 = new AspNetHostingPermission (PermissionState.None); // a. source (this) is unrestricted foreach (AspNetHostingPermissionLevel ppl in AllLevel) { sp2.Level = ppl; AspNetHostingPermission union = (AspNetHostingPermission)sp1.Union (sp2); Assert.IsTrue (union.IsUnrestricted (), "target " + ppl.ToString ()); } // b. destination (target) is unrestricted foreach (AspNetHostingPermissionLevel ppl in AllLevel) { sp2.Level = ppl; AspNetHostingPermission union = (AspNetHostingPermission)sp2.Union (sp1); Assert.IsTrue (union.IsUnrestricted (), "source " + ppl.ToString ()); } }
public void Union_Self () { AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None); foreach (AspNetHostingPermissionLevel ppl in AllLevel) { anhp.Level = ppl; AspNetHostingPermission result = (AspNetHostingPermission)anhp.Union (anhp); Assert.AreEqual (ppl, result.Level, ppl.ToString ()); } }
public void Union_None () { // Union with none is same AspNetHostingPermission pp1 = new AspNetHostingPermission (PermissionState.None); AspNetHostingPermission pp2 = new AspNetHostingPermission (PermissionState.None); AspNetHostingPermission union = null; foreach (AspNetHostingPermissionLevel ppl in AllLevelExceptUnrestricted) { pp2.Level = ppl; union = (AspNetHostingPermission)pp1.Union (pp2); Assert.IsFalse (union.IsUnrestricted (), "target.Unrestricted " + ppl.ToString ()); Assert.AreEqual (ppl, union.Level, "target.Level " + ppl.ToString ()); union = (AspNetHostingPermission)pp2.Union (pp1); Assert.IsFalse (union.IsUnrestricted (), "source.Unrestricted " + ppl.ToString ()); Assert.AreEqual (ppl, union.Level, "source.Level " + ppl.ToString ()); } pp2.Level = AspNetHostingPermissionLevel.Unrestricted; union = (AspNetHostingPermission)pp1.Union (pp2); Assert.IsTrue (union.IsUnrestricted (), "target.Unrestricted Unrestricted"); Assert.AreEqual (AspNetHostingPermissionLevel.Unrestricted, union.Level, "target.Level Unrestricted"); union = (AspNetHostingPermission)pp2.Union (pp1); Assert.IsTrue (union.IsUnrestricted (), "source.Unrestricted Unrestricted"); Assert.AreEqual (AspNetHostingPermissionLevel.Unrestricted, union.Level, "source.Level Unrestricted"); }
public void Union_Null () { AspNetHostingPermission anhp = new AspNetHostingPermission (PermissionState.None); // Union with null is a simple copy foreach (AspNetHostingPermissionLevel ppl in AllLevel) { anhp.Level = ppl; AspNetHostingPermission union = (AspNetHostingPermission)anhp.Union (null); Assert.AreEqual (ppl, union.Level, ppl.ToString ()); } }