Exemple #1
0
        public void ShouldNotMatchTypeWithNoRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            Assert.IsFalse(ruleSet.Matches(typeof(MockDal)));
            Assert.IsFalse(ruleSet.Matches(typeof(string)));
        }
        /// <summary>
        /// Checks if the rules in this policy match the given member info.
        /// </summary>
        /// <param name="member">MemberInfo to check against.</param>
        /// <returns>true if ruleset matches, false if it does not.</returns>
        protected override bool DoesMatch(MethodImplementationInfo member)
        {
            Guard.ArgumentNotNull(member, "member");

            bool matchesInterface = member.InterfaceMethodInfo != null?_ruleSet.Matches(member.InterfaceMethodInfo) : false;

            bool matchesImplementation = _ruleSet.Matches(member.ImplementationMethodInfo);

            return(matchesInterface | matchesImplementation);
        }
        public void ShouldNotMatchWhenOneRuleDoesntMatch()
        {
            MethodBase      member  = GetType().GetMethod("ShouldNotMatchWhenOneRuleDoesntMatch");
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            ruleSet.Add(new TypeMatchingRule(typeof(MatchingRuleSetFixture)));
            Assert.IsTrue(ruleSet.Matches(member));

            ruleSet.Add(new MemberNameMatchingRule("ThisMethodDoesntExist"));
            Assert.IsFalse(ruleSet.Matches(member));
        }
        public void ShouldNotMatchWhenOneRuleDoesntMatch()
        {
            MethodBase member = GetType().GetMethod("ShouldNotMatchWhenOneRuleDoesntMatch");
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            ruleSet.Add(new TypeMatchingRule(typeof(MatchingRuleSetFixture)));
            Assert.IsTrue(ruleSet.Matches(member));

            ruleSet.Add(new MemberNameMatchingRule("ThisMethodDoesntExist"));
            Assert.IsFalse(ruleSet.Matches(member));
        }
        public void ShouldNotMatchWithNoContainedRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            MethodBase member = GetType().GetMethod("ShouldNotMatchWithNoContainedRules");
            Assert.IsFalse(ruleSet.Matches(member));
        }
 public void ShouldMatchWithMatchingTypeRule()
 {
     MatchingRuleSet ruleSet = new MatchingRuleSet();
     ruleSet.Add(new TypeMatchingRule(typeof(MatchingRuleSetFixture)));
     MethodBase member = GetType().GetMethod("ShouldMatchWithMatchingTypeRule");
     Assert.IsTrue(ruleSet.Matches(member));
 }
Exemple #7
0
        public void ShouldMatchTypeWithTypeMatchRule()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            ruleSet.Add(new TypeMatchingAssignmentRule(typeof(MockDal)));
            Assert.IsTrue(ruleSet.Matches(typeof(MockDal)));
        }
        public void ShouldNotMatchWithNoContainedRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            MethodBase member = GetType().GetMethod("ShouldNotMatchWithNoContainedRules");

            Assert.IsFalse(ruleSet.Matches(member));
        }
        public void ShouldMatchWithMatchingTypeRule()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            ruleSet.Add(new TypeMatchingRule(typeof(MatchingRuleSetFixture)));
            MethodBase member = GetType().GetMethod("ShouldMatchWithMatchingTypeRule");

            Assert.IsTrue(ruleSet.Matches(member));
        }