private static void MenuItemCallback(object sender, EventArgs e) { RunTestsMenuCommand command = (RunTestsMenuCommand)sender; UIHierarchy uih = command.Dte2.ToolWindows.SolutionExplorer; Array selectedItems = (Array)uih.SelectedItems; UIHierarchyItem selectedItem = selectedItems.GetValue(0) as UIHierarchyItem; Solution solution = command.Dte2.Solution; Solution selectedSolution = selectedItem.Object as Solution; if (LaunchCommand.Instance.Launcher.BuildBeforeLaunch) { solution.SolutionBuild.Build(true); } if (selectedSolution != null) { //System.Diagnostics.Debug.WriteLine("RunTestsMenuCommand.MenuItemCallback() running all test projects for the solution"); foreach (Project p in selectedSolution.Projects) { if (RunTestsMenu.IsTestProject(p)) { RunTestProject(p, solution); } } return; } Project project = selectedItem.Object as Project; if (project != null) { //System.Diagnostics.Debug.WriteLine("RunTestsMenuCommand.MenuItemCallback() running a single test project"); RunTestProject(project, solution); } }
private void OnBeforeQueryStatus(object sender, EventArgs e) { var myCommand = sender as OleMenuCommand; if (null != myCommand) { UIHierarchy uih = Dte2.ToolWindows.SolutionExplorer; Array selectedItems = (Array)uih.SelectedItems; UIHierarchyItem selectedItem = selectedItems.GetValue(0) as UIHierarchyItem; Solution sol = selectedItem.Object as Solution; if (sol != null && RunTestsMenu.HasTestProjects(sol)) { myCommand.Visible = true; return; } Project prj = selectedItem.Object as Project; if (prj == null || !RunTestsMenu.IsTestProject(prj)) { myCommand.Visible = false; return; } myCommand.Visible = true; } }