internal void PopulateWithHeader(HierarchyItem headerUnderTest) { functionsTree.Nodes.Clear(); ProjectItem projectItem = headerUnderTest.GetExtObjectAs <ProjectItem>(); VCFileCodeModel codeModel = projectItem.FileCodeModel as VCFileCodeModel; PopulateRecursively(functionsTree.Nodes, codeModel.CodeElements); functionsTree.ExpandAll(); }
// ------------------------------------------------------ /// <summary> /// Called to update the status of the "Generate New Suite" command /// before it is displayed. /// </summary> /// <param name="sender"> /// The sender of the event. /// </param> /// <param name="e"> /// An <code>EventArgs</code> object. /// </param> private void GenerateTests_BeforeQueryStatus(object sender, EventArgs e) { OleMenuCommand command = (OleMenuCommand)sender; HierarchyItem[] selection = VsShellUtils.GetCurrentSelection(this); // Don't support test generation if more than one file is // selected. if (selection.Length > 1) { command.Supported = false; return; } ProjectItem item = selection[0].GetExtObjectAs <ProjectItem>(); if (item == null) { command.Supported = false; return; } VCFileCodeModel codeModel = (VCFileCodeModel)item.FileCodeModel; // Don't support test generation if the file contains unit tests // already. if (codeModel == null) { command.Supported = false; return; } else { foreach (VCCodeClass klass in codeModel.Classes) { if (klass.Bases.Count > 0 && Constants.CxxTestSuiteClassRegex.IsMatch( klass.Bases.Item(1).Name)) { command.Supported = false; return; } } } command.Supported = true; }