Exemplo n.º 1
0
        public void IsSubset_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);

            Assert.IsTrue(spn.IsSubsetOf(spctup), "None IsSubsetOf ConnectToUnrestrictedPort");
            Assert.IsTrue(spn.IsSubsetOf(spconnect), "None IsSubsetOf Connect");
            Assert.IsTrue(spn.IsSubsetOf(spnone), "None IsSubsetOf SmtpAccess.None");

            Assert.IsFalse(spu.IsSubsetOf(spctup), "Unrestricted IsSubsetOf ConnectToUnrestrictedPort");
            Assert.IsFalse(spu.IsSubsetOf(spconnect), "Unrestricted IsSubsetOf Connect");
            Assert.IsFalse(spu.IsSubsetOf(spnone), "Unrestricted IsSubsetOf SmtpAccess.None");

            Assert.IsTrue(spctup.IsSubsetOf(spctup), "ConnectToUnrestrictedPort IsSubsetOf ConnectToUnrestrictedPort");
            Assert.IsFalse(spctup.IsSubsetOf(spconnect), "ConnectToUnrestrictedPort IsSubsetOf Connect");
            Assert.IsFalse(spctup.IsSubsetOf(spnone), "ConnectToUnrestrictedPort IsSubsetOf SmtpAccess.None");
            Assert.IsFalse(spctup.IsSubsetOf(spn), "ConnectToUnrestrictedPort IsSubsetOf None");
            Assert.IsTrue(spctup.IsSubsetOf(spu), "ConnectToUnrestrictedPort IsSubsetOf Unrestricted");

            Assert.IsTrue(spconnect.IsSubsetOf(spctup), "Connect IsSubsetOf ConnectToUnrestrictedPort");
            Assert.IsTrue(spconnect.IsSubsetOf(spconnect), "Connect IsSubsetOf Connect");
            Assert.IsFalse(spconnect.IsSubsetOf(spnone), "Connect IsSubsetOf SmtpAccess.None");
            Assert.IsFalse(spconnect.IsSubsetOf(spn), "Connect IsSubsetOf None");
            Assert.IsTrue(spconnect.IsSubsetOf(spu), "Connect IsSubsetOf Unrestricted");

            Assert.IsTrue(spnone.IsSubsetOf(spctup), "SmtpAccess.None IsSubsetOf ConnectToUnrestrictedPort");
            Assert.IsTrue(spnone.IsSubsetOf(spconnect), "SmtpAccess.None IsSubsetOf Connect");
            Assert.IsTrue(spnone.IsSubsetOf(spnone), "SmtpAccess.None IsSubsetOf SmtpAccess.None");
            Assert.IsTrue(spnone.IsSubsetOf(spn), "SmtpAccess.None IsSubsetOf None");
            Assert.IsTrue(spnone.IsSubsetOf(spu), "SmtpAccess.None IsSubsetOf Unrestricted");
        }
Exemplo n.º 2
0
        public void IsSubset()
        {
            SmtpPermission spn = new SmtpPermission(PermissionState.None);
            SmtpPermission spu = new SmtpPermission(PermissionState.Unrestricted);

            Assert.IsTrue(spn.IsSubsetOf(null), "None IsSubsetOf null");
            Assert.IsFalse(spu.IsSubsetOf(null), "Unrestricted IsSubsetOf null");

            Assert.IsTrue(spn.IsSubsetOf(spn), "None IsSubsetOf None");
            Assert.IsTrue(spu.IsSubsetOf(spu), "Unrestricted IsSubsetOf Unrestricted");

            Assert.IsTrue(spn.IsSubsetOf(spu), "None IsSubsetOf Unrestricted");
            Assert.IsFalse(spu.IsSubsetOf(spn), "Unrestricted IsSubsetOf None");
        }
Exemplo n.º 3
0
// </snippet6>

// <snippet7>
        public static bool CheckSubSet(SmtpPermission permission)
        {
            SmtpPermission allAccess = new
                                       SmtpPermission(System.Security.Permissions.PermissionState.Unrestricted);

            return(permission.IsSubsetOf(allAccess));
        }
Exemplo n.º 4
0
        public void IsSubset_BadPermission()
        {
            SmtpPermission sp = new SmtpPermission(PermissionState.None);

            sp.IsSubsetOf(new SecurityPermission(PermissionState.Unrestricted));
        }