public void Intersect_None () { DirectoryServicesPermission dsp1 = new DirectoryServicesPermission (PermissionState.None); DirectoryServicesPermission dsp2 = new DirectoryServicesPermission (PermissionState.None); // 1. None N None DirectoryServicesPermission result = (DirectoryServicesPermission) dsp1.Intersect (dsp2); Assert.IsNull (result, "Empty N Empty"); // 2. None N Entry dsp2.PermissionEntries.Add (new DirectoryServicesPermissionEntry (DirectoryServicesPermissionAccess.None, String.Empty)); result = (DirectoryServicesPermission) dsp1.Intersect (dsp2); Assert.IsNull (result, "Empty N Entry"); // 3. Entry N None result = (DirectoryServicesPermission) dsp2.Intersect (dsp1); Assert.IsNull (result, "Entry N Empty"); }
public void Intersect_Unrestricted () { // Intersection with unrestricted == Copy // a. source (this) is unrestricted DirectoryServicesPermission dsp1 = new DirectoryServicesPermission (PermissionState.Unrestricted); DirectoryServicesPermission dsp2 = new DirectoryServicesPermission (PermissionState.None); // 1. Unrestricted N None DirectoryServicesPermission result = (DirectoryServicesPermission) dsp1.Intersect (dsp2); Assert.IsFalse (result.IsUnrestricted (), "(Unrestricted N None).IsUnrestricted"); Assert.AreEqual (0, result.PermissionEntries.Count, "(Unrestricted N None).Count"); // 2. None N Unrestricted result = (DirectoryServicesPermission) dsp2.Intersect (dsp1); Assert.IsFalse (result.IsUnrestricted (), "(None N Unrestricted).IsUnrestricted"); Assert.AreEqual (0, result.PermissionEntries.Count, "(None N Unrestricted).Count"); // 3. Unrestricted N Unrestricted result = (DirectoryServicesPermission) dsp1.Intersect (dsp1); Assert.IsTrue (result.IsUnrestricted (), "(Unrestricted N Unrestricted).IsUnrestricted"); Assert.AreEqual (0, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count"); // 4. Unrestricted N Entry dsp2.PermissionEntries.Add (new DirectoryServicesPermissionEntry (DirectoryServicesPermissionAccess.None, String.Empty)); result = (DirectoryServicesPermission)dsp1.Intersect (dsp2); Assert.IsFalse (result.IsUnrestricted (), "(Unrestricted N Entry).IsUnrestricted"); Assert.AreEqual (1, result.PermissionEntries.Count, "(Unrestricted N Entry).Count"); // 5. Entry N Unrestricted result = (DirectoryServicesPermission)dsp2.Intersect (dsp1); Assert.IsFalse (result.IsUnrestricted (), "(Entry N Unrestricted).IsUnrestricted"); Assert.AreEqual (1, result.PermissionEntries.Count, "(Entry N Unrestricted).Count"); // 6. Unrestricted N Unrestricted dsp1.PermissionEntries.Add (new DirectoryServicesPermissionEntry (DirectoryServicesPermissionAccess.None, String.Empty)); result = (DirectoryServicesPermission)dsp1.Intersect (dsp1); Assert.IsTrue (result.IsUnrestricted (), "(Unrestricted N Unrestricted).IsUnrestricted"); Assert.AreEqual (1, result.PermissionEntries.Count, "(Unrestricted N Unrestricted).Count"); }
public void Intersect_Null () { DirectoryServicesPermission dsp = new DirectoryServicesPermission (PermissionState.None); // No intersection with null Assert.IsNull (dsp.Intersect (null), "None N null"); }