예제 #1
0
        public void Unrestricted()
        {
            OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert);

            a.Unrestricted = true;
            OleDbPermission odp = (OleDbPermission)a.CreatePermission();

            Assert.IsTrue(odp.IsUnrestricted(), "IsUnrestricted");
            Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword");
            Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString");
            Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
            Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions");

            a.Unrestricted = false;
            odp            = (OleDbPermission)a.CreatePermission();
            Assert.IsFalse(odp.IsUnrestricted(), "!IsUnrestricted");
        }
        public void CreatePermission_Provider()
        {
            OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert);

            a.Provider = "Mono";
            Assert.AreEqual("Mono", a.Provider, "Mono");

            OleDbPermission odp = (OleDbPermission)a.CreatePermission();

            // provider isn't even supplied to permission in fx 2.0
            Assert.AreEqual(String.Empty, odp.Provider, "CreatePermission.Provider");
        }
        public void Default()
        {
            OleDbPermissionAttribute a = new OleDbPermissionAttribute(SecurityAction.Assert);

            Assert.AreEqual(a.ToString(), a.TypeId.ToString(), "TypeId");
            Assert.IsFalse(a.Unrestricted, "Unrestricted");
            Assert.IsFalse(a.AllowBlankPassword, "AllowBlankPassword");
            Assert.AreEqual(String.Empty, a.ConnectionString, "ConnectionString");
            Assert.AreEqual(KeyRestrictionBehavior.AllowOnly, a.KeyRestrictionBehavior, "KeyRestrictionBehavior");
            Assert.AreEqual(String.Empty, a.KeyRestrictions, "KeyRestrictions");
            Assert.AreEqual(String.Empty, a.Provider, "Provider");
            Assert.IsFalse(a.ShouldSerializeConnectionString(), "ShouldSerializeConnectionString");
            Assert.IsFalse(a.ShouldSerializeKeyRestrictions(), "ShouldSerializeConnectionString");
            OleDbPermission odp = (OleDbPermission)a.CreatePermission();

            Assert.IsFalse(odp.IsUnrestricted(), "IsUnrestricted");
        }