public void Union_Unrestricted () { // Union with unrestricted is unrestricted PrintingPermission sp1 = new PrintingPermission (PermissionState.Unrestricted); PrintingPermission sp2 = new PrintingPermission (PermissionState.None); // a. source (this) is unrestricted foreach (PrintingPermissionLevel ppl in AllLevel) { sp2.Level = ppl; PrintingPermission union = (PrintingPermission)sp1.Union (sp2); Assert.IsTrue (union.IsUnrestricted (), "target " + ppl.ToString ()); } // b. destination (target) is unrestricted foreach (PrintingPermissionLevel ppl in AllLevel) { sp2.Level = ppl; PrintingPermission union = (PrintingPermission)sp2.Union (sp1); Assert.IsTrue (union.IsUnrestricted (), "source " + ppl.ToString ()); } }
public void Union_None () { // Union with none is same PrintingPermission pp1 = new PrintingPermission (PermissionState.None); PrintingPermission pp2 = new PrintingPermission (PermissionState.None); PrintingPermission union = null; // a. source (this) is none pp2.Level = PrintingPermissionLevel.NoPrinting; union = (PrintingPermission)pp1.Union (pp2); Assert.IsNull (union, "target NoPrinting"); foreach (PrintingPermissionLevel ppl in AllLevelExceptNoAndAllLevel) { pp2.Level = ppl; union = (PrintingPermission)pp1.Union (pp2); Assert.IsFalse (union.IsUnrestricted (), "target " + ppl.ToString ()); } pp2.Level = PrintingPermissionLevel.AllPrinting; union = (PrintingPermission)pp1.Union (pp2); Assert.IsTrue (union.IsUnrestricted (), "target AllPrinting"); // b. destination (target) is none pp2.Level = PrintingPermissionLevel.NoPrinting; union = (PrintingPermission)pp2.Union (pp1); Assert.IsNull (union, "source NoPrinting"); foreach (PrintingPermissionLevel ppl in AllLevelExceptNoAndAllLevel) { pp2.Level = ppl; union = (PrintingPermission)pp2.Union (pp1); Assert.IsFalse (union.IsUnrestricted (), "source " + ppl.ToString ()); } pp2.Level = PrintingPermissionLevel.AllPrinting; union = (PrintingPermission)pp2.Union (pp1); Assert.IsTrue (union.IsUnrestricted (), "source AllPrinting"); }
public void Union_Self () { PrintingPermission pp = new PrintingPermission (PermissionState.None); foreach (PrintingPermissionLevel ppl in AllLevelExceptNoLevel) { pp.Level = ppl; PrintingPermission result = (PrintingPermission)pp.Union (pp); Assert.AreEqual (ppl, result.Level, ppl.ToString ()); } // union of NoPrinting with NoPrinting == null pp.Level = PrintingPermissionLevel.NoPrinting; Assert.IsNull (pp.Union (pp), "NoPrinting"); }
public void Union_Null () { PrintingPermission pp = new PrintingPermission (PermissionState.None); // Union with null is a simple copy foreach (PrintingPermissionLevel ppl in AllLevel) { pp.Level = ppl; PrintingPermission union = (PrintingPermission)pp.Union (null); Assert.AreEqual (ppl, union.Level, ppl.ToString ()); } }