Пример #1
0
        /// <summary>
        /// Copies the contents of a test project.
        /// </summary>
        /// <param name="source">The source test project.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is null.</exception>
        public TestProjectData(TestProject source)
            : this()
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            testPackage = new TestPackageData(source.TestPackage);
            GenericCollectionUtils.ConvertAndAddAll(source.TestFilters, testFilters, x => x.Copy());
            testRunnerExtensions.AddRange(source.TestRunnerExtensionSpecifications);
            reportNameFormat = source.ReportNameFormat;
            reportDirectory  = source.ReportDirectory;
        }
Пример #2
0
        /// <summary>
        /// Copies the contents of a test package.
        /// </summary>
        /// <param name="source">The source test package.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is null.</exception>
        public TestPackageData(TestPackage source)
            : this()
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            GenericCollectionUtils.ConvertAndAddAll(source.HintDirectories, hintDirectories, directory => directory.FullName);
            GenericCollectionUtils.ConvertAndAddAll(source.Files, files, file => file.FullName);
            excludedFrameworkIds.AddRange(source.ExcludedTestFrameworkIds);
            ShadowCopy = source.ShadowCopy;
            Debug      = source.DebuggerSetup != null;
            ApplicationBaseDirectory = source.ApplicationBaseDirectory != null ? source.ApplicationBaseDirectory.FullName : null;
            WorkingDirectory         = source.WorkingDirectory != null ? source.WorkingDirectory.FullName : null;
            RuntimeVersion           = source.RuntimeVersion;
            properties = source.Properties.Copy();
        }
Пример #3
0
        /// <summary>
        /// Creates a copy of the test project.
        /// </summary>
        /// <returns>The new copy.</returns>
        public TestProject Copy()
        {
            var copy = new TestProject()
            {
                testRunnerFactoryName            = testRunnerFactoryName,
                isTestRunnerFactoryNameSpecified = isTestRunnerFactoryNameSpecified,
                reportDirectory             = reportDirectory,
                IsReportDirectorySpecified  = IsReportDirectorySpecified,
                reportNameFormat            = reportNameFormat,
                isReportNameFormatSpecified = isReportNameFormatSpecified,
                testPackage   = testPackage.Copy(),
                ReportArchive = ReportArchive
            };

            GenericCollectionUtils.ConvertAndAddAll(testFilters, copy.testFilters, x => x.Copy());
            copy.testRunnerExtensions.AddRange(testRunnerExtensions);
            copy.testRunnerExtensionSpecifications.AddRange(testRunnerExtensionSpecifications);
            return(copy);
        }
Пример #4
0
        /// <summary>
        /// Copies the contents of a test.
        /// </summary>
        /// <param name="source">The source test.</param>
        /// <param name="nonRecursive">If true, does not recursively populate the children of the test.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="source"/> is null.</exception>
        public TestData(Test source, bool nonRecursive)
            : base(source)
        {
            fullName   = source.FullName;
            isTestCase = source.IsTestCase;

            children   = new List <TestData>();
            parameters = new List <TestParameterData>();

            if (!nonRecursive)
            {
                GenericCollectionUtils.ConvertAndAddAll(source.Children, children, delegate(Test child)
                {
                    return(new TestData(child));
                });
            }

            GenericCollectionUtils.ConvertAndAddAll(source.Parameters, parameters, delegate(TestParameter parameter)
            {
                return(new TestParameterData(parameter));
            });
        }
Пример #5
0
        /// <summary>
        /// Processes test file patterns and generates a consolidated test project.
        /// </summary>
        private TestProject ConsolidateTestProject(ITestProjectManager testProjectManager, ref bool canceled)
        {
            TestProject consolidatedTestProject = null;

            RunWithProgress(delegate(IProgressMonitor progressMonitor)
            {
                List <string> allFilePatterns = new List <string>(filePatterns);
                GenericCollectionUtils.ConvertAndAddAll(testProject.TestPackage.Files, allFilePatterns, x => x.ToString());

                TestProject overlayTestProject = testProject.Copy();
                overlayTestProject.TestPackage.ClearFiles();
                TestProject baseTestProject = null;

                bool haveProject = false;
                using (progressMonitor.BeginTask("Verifying test files.", Math.Max(allFilePatterns.Count, 1)))
                {
                    foreach (string filePattern in allFilePatterns)
                    {
                        IList <FileInfo> files = ExpandFilePattern(filePattern);
                        if (files == null)
                        {
                            return;
                        }

                        foreach (FileInfo file in files)
                        {
                            bool isProject = file.Extension == TestProject.Extension;
                            if (isProject && overlayTestProject.TestPackage.Files.Count != 0 || haveProject)
                            {
                                logger.Log(LogSeverity.Error, "At most one test project can be specified at a time and it cannot be combined with other test files.");
                                return;
                            }

                            if (isProject)
                            {
                                haveProject = true;

                                try
                                {
                                    baseTestProject = testProjectManager.LoadProject(file);
                                }
                                catch (Exception ex)
                                {
                                    logger.Log(LogSeverity.Error, string.Format("Could not load test project '{0}'.", file.FullName), ex);
                                }
                            }
                            else
                            {
                                overlayTestProject.TestPackage.AddFile(file);
                            }
                        }

                        progressMonitor.Worked(1);
                    }

                    if (baseTestProject != null)
                    {
                        baseTestProject.ApplyOverlay(overlayTestProject);
                        consolidatedTestProject = baseTestProject;
                    }
                    else
                    {
                        consolidatedTestProject = overlayTestProject;
                    }
                }
            }, ref canceled);

            return(consolidatedTestProject);
        }