Exemple #1
0
 private static bool IsIgnoredClassOrPackage(String fullName, RunnerSearchConfig searchConfig)
 {
     foreach (String ignoredPath in searchConfig.GetIgnoredPaths())
     {
         if (fullName.Contains(ignoredPath))
         {
             return(true);
         }
     }
     return(false);
 }
 private static bool IsInSearchPath(String fullName, RunnerSearchConfig searchConfig)
 {
     if (searchConfig.GetSearchClasses().Contains(fullName))
     {
         return(true);
     }
     foreach (String searchPackage in searchConfig.GetSearchPackages())
     {
         if (fullName.StartsWith(searchPackage))
         {
             return(true);
         }
     }
     return(false);
 }
        private static bool IsIgnoredClassOrPackage(String fullName, RunnerSearchConfig searchConfig)
        {
            foreach (String ignoredPath in searchConfig.GetIgnoredPaths())
            {
                String filePath = Path.Combine(TestUtil.GetParentProjectDirectory(TestContext
                                                                                  .CurrentContext.TestDirectory),
                                               ignoredPath.Replace(".", "\\"));

                if ((Directory.Exists(filePath) && fullName.Contains(ignoredPath)) ||
                    (File.Exists(filePath + ".cs") && fullName.Equals(ignoredPath)))
                {
                    return(true);
                }
            }
            return(false);
        }
        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);
        }
Exemple #6
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);
        }