private static bool HasCodeElementWithPattern <T>(IPatternEvaluator evaluator, IEnumerable <T> elements)
     where T : ICodeElementInfo
 {
     foreach (T element in elements)
     {
         if (evaluator.HasPatterns(element))
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Infers whether the type is a test type based on its structure.
        /// </summary>
        /// <remarks>
        /// <para>
        /// Returns true if the type any associated patterns, if it has
        /// non-nested type members (subject to <see cref="GetMemberBindingFlags" />)
        /// with patterns, if it has generic parameters with patterns, or if any
        /// of its nested types satisfy the preceding rules.
        /// </para>
        /// </remarks>
        /// <param name="evaluator">The pattern evaluator.</param>
        /// <param name="type">The type.</param>
        /// <returns>True if the type is likely a test type.</returns>
        protected virtual bool InferTestType(IPatternEvaluator evaluator, ITypeInfo type)
        {
            if (evaluator.HasPatterns(type))
            {
                return(true);
            }

            BindingFlags bindingFlags = GetMemberBindingFlags(type);

            if (HasCodeElementWithPattern(evaluator, type.GetMethods(bindingFlags)) ||
                HasCodeElementWithPattern(evaluator, type.GetProperties(bindingFlags)) ||
                HasCodeElementWithPattern(evaluator, type.GetFields(bindingFlags)) ||
                HasCodeElementWithPattern(evaluator, type.GetEvents(bindingFlags)))
            {
                return(true);
            }

            if (type.IsGenericTypeDefinition && HasCodeElementWithPattern(evaluator, type.GenericArguments))
            {
                return(true);
            }

            if (ShouldConsumeConstructors(type) &&
                HasCodeElementWithPattern(evaluator, type.GetConstructors(ConstructorBindingFlags)))
            {
                return(true);
            }

            foreach (ITypeInfo nestedType in type.GetNestedTypes(NestedTypeBindingFlags))
            {
                if (InferTestType(evaluator, nestedType))
                {
                    return(true);
                }
            }

            return(false);
        }
 private bool IsTestPart(IPatternEvaluator evaluator, ICodeElementInfo codeElement)
 {
     return evaluator.HasPatterns(codeElement);
 }
 private bool IsTestPart(IPatternEvaluator evaluator, ICodeElementInfo codeElement)
 {
     return(evaluator.HasPatterns(codeElement));
 }