示例#1
0
        private static WrappedSamplesRunner.RunnerParams CheckIfTestAndCreateParams(Type classType, RunnerSearchConfig searchConfig)
        {
            if (!IsInSearchPath(classType.FullName, searchConfig))
            {
                return(null);
            }
            if (IsIgnoredClassOrPackage(classType.FullName, searchConfig))
            {
                return(null);
            }

            WrappedSamplesRunner.RunnerParams runnerParams = new WrappedSamplesRunner.RunnerParams();
            runnerParams.sampleType = classType;
            Attribute attribute = Attribute.GetCustomAttribute(classType, typeof(WrapToTestAttribute));

            if (attribute == null)
            {
                if (searchConfig.IsToMarkTestsWithoutAnnotationAsIgnored() && IsLookLikeTest(classType))
                {
                    runnerParams.ignoreMessage = String.Format("Class {0} seems to be a test but it doesn't have WrapToTest annotation."
                                                               , classType.FullName);
                    return(runnerParams);
                }
                return(null);
            }
            WrapToTestAttribute wrapToTestAttribute = (WrapToTestAttribute)attribute;

            if (!String.IsNullOrEmpty(wrapToTestAttribute.IgnoreWithMessage))
            {
                runnerParams.ignoreMessage = wrapToTestAttribute.IgnoreWithMessage;
            }
            return(runnerParams);
        }
        protected static ICollection <TestFixtureData> GenerateTestsList(Assembly assembly, RunnerSearchConfig searchConfig)
        {
            IList <TestFixtureData> parametersList = new List <TestFixtureData>();

            foreach (Type type in assembly.GetTypes())
            {
                WrappedSamplesRunner.RunnerParams runnerParams = CheckIfTestAndCreateParams(type, searchConfig);
                if (runnerParams != null && !type.IsNested)
                {
                    parametersList.Add(new TestFixtureData(runnerParams));
                }
            }

            return(parametersList);
        }
        private static WrappedSamplesRunner.RunnerParams CheckIfTestAndCreateParams(Type classType, RunnerSearchConfig searchConfig)
        {
            if (!IsInSearchPath(classType.FullName, searchConfig))
            {
                return(null);
            }
            if (IsIgnoredClassOrPackage(classType, searchConfig))
            {
                return(null);
            }

            WrappedSamplesRunner.RunnerParams runnerParams = new WrappedSamplesRunner.RunnerParams();
            runnerParams.sampleType = classType;

            return(runnerParams);
        }