public void Union_DifferentIdentities () { ZoneIdentityPermission a = new ZoneIdentityPermission (SecurityZone.Trusted); ZoneIdentityPermission b = new ZoneIdentityPermission (SecurityZone.Untrusted); IPermission result = a.Union (b); #if NET_2_0 Assert.IsNotNull (result, "Union"); // new XML format is used to contain more than one site SecurityElement se = result.ToXml (); Assert.AreEqual (2, se.Children.Count, "Childs"); Assert.AreEqual (a.SecurityZone.ToString (), (se.Children [0] as SecurityElement).Attribute ("Zone"), "Zone#1"); Assert.AreEqual (b.SecurityZone.ToString (), (se.Children [1] as SecurityElement).Attribute ("Zone"), "Zone#2"); // strangely it is still versioned as 'version="1"'. Assert.AreEqual ("1", se.Attribute ("version"), "Version"); #else Assert.IsNull (result); #endif }
public void Union_DifferentPermissions () { ZoneIdentityPermission a = new ZoneIdentityPermission (SecurityZone.Trusted); SecurityPermission b = new SecurityPermission (PermissionState.None); a.Union (b); }
public void Union () { ZoneIdentityPermission a = new ZoneIdentityPermission (SecurityZone.Trusted); ZoneIdentityPermission z = (ZoneIdentityPermission) a.Union (null); Assert.IsTrue (Same (a, z), "Trusted+null"); Assert.IsFalse (Object.ReferenceEquals (a, z), "!ReferenceEquals1"); z = (ZoneIdentityPermission) a.Union (new ZoneIdentityPermission (PermissionState.None)); Assert.IsTrue (Same (a, z), "Trusted+PS.None"); Assert.IsFalse (Object.ReferenceEquals (a, z), "!ReferenceEquals2"); // note: can't be tested with PermissionState.Unrestricted ZoneIdentityPermission n = new ZoneIdentityPermission (SecurityZone.NoZone); z = (ZoneIdentityPermission) a.Union (n); Assert.IsTrue (Same (a, z), "Trusted+NoZone"); Assert.IsFalse (Object.ReferenceEquals (a, z), "!ReferenceEquals3"); z = (ZoneIdentityPermission) n.Union (a); Assert.IsTrue (Same (a, z), "NoZone+Trusted"); Assert.IsFalse (Object.ReferenceEquals (a, z), "!ReferenceEquals4"); }