public void CustomAttributeRuleDoesNotSearchInheritanceChainWhenInheritedIsFalse()
        {
            MethodInfo method = typeof(DerivedObject).GetMethod("MethodWithAttribute");
            CustomAttributeMatchingRule rule = new CustomAttributeMatchingRule(typeof(RandomAttribute), false);

            Assert.IsFalse(rule.Matches(method));
        }
        public void CustomAttributeRuleDeniesMatchWhenNoAttributeFound()
        {
            MethodInfo method = typeof(TestObject).GetMethod("MethodWithoutAttribute");
            CustomAttributeMatchingRule rule = new CustomAttributeMatchingRule(typeof(RandomAttribute), false);

            Assert.IsFalse(rule.Matches(method));
        }
        public void CustomAttributeRuleMatchesWhenAttributeFuond()
        {
            MethodInfo method = typeof(TestObject).GetMethod("MethodWithAttribute");
            CustomAttributeMatchingRule rule = new CustomAttributeMatchingRule(typeof(RandomAttribute), false);

            Assert.IsTrue(rule.Matches(method));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Builds an instance of the subtype of <typeparamref name="TObject"/> 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 retrieving reflection information.</param>
        /// <returns>A fully initialized instance of the <typeparamref name="TObject"/> subtype.</returns>
        public IMatchingRule Assemble(IBuilderContext context, MatchingRuleData objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
        {
            CustomAttributeMatchingRuleData castedRuleData = (CustomAttributeMatchingRuleData)objectConfiguration;

            CustomAttributeMatchingRule matchingRule = new CustomAttributeMatchingRule(castedRuleData.AttributeType, castedRuleData.SearchInheritanceChain);

            return(matchingRule);
        }
 public void CustomAttributeRuleDoesNotSearchInheritanceChainWhenInheritedIsFalse()
 {
     MethodInfo method = typeof(DerivedObject).GetMethod("MethodWithAttribute");
     CustomAttributeMatchingRule rule = new CustomAttributeMatchingRule(typeof(RandomAttribute), false);
     Assert.IsFalse(rule.Matches(method));
 }
 public void CustomAttributeRuleDeniesMatchWhenNoAttributeFound()
 {
     MethodInfo method = typeof(TestObject).GetMethod("MethodWithoutAttribute");
     CustomAttributeMatchingRule rule = new CustomAttributeMatchingRule(typeof(RandomAttribute), false);
     Assert.IsFalse(rule.Matches(method));
 }
 public void CustomAttributeRuleMatchesWhenAttributeFuond()
 {
     MethodInfo method = typeof(TestObject).GetMethod("MethodWithAttribute");
     CustomAttributeMatchingRule rule = new CustomAttributeMatchingRule(typeof(RandomAttribute), false);
     Assert.IsTrue(rule.Matches(method));
 }