void UpdateTextEditor(CodeCoverageTreeNode node) { CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode; CodeCoverageMethodTreeNode methodNode = node as CodeCoverageMethodTreeNode; CodeCoveragePropertyTreeNode propertyNode = node as CodeCoveragePropertyTreeNode; if (classNode != null && classNode.Nodes.Count > 0) { propertyNode = classNode.Nodes[0] as CodeCoveragePropertyTreeNode; methodNode = classNode.Nodes[0] as CodeCoverageMethodTreeNode; } if (propertyNode != null && propertyNode.Nodes.Count > 0) { methodNode = propertyNode.Nodes[0] as CodeCoverageMethodTreeNode; } if (methodNode != null && methodNode.Method.SequencePoints.Count > 0) { CodeCoverageSequencePoint sequencePoint = methodNode.Method.SequencePoints[0]; if (sequencePoint.HasDocument()) { if (classNode == null) { OpenFile(sequencePoint.Document, sequencePoint.Line, sequencePoint.Column); } else { OpenFile(sequencePoint.Document, 1, 1); } } } }
public void Init() { List<CodeCoverageModule> modules = new List<CodeCoverageModule>(); CodeCoverageModule fooModule = new CodeCoverageModule("Foo.Tests"); CodeCoverageMethod fooTestMethod = new CodeCoverageMethod("FooTest", "Foo.Tests.FooTestFixture"); fooTestMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTestFixture.cs", 0, 1, 0, 2, 1, 1)); fooTestMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTestFixture.cs", 0, 2, 2, 3, 4, 1)); fooModule.Methods.Add(fooTestMethod); modules.Add(fooModule); using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) { treeView.AddModules(modules); nodes = treeView.Nodes; } fooModuleNode = (CodeCoverageModuleTreeNode)nodes[0]; fooModuleNode.Expanding(); fooNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooModuleNode.Nodes[0]; fooNamespaceTreeNode.Expanding(); fooTestsNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooNamespaceTreeNode.Nodes[0]; fooTestsNamespaceTreeNode.Expanding(); fooTestFixtureTreeNode = (CodeCoverageClassTreeNode)fooTestsNamespaceTreeNode.Nodes[0]; fooTestFixtureTreeNode.Expanding(); fooTestMethodTreeNode = (CodeCoverageMethodTreeNode)fooTestFixtureTreeNode.Nodes[0]; }
void AddClassTreeNode(CodeCoverageClassTreeNode node) { foreach (CodeCoverageTreeNode childNode in node.Nodes) { CodeCoverageMethodTreeNode method = childNode as CodeCoverageMethodTreeNode; CodeCoveragePropertyTreeNode property = childNode as CodeCoveragePropertyTreeNode; if (method != null) { AddSequencePoints(method.Method.SequencePoints); } else { AddPropertyTreeNode(property); } } }
protected override void Initialize() { Nodes.Clear(); foreach (string namespaceName in module.RootNamespaces) { CodeCoverageNamespaceTreeNode node = new CodeCoverageNamespaceTreeNode(namespaceName, CodeCoverageMethod.GetAllMethods(module.Methods, namespaceName)); node.AddTo(this); } // Add any classes that have no namespace. foreach (string className in CodeCoverageMethod.GetClassNames(module.Methods, String.Empty)) { CodeCoverageClassTreeNode classNode = new CodeCoverageClassTreeNode(className, CodeCoverageMethod.GetMethods(module.Methods, String.Empty, className)); classNode.AddTo(this); } // Sort these nodes. SortChildNodes(); }
public void SetUpFixture() { List<CodeCoverageModule> modules = new List<CodeCoverageModule>(); CodeCoverageModule fooModule = new CodeCoverageModule("Tests"); XElement setterMethod = CreateSetterElement("Tests.FooTest", "Count"); fooSetterMethod = new CodeCoverageMethod("Tests.FooTest", setterMethod); fooSetterMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTest.cs", 1, 2, 2, 3, 4, 2)); fooSetterMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTest.cs", 0, 3, 4, 4, 4, 1)); XElement getterMethod = CreateGetterElement("Tests.FooTest", "Count"); fooGetterMethod = new CodeCoverageMethod("Tests.FooTest", getterMethod); fooGetterMethod.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTest.cs", 1, 1, 0, 2, 1, 1)); fooModule.Methods.Add(fooGetterMethod); fooModule.Methods.Add(fooSetterMethod); modules.Add(fooModule); using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) { treeView.AddModules(modules); fooModuleNode = (CodeCoverageModuleTreeNode)treeView.Nodes[0]; } fooModuleNode.Expanding(); fooTestsNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooModuleNode.Nodes[0]; fooTestsNamespaceTreeNode.Expanding(); fooTestTreeNode = (CodeCoverageClassTreeNode)fooTestsNamespaceTreeNode.Nodes[0]; fooTestTreeNode.Expanding(); if (fooTestTreeNode.Nodes.Count > 0) { countPropertyTreeNode = fooTestTreeNode.Nodes[0] as CodeCoveragePropertyTreeNode; } countPropertyTreeNode.Expanding(); if (countPropertyTreeNode != null && countPropertyTreeNode.Nodes.Count > 1) { fooGetterTreeNode = (CodeCoverageMethodTreeNode)countPropertyTreeNode.Nodes[0]; fooSetterTreeNode = (CodeCoverageMethodTreeNode)countPropertyTreeNode.Nodes[1]; } }
public void SetUpFixture() { List<CodeCoverageModule> modules = new List<CodeCoverageModule>(); CodeCoverageModule fooModule = new CodeCoverageModule("Foo.Tests"); CodeCoverageMethod fooTestMethod1 = new CodeCoverageMethod("FooTest1", "Foo.Tests.FooTestFixture"); fooTestMethod1.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTestFixture.cs", 1, 1, 0, 2, 1)); fooTestMethod1.SequencePoints.Add(new CodeCoverageSequencePoint("c:\\Projects\\Foo\\FooTestFixture.cs", 0, 2, 2, 3, 4)); CodeCoverageMethod fooTestMethod2 = new CodeCoverageMethod("FooTest2", "Foo.Tests.FooTestFixture"); CodeCoverageMethod helperMethod = new CodeCoverageMethod("GetCoverageFile", "Foo.Tests.Util.Helper"); fooModule.Methods.Add(fooTestMethod1); fooModule.Methods.Add(fooTestMethod2); fooModule.Methods.Add(helperMethod); CodeCoverageModule barModule = new CodeCoverageModule("Bar.Tests"); modules.Add(barModule); modules.Add(fooModule); using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) { treeView.AddModules(modules); nodes = treeView.Nodes; } barModuleNode = (CodeCoverageModuleTreeNode)nodes[0]; fooModuleNode = (CodeCoverageModuleTreeNode)nodes[1]; fooModuleNode.Expanding(); fooNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooModuleNode.Nodes[0]; fooNamespaceTreeNode.Expanding(); fooTestsNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooNamespaceTreeNode.Nodes[0]; fooTestsNamespaceTreeNode.Expanding(); fooTestsUtilNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooTestsNamespaceTreeNode.Nodes[0]; fooTestFixtureTreeNode = (CodeCoverageClassTreeNode)fooTestsNamespaceTreeNode.Nodes[1]; fooTestFixtureTreeNode.Expanding(); fooTestMethod1TreeNode = (CodeCoverageMethodTreeNode)fooTestFixtureTreeNode.Nodes[0]; fooTestMethod2TreeNode = (CodeCoverageMethodTreeNode)fooTestFixtureTreeNode.Nodes[1]; }
protected override void Initialize() { Nodes.Clear(); // Add namespace nodes. string fullNamespace = CodeCoverageMethod.GetFullNamespace(namespacePrefix, Name); foreach (string namespaceName in CodeCoverageMethod.GetChildNamespaces(Methods, fullNamespace)) { string childFullNamespace = CodeCoverageMethod.GetFullNamespace(fullNamespace, namespaceName); CodeCoverageNamespaceTreeNode node = new CodeCoverageNamespaceTreeNode(fullNamespace, namespaceName, CodeCoverageMethod.GetAllMethods(Methods, childFullNamespace)); node.AddTo(this); } // Add class nodes for this namespace. foreach (string className in CodeCoverageMethod.GetClassNames(Methods, fullNamespace)) { CodeCoverageClassTreeNode classNode = new CodeCoverageClassTreeNode(className, CodeCoverageMethod.GetMethods(Methods, fullNamespace, className)); classNode.AddTo(this); } // Sort nodes added. SortChildNodes(); }
void UpdateTextEditor(CodeCoverageTreeNode node) { CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode; CodeCoverageMethodTreeNode methodNode = node as CodeCoverageMethodTreeNode; if (classNode != null && classNode.Nodes.Count > 0) { methodNode = (CodeCoverageMethodTreeNode)classNode.Nodes[0]; } if (methodNode != null && methodNode.Method.SequencePoints.Count > 0) { CodeCoverageSequencePoint sequencePoint = methodNode.Method.SequencePoints[0]; if (classNode == null) { OpenFile(sequencePoint.Document, sequencePoint.Line - 1, sequencePoint.Column - 1); } else { OpenFile(sequencePoint.Document, 1, 1); } } }
void UpdateListView(CodeCoverageTreeNode node) { listView.BeginUpdate(); try { listView.Items.Clear(); CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode; CodeCoverageMethodTreeNode methodNode = node as CodeCoverageMethodTreeNode; CodeCoveragePropertyTreeNode propertyNode = node as CodeCoveragePropertyTreeNode; if (classNode != null) { AddClassTreeNode(classNode); } else if (methodNode != null) { AddSequencePoints(methodNode.Method.SequencePoints); } else if (propertyNode != null) { AddPropertyTreeNode(propertyNode); } } finally { listView.EndUpdate(); } }
public void ClassAndNamespaceTreeNodeCompared() { List<CodeCoverageMethod> methods = new List<CodeCoverageMethod>(); CodeCoverageNamespaceTreeNode namespaceTreeNode = new CodeCoverageNamespaceTreeNode("Z", methods); CodeCoverageClassTreeNode classTreeNode = new CodeCoverageClassTreeNode("A", methods); Assert.AreEqual(-1, nodeSorter.Compare(namespaceTreeNode, classTreeNode)); Assert.Greater(classTreeNode.SortOrder, namespaceTreeNode.SortOrder); }