public void Union_BadPermission () { PerformanceCounterPermission pcp1 = new PerformanceCounterPermission (PermissionState.Unrestricted); pcp1.Union (new SecurityPermission (SecurityPermissionFlag.Assertion)); }
public void Union_Self () { foreach (PerformanceCounterPermissionAccess pcpa in AllAccess) { PerformanceCounterPermission pcp = new PerformanceCounterPermission (PermissionState.None); pcp.PermissionEntries.Add (new PerformanceCounterPermissionEntry (pcpa, pcpa.ToString (), String.Empty)); PerformanceCounterPermission union = (PerformanceCounterPermission)pcp.Union (pcp); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted " + pcpa.ToString ()); Assert.AreEqual (1, union.PermissionEntries.Count, "Count " + pcpa.ToString ()); } }
public void Union_Unrestricted () { // Union with unrestricted is unrestricted PerformanceCounterPermission pcp1 = new PerformanceCounterPermission (PermissionState.Unrestricted); foreach (PerformanceCounterPermissionAccess pcpa in AllAccess) { PerformanceCounterPermission pcp2 = new PerformanceCounterPermission (PermissionState.None); pcp2.PermissionEntries.Add (new PerformanceCounterPermissionEntry (pcpa, pcpa.ToString (), String.Empty)); PerformanceCounterPermission union = (PerformanceCounterPermission)pcp1.Union (pcp2); Assert.IsTrue (union.IsUnrestricted (), "target.IsUnrestricted " + pcpa.ToString ()); Assert.AreEqual (0, union.PermissionEntries.Count, "target.Count " + pcpa.ToString ()); union = (PerformanceCounterPermission)pcp2.Union (pcp1); Assert.IsTrue (union.IsUnrestricted (), "source.IsUnrestricted " + pcpa.ToString ()); Assert.AreEqual (0, union.PermissionEntries.Count, "source.Count " + pcpa.ToString ()); } }
public void Union_Null () { PerformanceCounterPermission pcp = new PerformanceCounterPermission (PermissionState.None); pcp.PermissionEntries.Add (new PerformanceCounterPermissionEntry (PerformanceCounterPermissionAccess.None, "localhost", String.Empty)); // Union with null is a simple copy PerformanceCounterPermission union = (PerformanceCounterPermission)pcp.Union (null); Assert.IsNotNull (pcp.PermissionEntries.Count, "Count"); }