public void Intersect_SmtpAccess() { SmtpPermission spn = new SmtpPermission(false); SmtpPermission spu = new SmtpPermission(true); SmtpPermission spctup = new SmtpPermission(SmtpAccess.ConnectToUnrestrictedPort); SmtpPermission spconnect = new SmtpPermission(SmtpAccess.Connect); SmtpPermission spnone = new SmtpPermission(SmtpAccess.None); SmtpPermission intersect = (SmtpPermission)spn.Intersect(spctup); Assert.AreEqual(SmtpAccess.None, intersect.Access, "None N ConnectToUnrestrictedPort"); intersect = (SmtpPermission)spn.Intersect(spconnect); Assert.AreEqual(SmtpAccess.None, intersect.Access, "None N Connect"); intersect = (SmtpPermission)spn.Intersect(spnone); Assert.AreEqual(SmtpAccess.None, intersect.Access, "None N SmtpAccess.None"); intersect = (SmtpPermission)spu.Intersect(spctup); Assert.AreEqual(SmtpAccess.ConnectToUnrestrictedPort, intersect.Access, "Unrestricted N ConnectToUnrestrictedPort"); intersect = (SmtpPermission)spu.Intersect(spconnect); Assert.AreEqual(SmtpAccess.Connect, intersect.Access, "Unrestricted N Connect"); intersect = (SmtpPermission)spu.Intersect(spnone); Assert.AreEqual(SmtpAccess.None, intersect.Access, "Unrestricted N SmtpAccess.None"); intersect = (SmtpPermission)spctup.Intersect(spctup); Assert.AreEqual(SmtpAccess.ConnectToUnrestrictedPort, intersect.Access, "ConnectToUnrestrictedPort N ConnectToUnrestrictedPort"); intersect = (SmtpPermission)spctup.Intersect(spconnect); Assert.AreEqual(SmtpAccess.Connect, intersect.Access, "ConnectToUnrestrictedPort N Connect"); intersect = (SmtpPermission)spctup.Intersect(spnone); Assert.AreEqual(SmtpAccess.None, intersect.Access, "ConnectToUnrestrictedPort N SmtpAccess.None"); intersect = (SmtpPermission)spctup.Intersect(spn); Assert.AreEqual(SmtpAccess.None, intersect.Access, "ConnectToUnrestrictedPort N None"); intersect = (SmtpPermission)spctup.Intersect(spu); Assert.AreEqual(SmtpAccess.ConnectToUnrestrictedPort, intersect.Access, "ConnectToUnrestrictedPort N Unrestricted"); intersect = (SmtpPermission)spconnect.Intersect(spctup); Assert.AreEqual(SmtpAccess.Connect, intersect.Access, "Connect N ConnectToUnrestrictedPort"); intersect = (SmtpPermission)spconnect.Intersect(spconnect); Assert.AreEqual(SmtpAccess.Connect, intersect.Access, "Connect N Connect"); intersect = (SmtpPermission)spconnect.Intersect(spnone); Assert.AreEqual(SmtpAccess.None, intersect.Access, "Connect N SmtpAccess.None"); intersect = (SmtpPermission)spconnect.Intersect(spn); Assert.AreEqual(SmtpAccess.None, intersect.Access, "Connect N None"); intersect = (SmtpPermission)spconnect.Intersect(spu); Assert.AreEqual(SmtpAccess.Connect, intersect.Access, "Connect N Unrestricted"); intersect = (SmtpPermission)spnone.Intersect(spctup); Assert.AreEqual(SmtpAccess.None, intersect.Access, "SmtpAccess.None N ConnectToUnrestrictedPort"); intersect = (SmtpPermission)spnone.Intersect(spconnect); Assert.AreEqual(SmtpAccess.None, intersect.Access, "SmtpAccess.None N Connect"); intersect = (SmtpPermission)spnone.Intersect(spnone); Assert.AreEqual(SmtpAccess.None, intersect.Access, "SmtpAccess.None N SmtpAccess.None"); intersect = (SmtpPermission)spnone.Intersect(spn); Assert.AreEqual(SmtpAccess.None, intersect.Access, "SmtpAccess.None N None"); intersect = (SmtpPermission)spnone.Intersect(spu); Assert.AreEqual(SmtpAccess.None, intersect.Access, "SmtpAccess.None N Unrestricted"); }
// </snippet5> // <snippet6> public static SmtpPermission IntersectionWithFull(SmtpPermission permission) { SmtpPermission allAccess = new SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted); return((SmtpPermission)permission.Intersect(allAccess)); }
public void Intersect() { SmtpPermission spn = new SmtpPermission(PermissionState.None); Assert.IsNull(spn.Intersect(null), "None N null"); SmtpPermission inter = (SmtpPermission)spn.Intersect(spn); Assert.AreEqual(SmtpAccess.None, inter.Access, "None N None"); SmtpPermission spu = new SmtpPermission(PermissionState.Unrestricted); Assert.IsNull(spu.Intersect(null), "Unrestricted N null"); SmtpPermission result = (SmtpPermission)spu.Intersect(spu); Assert.IsTrue(result.IsUnrestricted(), "Unrestricted N Unrestricted"); inter = (SmtpPermission)spn.Intersect(spu); Assert.AreEqual(SmtpAccess.None, inter.Access, "None N Unrestricted"); inter = (SmtpPermission)spu.Intersect(spn); Assert.AreEqual(SmtpAccess.None, inter.Access, "Unrestricted N None"); }
public void Intersect_BadPermission() { SmtpPermission sp = new SmtpPermission(PermissionState.None); sp.Intersect(new SecurityPermission(PermissionState.Unrestricted)); }