コード例 #1
0
        public void ShouldNotMatchTypeWithNoRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            Assert.IsFalse(ruleSet.Matches(typeof(MockDal)));
            Assert.IsFalse(ruleSet.Matches(typeof(string)));
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        public void ShouldNotMatchWithNoContainedRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

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

            ruleSet.Add(new TypeMatchingAssignmentRule(typeof(MockDal)));
            Assert.IsTrue(ruleSet.Matches(typeof(MockDal)));
        }
コード例 #8
0
        public void ShouldNotMatchWithNoContainedRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

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

            Assert.IsFalse(ruleSet.Matches(member));
        }
コード例 #9
0
        public void ShouldMatchWithMatchingTypeRule()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

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

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