Example #1
0
        public void ResolveMatchingCodeGroups_OneLevel()
        {
            UnionCodeGroup level1 = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(new PermissionSet(PermissionState.None)));
            CodeGroup      match  = level1.ResolveMatchingCodeGroups(new Evidence());

            Assert.IsNotNull(match, "Match");
            Assert.IsTrue(match.Equals(level1, false), "Equals(false)");
            Assert.IsTrue(match.Equals(level1, true), "Equals(true)");
        }
Example #2
0
        public void ResolveMatchingCodeGroups_OneLevel()
        {
            FileCodeGroup level1 = new FileCodeGroup(new AllMembershipCondition(), FileIOPermissionAccess.AllAccess);
            CodeGroup     match  = level1.ResolveMatchingCodeGroups(new Evidence());

            Assert.IsNotNull(match, "Match");
            Assert.IsTrue(match.Equals(level1, false), "Equals(false)");
            Assert.IsTrue(match.Equals(level1, true), "Equals(true)");
        }
Example #3
0
        public void ResolveMatchingCodeGroups_ThreeLevel()
        {
            UnionCodeGroup level1 = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(new PermissionSet(PermissionState.None)));
            CodeGroup      level2 = level1.Copy();

            level1.AddChild(level2);
            UnionCodeGroup level3 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Untrusted), new PolicyStatement(new PermissionSet(PermissionState.Unrestricted)));

            level2.AddChild(level3);

            CodeGroup match = level1.ResolveMatchingCodeGroups(new Evidence());

            Assert.IsNotNull(match, "Match");
            Assert.IsTrue(match.Equals(level1, false), "Equals(false)");
            // Equals (true) isn't a deep compare (just one level)
            Assert.IsTrue(match.Equals(level1, true), "Equals(true)");
        }
Example #4
0
        public void ResolveMatchingCodeGroups_ThreeLevel()
        {
            FileCodeGroup level1 = new FileCodeGroup(new AllMembershipCondition(), FileIOPermissionAccess.AllAccess);
            CodeGroup     level2 = level1.Copy();

            level1.AddChild(level2);
            FileCodeGroup level3 = new FileCodeGroup(new ZoneMembershipCondition(SecurityZone.Untrusted), FileIOPermissionAccess.AllAccess);

            level2.AddChild(level3);

            CodeGroup match = level1.ResolveMatchingCodeGroups(new Evidence());

            Assert.IsNotNull(match, "Match");
            Assert.IsTrue(match.Equals(level1, false), "Equals(false)");
            // Equals (true) isn't a deep compare (just one level)
            Assert.IsTrue(match.Equals(level1, true), "Equals(true)");
        }
Example #5
0
        public void ResolveMatchingCodeGroups_TwoLevel()
        {
            FileCodeGroup level1 = new FileCodeGroup(new AllMembershipCondition(), FileIOPermissionAccess.AllAccess);
            CodeGroup     level2 = level1.Copy();

            level1.AddChild(level2);

            CodeGroup match = level1.ResolveMatchingCodeGroups(new Evidence());

            Assert.IsNotNull(match, "Match");
            Assert.IsTrue(match.Equals(level1, false), "Equals(false)");
            Assert.IsTrue(match.Equals(level1, true), "Equals(true)");

            FileCodeGroup level2b = new FileCodeGroup(new ZoneMembershipCondition(SecurityZone.Untrusted), FileIOPermissionAccess.AllAccess);

            level1.AddChild(level2b);
            CodeGroup match2 = level1.ResolveMatchingCodeGroups(new Evidence());

            Assert.IsNotNull(match2, "Match2");
            Assert.IsTrue(match2.Equals(level1, false), "Equals(false)");
            Assert.IsTrue(!match2.Equals(level1, true), "Equals(true)");
        }
        public override bool Equals(Object o)
        {
            if (m_cg != null)
            {
                return(m_cg.Equals(o));
            }

            if (o is CSingleCodeGroup)
            {
                return(m_scg == o);
            }

            return(base.Equals(o));
        }// Equals