Exemplo n.º 1
0
        public void OpenProject(IProgressMonitor progressMonitor, string projectLocation)
        {
            using (progressMonitor.BeginTask(Resources.ProjectController_Loading_project_file, 100))
            {
                var testProject = new TestProject();

                try
                {
                    testProject = testProjectManager.LoadProject(new FileInfo(projectLocation));
                }
                catch (Exception ex)
                {
                    unhandledExceptionPolicy.Report(Resources.ProjectController_Error_loading_project_file, ex);
                }

                progressMonitor.Worked(50);
                LoadProject(testProject, projectLocation);
            }
        }
Exemplo n.º 2
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);
        }