GetTestMethods() public static method

Selects all test methods in a given type.
public static GetTestMethods ( Type type, bool flattenHierarchy ) : IEnumerable
type System.Type /// The type to inspect. ///
flattenHierarchy bool /// Specifies that tests from parent fixtures should be returned. ///
return IEnumerable
        private static IEnumerable <MethodBase> SelectEmptyTestMethods(Type type)
        {
            var selectEmptyTestMethods =
                from testMethod in TypeInvestigationService.GetTestMethods(type, false)
                where !testMethod.IsAbstract &&
                !TypeInvestigationService.IsExpectedExceptionTestMethod(testMethod) &&
                GetIntermediateLanguageFromMethodInfoBase(testMethod).Count() <= 2
                select testMethod;

            return(selectEmptyTestMethods);
        }
Exemplo n.º 2
0
        private static IEnumerable <MethodBase> SelectExceptionResilientTestMethods(Type type)
        {
            var testMethodsInContext = TypeInvestigationService.GetAllContextSpecificationTypes(type)
                                       .SelectMany(nestedType => TypeInvestigationService.GetTestMethods(nestedType, true));
            var expectedExceptionTestMethodsInContext = TypeInvestigationService.GetTestMethods(type, true)
                                                        .Concat(testMethodsInContext)
                                                        .Where(TypeInvestigationService.IsExpectedExceptionTestMethod)
                                                        .ToArray();

            // If there is any test method marked with ExpectedExceptionAttribute, then all other act as if marked with ExceptionResilientAttribute
            if (expectedExceptionTestMethodsInContext.Any())
            {
                var testMethods = TypeInvestigationService.GetTestMethods(type, false);
                return(testMethods.Except(expectedExceptionTestMethodsInContext).ToArray());
            }

            return(Enumerable.Empty <MethodBase>());
        }
Exemplo n.º 3
0
        private static IEnumerable <MethodBase> SelectTestMethods(Type type)
        {
            var testMethods = TypeInvestigationService.GetTestMethods(type, false);

            return(testMethods.Except(SelectExceptionResilientTestMethods(type)));
        }