public void Union_BadPermission () { ServiceControllerPermission scp1 = new ServiceControllerPermission (PermissionState.Unrestricted); scp1.Union (new SecurityPermission (SecurityPermissionFlag.Assertion)); }
public void Union_Self () { foreach (ServiceControllerPermissionAccess scpa in AllAccess) { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); scp.PermissionEntries.Add (new ServiceControllerPermissionEntry (scpa, "localhost", scpa.ToString ())); ServiceControllerPermission union = (ServiceControllerPermission)scp.Union (scp); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted " + scpa.ToString ()); Assert.AreEqual (1, union.PermissionEntries.Count, "Count " + scpa.ToString ()); } }
public void Union_Unrestricted () { // Union with unrestricted is unrestricted ServiceControllerPermission scp1 = new ServiceControllerPermission (PermissionState.Unrestricted); foreach (ServiceControllerPermissionAccess scpa in AllAccess) { ServiceControllerPermission scp2 = new ServiceControllerPermission (PermissionState.None); scp2.PermissionEntries.Add (new ServiceControllerPermissionEntry (scpa, "localhost", scpa.ToString ())); ServiceControllerPermission union = (ServiceControllerPermission)scp1.Union (scp2); Assert.IsTrue (union.IsUnrestricted (), "target.IsUnrestricted " + scpa.ToString ()); Assert.AreEqual (0, union.PermissionEntries.Count, "target.Count " + scpa.ToString ()); union = (ServiceControllerPermission)scp2.Union (scp1); Assert.IsTrue (union.IsUnrestricted (), "source.IsUnrestricted " + scpa.ToString ()); Assert.AreEqual (0, union.PermissionEntries.Count, "source.Count " + scpa.ToString ()); } }
public void Union_Null () { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); scp.PermissionEntries.Add (new ServiceControllerPermissionEntry (ServiceControllerPermissionAccess.None, "localhost", "http")); // Union with null is a simple copy ServiceControllerPermission union = (ServiceControllerPermission)scp.Union (null); Assert.AreEqual (1, union.PermissionEntries.Count, "Count"); }