Пример #1
0
        public void ShouldNotMatchWithNoContainedRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            MethodBase member = GetType().GetMethod("ShouldNotMatchWithNoContainedRules");
            Assert.IsFalse(ruleSet.Matches(member));
        }
Пример #2
0
 public void ShouldMatchWithMatchingTypeRule()
 {
     MatchingRuleSet ruleSet = new MatchingRuleSet();
     ruleSet.Add(new TypeMatchingRule(typeof(MatchingRuleSetFixture)));
     MethodBase member = GetType().GetMethod("ShouldMatchWithMatchingTypeRule");
     Assert.IsTrue(ruleSet.Matches(member));
 }
Пример #3
0
        public void ShouldMatchTypeWithTypeMatchRule()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            ruleSet.Add(new TypeMatchingAssignmentRule(typeof(MockDal)));
            Assert.IsTrue(ruleSet.Matches(typeof(MockDal)));
        }
Пример #4
0
        public void ShouldNotMatchTypeWithNoRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

            Assert.IsFalse(ruleSet.Matches(typeof(MockDal)));
            Assert.IsFalse(ruleSet.Matches(typeof(string)));
        }
Пример #5
0
        public void ShouldNotMatchWithNoContainedRules()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

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

            Assert.IsFalse(ruleSet.Matches(member));
        }
Пример #6
0
        /// <summary>
        /// Creates a new <see cref="RuleDrivenPolicy"/> object with a name, a set of matching rules
        /// and the names to use when resolving handlers.
        /// </summary>
        public RuleDrivenPolicy(string name, IMatchingRule[] matchingRules, string[] callHandlerNames)
            : base(name)
        {
            this.ruleSet = new MatchingRuleSet();
            this.ruleSet.AddRange(matchingRules);

            this.callHandlerNames = callHandlerNames;
        }
Пример #7
0
        /// <summary>
        /// Creates a new <see cref="RuleDrivenPolicy"/> object with a name, a set of matching rules
        /// and the names to use when resolving handlers.
        /// </summary>
        public RuleDrivenPolicy(string name, IMatchingRule[] matchingRules, string[] callHandlerNames)
            : base(name)
        {
            _ruleSet = new MatchingRuleSet();
            _ruleSet.AddRange(matchingRules);

            _callHandlerNames = callHandlerNames;
        }
Пример #8
0
        public void ShouldMatchWithMatchingTypeRule()
        {
            MatchingRuleSet ruleSet = new MatchingRuleSet();

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

            Assert.IsTrue(ruleSet.Matches(member));
        }
Пример #9
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));
        }
Пример #10
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));
        }