private void testListWorker_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e) { string assemblyPath = currentlyLoadingProject.AssemblyPath; DataTable dataTable = (DataTable)dataGridView1.DataSource; if (loadedTestCases != null) { foreach (string testCase in loadedTestCases) { TestInformation testInformation = new TestInformation(); testInformation.AssemblyPath = assemblyPath; testInformation.TestName = testCase; string[] nameParts = testCase.Split('.'); string testName; string caseName; string testNamespace; if (nameParts.Length > 2) { testName = nameParts[nameParts.Length - 1]; caseName = nameParts[nameParts.Length - 2]; testNamespace = testCase.Substring(0, testCase.Length - (caseName.Length + testName.Length + 2)); } else { testName = nameParts[nameParts.Length - 1]; caseName = nameParts[nameParts.Length - 2]; testNamespace = ""; } if (namespaceComboBox.SelectedIndex != -1 && !testNamespace.Equals(namespaceComboBox.SelectedItem)) { continue; } if (caseComboBox.SelectedIndex != -1 && !caseName.Equals(caseComboBox.SelectedItem)) { continue; } if (!namespaceComboBox.Items.Contains(testNamespace)) { namespaceComboBox.Items.Add(testNamespace); } if (!caseComboBox.Items.Contains(caseName)) { caseComboBox.Items.Add(caseName); } DataRow row = dataTable.Rows.Add(new Object[] { TestState.None, testNamespace, caseName, testName, "", testInformation.FailureMessage, testInformation }); testInformation.DataRow = row; } } dataGridView1.ClearSelection(); if (projectsToLoad.Count > 0&&!testListWorker.IsBusy) { currentlyLoadingProject = projectsToLoad.Dequeue(); testListWorker.RunWorkerAsync(); } }
public void RefreshView() { if (!dataGridView1.Visible) { return; } Trace.TraceInformation("Refreshing NUnit View."); DTE dte = (DTE)Package.GetGlobalService(typeof(DTE)); DataTable table = new DataTable(); table.Columns.Add(new DataColumn("Success", typeof(TestState))); table.Columns.Add(new DataColumn("Namespace", typeof(string))); table.Columns.Add(new DataColumn("Case", typeof(string))); table.Columns.Add(new DataColumn("Test", typeof(string))); table.Columns.Add(new DataColumn("Time", typeof(string))); table.Columns.Add(new DataColumn("Message", typeof(string))); table.Columns.Add(new DataColumn("TestInformation", typeof(TestInformation))); foreach (Project project in dte.Solution) { AddProject(project); } dataGridView1.DataSource = table; if ((projectsToLoad.Count > 0) && !testListWorker.IsBusy) { currentlyLoadingProject = projectsToLoad.Dequeue(); testListWorker.RunWorkerAsync(); } }
private void AddProject(Project project) { try { if (project.Kind.ToUpperInvariant().Equals(SolutionFolderKind)) { AddFolder(project); } if (project.ConfigurationManager == null) { return; } Configuration configuration = project.ConfigurationManager.ActiveConfiguration; if (configuration.IsBuildable) { String localPath = ""; String outputPath = ""; String outputFileName = ""; foreach (Property property in project.Properties) { try { if ("LocalPath".Equals(property.Name)) { localPath = (string)property.Value; } if ("OutputFileName".Equals(property.Name)) { outputFileName = (string)property.Value; } } catch (Exception ex) { Trace.WriteLine(ex); } } foreach (Property property in configuration.Properties) { try { if ("OutputPath".Equals(property.Name)) { outputPath = (string)property.Value; } } catch (Exception ex) { Trace.WriteLine(ex); } } if (!projectComboBox.Items.Contains(project.Name)) { projectComboBox.Items.Add(project.Name); } if (projectComboBox.SelectedIndex != -1 && !project.Name.Equals(projectComboBox.SelectedItem)) { return; } String assemblyPath = localPath + outputPath + outputFileName; if (!assemblyPath.EndsWith(".dll")) { return; } if (File.Exists(assemblyPath)) { ProjectInformation projectInformation = new ProjectInformation(); projectInformation.Name = project.Name; projectInformation.AssemblyPath = assemblyPath; projectsToLoad.Enqueue(projectInformation); } } } catch (Exception ex) { Trace.TraceError("Error refreshing NUnit view: " + ex.ToString()); } }
/// <summary> /// Constructor /// </summary> /// <param name="platformName">the name of the project platform Name</param> public ProjectInformation(string platformName) { this.Platform = ProjectInformation.ParsePlatformName(platformName); }