Пример #1
0
        public void RuleDeniesMatchWhenTagTextDoesNotCorrespond()
        {
            MethodInfo method             = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("WhichTag?");

            Assert.IsFalse(rule.Matches(method));
        }
Пример #2
0
        public void RuleCanMatchCaseInsensitive()
        {
            MethodInfo method             = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("taGGed", true);

            Assert.IsTrue(rule.Matches(method));
        }
Пример #3
0
        public void RuleCanMatchesCaseSensitiveByDefault()
        {
            MethodInfo method             = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("taGGed");

            Assert.IsFalse(rule.Matches(method));
        }
Пример #4
0
        public void ShouldMatchRuleForTaggedProperty()
        {
            MethodInfo method             = typeof(AnnotatedWithTags).GetProperty("Name").GetGetMethod();
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsTrue(rule.Matches(method));
        }
Пример #5
0
        public void RuleMatchesWhenTagMatches()
        {
            MethodInfo method             = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsTrue(rule.Matches(method));
        }
        public void RuleDeniesMatchWhenTagTextDoesNotCorrespond()
        {
            MethodInfo method = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("WhichTag?");

            Assert.IsFalse(rule.Matches(method));
        }
        public void RuleMatchesWhenTagMatches()
        {
            MethodInfo method = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsTrue(rule.Matches(method));
        }
        public void RuleDeniesMatchWhenTagAttributeIsNotDeclared()
        {
            MethodInfo method = typeof(AnnotatedWithTags).GetMethod("NotTagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsFalse(rule.Matches(method));
        }
        public void RuleCanMatchesCaseSensitiveByDefault()
        {
            MethodInfo method = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("taGGed");

            Assert.IsFalse(rule.Matches(method));
        }
        public void RuleCanMatchCaseInsensitive()
        {
            MethodInfo method = typeof(AnnotatedWithTags).GetMethod("Tagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("taGGed", true);

            Assert.IsTrue(rule.Matches(method));
        }
Пример #11
0
        public void RuleDeniesMatchWhenTagAttributeIsNotDeclared()
        {
            MethodInfo method             = typeof(AnnotatedWithTags).GetMethod("NotTagged");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsFalse(rule.Matches(method));
        }
Пример #12
0
        /// <summary>
        /// Builds an instance of the subtype of IMatchingRule type the receiver knows how to build, based on
        /// a configuration object.
        /// </summary>
        /// <param name="context">The <see cref="IBuilderContext"/> that represents the current building process.</param>
        /// <param name="objectConfiguration">The configuration object that describes the object to build.</param>
        /// <param name="configurationSource">The source for configuration objects.</param>
        /// <param name="reflectionCache">The cache to use for retrieving reflection information.</param>
        /// <returns>A fully initialized instance of the IMatchingRule subtype.</returns>
        public IMatchingRule Assemble(IBuilderContext context, MatchingRuleData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            TagAttributeMatchingRuleData castedRuleData = (TagAttributeMatchingRuleData)objectConfiguration;

            TagAttributeMatchingRule matchingRule = new TagAttributeMatchingRule(castedRuleData.Match, castedRuleData.IgnoreCase);

            return(matchingRule);
        }
 public void ShouldMatchForMethodWhenTagIsOnInterface()
 {
     MethodInfo createMethod = typeof(DaoImpl).GetMethod("Create");
     MethodInfo interfaceMethod = typeof(IDao).GetMethod("Create");
     TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tag on interface", true);
     Assert.IsFalse(rule.Matches(createMethod));
     Assert.IsTrue(rule.Matches(interfaceMethod));
 }
Пример #14
0
        public void ShouldMatchForMethodWhenTagIsOnInterface()
        {
            MethodInfo createMethod       = typeof(DaoImpl).GetMethod("Create");
            MethodInfo interfaceMethod    = typeof(IDao).GetMethod("Create");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tag on interface", true);

            Assert.IsFalse(rule.Matches(createMethod));
            Assert.IsTrue(rule.Matches(interfaceMethod));
        }
        public void ShouldMatchRuleForTaggedClass()
        {
            MethodInfo method1 = typeof(AnnotatedWithTagsOnClass).GetMethod("Method1");
            MethodInfo method2 = typeof(AnnotatedWithTagsOnClass).GetMethod("Method2");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsTrue(rule.Matches(method1));
            Assert.IsTrue(rule.Matches(method2));
        }
Пример #16
0
        public void ShouldMatchRuleForTaggedClass()
        {
            MethodInfo method1            = typeof(AnnotatedWithTagsOnClass).GetMethod("Method1");
            MethodInfo method2            = typeof(AnnotatedWithTagsOnClass).GetMethod("Method2");
            TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");

            Assert.IsTrue(rule.Matches(method1));
            Assert.IsTrue(rule.Matches(method2));
        }
Пример #17
0
        private void AddOverloadsPolicy(PolicyInjector factory)
        {
            RuleDrivenPolicy         policy  = new RuleDrivenPolicy("NullStringPolicy");
            TagAttributeMatchingRule tagRule = new TagAttributeMatchingRule("NullString");

            policy.RuleSet.Add(tagRule);

            policy.Handlers.Add(new MakeReturnNullHandler());

            factory.Policies.Add(policy);
        }
 public void ShouldMatchRuleForTaggedProperty()
 {
     MethodInfo method = typeof(AnnotatedWithTags).GetProperty("Name").GetGetMethod();
     TagAttributeMatchingRule rule = new TagAttributeMatchingRule("Tagged");
     Assert.IsTrue(rule.Matches(method));
 }