/// <summary> /// Called when the command is executed. /// </summary> protected override void OnExecute() { CodeCoverageResults.ClearTreeView(); TestMethodWrapperContainer msTests = null, nUnitTests = null; TestMethodWrapperContainer container = TestExplorer.TestsTreeView.Root as TestMethodWrapperContainer; if (container != null) { if (container.TestType == TestType.MSTest) { msTests = container; } else { nUnitTests = container; } } else { msTests = TestExplorer.TestsTreeView.Root.Children[0] as TestMethodWrapperContainer; nUnitTests = TestExplorer.TestsTreeView.Root.Children[1] as TestMethodWrapperContainer; } var selectedMSTests = msTests != null?msTests.GetSelectedTestGroupsAndTests() : null; var selectedNUnitTests = nUnitTests != null?nUnitTests.GetSelectedTests() : null; _testExecutor = null; SetTestExecutor(selectedMSTests, selectedNUnitTests); if (_testExecutor == null) { MessageBox.Show(ExecuteSelectedTestsCommand.CODE_COVERAGE_SELECT_TESTS_MESSAGE, Resources.MessageBoxTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!_testExecutor.ValidateCommandLineArgumentsLength()) { MessageBox.Show(ExecuteSelectedTestsCommand.CODE_COVERAGE_SELECT_LESS_TESTS_MESSAGE, Resources.MessageBoxTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } // show tool window which shows the progress. ShowCodeCoverageResultsToolWindow(); Enabled = false; _isRunningCodeCoverage = true; _package.VSEventsHandler.BuildDone += RunOpenCover; _package.VSEventsHandler.BuildSolution(); }
internal static TestMethodWrapperContainer GetContainer(this SharpTreeNodeCollection treeNodeCollection, TestType testType) { TestMethodWrapperContainer container = null; foreach (var node in treeNodeCollection) { var testContainer = node as TestMethodWrapperContainer; if (null != testContainer && testContainer.TestType == testType) { container = testContainer; } } return(container); }