Browse Source

Improved speed of expanding tree nodes in code coverage tree view - child nodes added only when the node is expanded via the ExtTreeNode.Initialize method. Classes with no namespace are now added to the tree view without a parent namespace node.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1084 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 20 years ago
parent
commit
ea4884bf6a
  1. 3
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj
  2. 15
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageClassTreeNode.cs
  3. 109
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethod.cs
  4. 49
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodsTreeNode.cs
  5. 30
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageModule.cs
  6. 112
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageModuleTreeNode.cs
  7. 31
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageNamespaceTreeNode.cs
  8. 20
      src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageTreeView.cs
  9. 70
      src/AddIns/Misc/CodeCoverage/Test/ClassWithNoNamespaceInTreeViewTestFixture.cs
  10. 2
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverage.Tests.csproj
  11. 104
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageNamespaceTestFixture.cs
  12. 36
      src/AddIns/Misc/CodeCoverage/Test/CodeCoverageTreeViewTestFixture.cs
  13. 10
      src/AddIns/Misc/CodeCoverage/Test/ZeroCodeCoverageTreeViewTestFixture.cs

3
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.csproj

@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
<AssemblyName>CodeCoverage</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{08ce9972-283b-44f4-82fa-966f7dfa6b7a}</ProjectGuid>
<ProjectGuid>{08CE9972-283B-44F4-82FA-966F7DFA6B7A}</ProjectGuid>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
@ -80,6 +80,7 @@ @@ -80,6 +80,7 @@
</None>
<Compile Include="Src\CodeCoverageImageList.cs" />
<Compile Include="Src\GrayScaleBitmap.cs" />
<Compile Include="Src\CodeCoverageMethodsTreeNode.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

15
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageClassTreeNode.cs

@ -7,15 +7,16 @@ @@ -7,15 +7,16 @@
using ICSharpCode.Core;
using System;
using System.Collections.Generic;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageClassTreeNode : CodeCoverageTreeNode
public class CodeCoverageClassTreeNode : CodeCoverageMethodsTreeNode
{
public CodeCoverageClassTreeNode(string name) : base(name, CodeCoverageImageListIndex.Class)
public CodeCoverageClassTreeNode(string name, List<CodeCoverageMethod> methods) : base(name, methods, CodeCoverageImageListIndex.Class)
{
}
public override void ActivateItem()
{
if (Nodes.Count > 0) {
@ -26,5 +27,13 @@ namespace ICSharpCode.CodeCoverage @@ -26,5 +27,13 @@ namespace ICSharpCode.CodeCoverage
}
}
protected override void Initialize()
{
Nodes.Clear();
foreach (CodeCoverageMethod method in Methods) {
CodeCoverageMethodTreeNode node = new CodeCoverageMethodTreeNode(method);
node.AddTo(this);
}
}
}
}

109
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethod.cs

@ -60,6 +60,21 @@ namespace ICSharpCode.CodeCoverage @@ -60,6 +60,21 @@ namespace ICSharpCode.CodeCoverage
}
}
public string RootNamespace {
get {
return GetRootNamespace(classNamespace);
}
}
public static string GetRootNamespace(string ns)
{
int index = ns.IndexOf('.');
if (index > 0) {
return ns.Substring(0, index);
}
return ns;
}
public List<CodeCoverageSequencePoint> SequencePoints {
get {
return sequencePoints;
@ -101,5 +116,99 @@ namespace ICSharpCode.CodeCoverage @@ -101,5 +116,99 @@ namespace ICSharpCode.CodeCoverage
return matchedSequencePoints;
}
/// <summary>
/// Gets the next namespace level given the parent namespace.
/// </summary>
public static string GetChildNamespace(string fullNamespace, string parentNamespace)
{
string end = fullNamespace.Substring(parentNamespace.Length + 1);
return GetRootNamespace(end);
}
/// <summary>
/// Adds the child namespace to the namespace prefix.
/// </summary>
public static string GetFullNamespace(string prefix, string name)
{
if (prefix.Length > 0) {
return String.Concat(prefix, ".", name);
}
return name;
}
/// <summary>
/// Gets all child namespaces that starts with the specified string.
/// </summary>
/// <remarks>
/// If the starts with string is 'ICSharpCode' and there is a code coverage
/// method with a namespace of 'ICSharpCode.XmlEditor.Tests', then this
/// method will return 'XmlEditor' as one of its strings.
/// </remarks>
public static List<string> GetChildNamespaces(List<CodeCoverageMethod> methods, string parentNamespace) {
List<string> items = new List<string>();
foreach (CodeCoverageMethod method in methods) {
string classNamespace = method.ClassNamespace;
if (classNamespace.Length > parentNamespace.Length && classNamespace.StartsWith(parentNamespace)) {
string ns = CodeCoverageMethod.GetChildNamespace(method.ClassNamespace, parentNamespace);
if (!items.Contains(ns)) {
items.Add(ns);
}
}
}
return items;
}
/// <summary>
/// Gets all methods whose namespaces starts with the specified string.
/// </summary>
public static List<CodeCoverageMethod> GetAllMethods(List<CodeCoverageMethod> methods, string namespaceStartsWith)
{
List<CodeCoverageMethod> matchedMethods = new List<CodeCoverageMethod>();
foreach (CodeCoverageMethod method in methods) {
if (method.ClassNamespace.StartsWith(namespaceStartsWith)) {
matchedMethods.Add(method);
}
}
return matchedMethods;
}
/// <summary>
/// Gets only those methods whose namespaces exactly match the specified string.
/// </summary>
public static List<CodeCoverageMethod> GetMethods(List<CodeCoverageMethod> methods, string ns)
{
List<CodeCoverageMethod> matchedMethods = new List<CodeCoverageMethod>();
foreach (CodeCoverageMethod method in methods) {
if (method.ClassNamespace == ns) {
matchedMethods.Add(method);
}
}
return matchedMethods;
}
/// <summary>
/// Gets only those methods for the specified class.
/// </summary>
public static List<CodeCoverageMethod> GetMethods(List<CodeCoverageMethod> methods, string ns, string className)
{
List<CodeCoverageMethod> matchedMethods = new List<CodeCoverageMethod>();
foreach (CodeCoverageMethod method in methods) {
if (method.ClassName == className && method.ClassNamespace == ns) {
matchedMethods.Add(method);
}
}
return matchedMethods;
}
public static List<string> GetClassNames(List<CodeCoverageMethod> methods, string ns)
{
List<string> names = new List<string>();
foreach (CodeCoverageMethod method in methods) {
if (method.ClassNamespace == ns && !names.Contains(method.ClassName)) {
names.Add(method.ClassName);
}
}
return names;
}
}
}

49
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageMethodsTreeNode.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.Collections.Generic;
namespace ICSharpCode.CodeCoverage
{
/// <summary>
/// Represents a code coverage tree node that has associated
/// methods.
/// </summary>
public class CodeCoverageMethodsTreeNode : CodeCoverageTreeNode
{
List<CodeCoverageMethod> methods = new List<CodeCoverageMethod>();
public CodeCoverageMethodsTreeNode(string name, List<CodeCoverageMethod> methods, CodeCoverageImageListIndex index) : base(name, index)
{
this.methods = methods;
if (methods.Count > 0) {
// Add dummy node.
Nodes.Add(new ExtTreeNode());
}
int visitedCount = 0;
int notVisitedCount = 0;
foreach (CodeCoverageMethod method in methods) {
visitedCount += method.VisitedSequencePointsCount;
notVisitedCount += method.NotVisitedSequencePointsCount;
}
Name = name;
VisitedCount = visitedCount;
NotVisitedCount = notVisitedCount;
}
public List<CodeCoverageMethod> Methods {
get {
return methods;
}
}
}
}

30
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageModule.cs

@ -14,12 +14,16 @@ namespace ICSharpCode.CodeCoverage @@ -14,12 +14,16 @@ namespace ICSharpCode.CodeCoverage
{
string name = String.Empty;
List<CodeCoverageMethod> methods = new List<CodeCoverageMethod>();
List<string> rootNamespaces;
public CodeCoverageModule(string name)
{
this.name = name;
}
/// <summary>
/// The module's assembly name.
/// </summary>
public string Name {
get {
return name;
@ -60,5 +64,31 @@ namespace ICSharpCode.CodeCoverage @@ -60,5 +64,31 @@ namespace ICSharpCode.CodeCoverage
}
return sequencePoints;
}
/// <summary>
/// Gets the distinct root namespaces for all the methods.
/// </summary>
/// <remarks>
/// If one of the namespaces is 'ICSharpCode.XmlEditor' then this
/// method will return 'ICSharpCode' as one of the root namespaces.
/// </remarks>
public List<string> RootNamespaces {
get {
if (rootNamespaces == null) {
GetRootNamespaces();
}
return rootNamespaces;
}
}
void GetRootNamespaces()
{
rootNamespaces = new List<string>();
foreach (CodeCoverageMethod method in methods) {
if (method.RootNamespace.Length > 0 && !rootNamespaces.Contains(method.RootNamespace)) {
rootNamespaces.Add(method.RootNamespace);
}
}
}
}
}

112
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageModuleTreeNode.cs

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
@ -14,110 +15,31 @@ namespace ICSharpCode.CodeCoverage @@ -14,110 +15,31 @@ namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageModuleTreeNode : CodeCoverageTreeNode
{
public CodeCoverageModuleTreeNode(CodeCoverageModule module) : base(module.Name, CodeCoverageImageListIndex.Module, module.VisitedSequencePointsCount, module.NotVisitedSequencePointsCount)
{
foreach (CodeCoverageMethod method in module.Methods) {
AddMethod(method);
}
// Update percentage totals for namespace nodes.
UpdateNamespacePercentages(Nodes);
}
CodeCoverageModule module;
void AddMethod(CodeCoverageMethod method)
{
ExtTreeNode parentNode = GetParentNamespaceNode(method.ClassNamespace);
// Add class node.
ExtTreeNode classNode = FindNode(parentNode.Nodes, method.ClassName);
if (classNode == null) {
classNode = new CodeCoverageClassTreeNode(method.ClassName);
classNode.AddTo(parentNode);
}
// Add method node.
CodeCoverageMethodTreeNode methodNode = new CodeCoverageMethodTreeNode(method);
methodNode.AddTo(classNode);
}
ExtTreeNode GetParentNamespaceNode(string classNamespace)
{
string[] treePath = classNamespace.Split('.');
ExtTreeNode node = this;
ExtTreeNode currentNode = node;
foreach (string path in treePath) {
if (currentNode != null) {
currentNode = FindNode(currentNode.Nodes, path);
}
if (currentNode == null) {
CodeCoverageNamespaceTreeNode newNode = new CodeCoverageNamespaceTreeNode(path);
newNode.AddTo(node);
node = newNode;
} else {
node = currentNode;
}
}
return node;
}
ExtTreeNode FindNode(TreeNodeCollection nodes, string name)
{
foreach (ExtTreeNode node in nodes) {
if (node.Text == name) {
return node;
}
}
return null;
}
void UpdateNamespacePercentages(TreeNodeCollection nodes)
public CodeCoverageModuleTreeNode(CodeCoverageModule module) : base(module.Name, CodeCoverageImageListIndex.Module, module.VisitedSequencePointsCount, module.NotVisitedSequencePointsCount)
{
foreach (ExtTreeNode node in nodes) {
CodeCoverageNamespaceTreeNode namespaceNode = node as CodeCoverageNamespaceTreeNode;
if (namespaceNode != null) {
SumVisits(namespaceNode);
}
this.module = module;
if (module.Methods.Count > 0) {
// Add dummy node.
Nodes.Add(new ExtTreeNode());
}
}
void SumVisits(CodeCoverageNamespaceTreeNode parentNode)
protected override void Initialize()
{
int visitedCount = 0;
int notVisitedCount = 0;
foreach (CodeCoverageTreeNode node in parentNode.Nodes) {
CodeCoverageNamespaceTreeNode namespaceNode = node as CodeCoverageNamespaceTreeNode;
CodeCoverageClassTreeNode classNode = node as CodeCoverageClassTreeNode;
if (namespaceNode != null) {
SumVisits(namespaceNode);
} else if (classNode != null) {
SumVisits(classNode);
}
visitedCount += node.VisitedCount;
notVisitedCount += node.NotVisitedCount;
Nodes.Clear();
foreach (string namespaceName in module.RootNamespaces) {
CodeCoverageNamespaceTreeNode node = new CodeCoverageNamespaceTreeNode(namespaceName, CodeCoverageMethod.GetAllMethods(module.Methods, namespaceName));
node.AddTo(this);
}
parentNode.VisitedCount = visitedCount;
parentNode.NotVisitedCount = notVisitedCount;
}
void SumVisits(CodeCoverageClassTreeNode parentNode)
{
int visitedCount = 0;
int notVisitedCount = 0;
foreach (CodeCoverageTreeNode node in parentNode.Nodes) {
visitedCount += node.VisitedCount;
notVisitedCount += node.NotVisitedCount;
// 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);
}
parentNode.VisitedCount = visitedCount;
parentNode.NotVisitedCount = notVisitedCount;
}
}
}

31
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageNamespaceTreeNode.cs

@ -7,13 +7,40 @@ @@ -7,13 +7,40 @@
using ICSharpCode.Core;
using System;
using System.Collections.Generic;
namespace ICSharpCode.CodeCoverage
{
public class CodeCoverageNamespaceTreeNode : CodeCoverageTreeNode
public class CodeCoverageNamespaceTreeNode : CodeCoverageMethodsTreeNode
{
public CodeCoverageNamespaceTreeNode(string name) : base(name, CodeCoverageImageListIndex.Namespace)
string namespacePrefix = String.Empty;
public CodeCoverageNamespaceTreeNode(string name, List<CodeCoverageMethod> methods) : this(String.Empty, name, methods)
{
}
public CodeCoverageNamespaceTreeNode(string namespacePrefix, string name, List<CodeCoverageMethod> methods) : base(name, methods, CodeCoverageImageListIndex.Namespace)
{
this.namespacePrefix = namespacePrefix;
}
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);
}
}
}
}

20
src/AddIns/Misc/CodeCoverage/Project/Src/CodeCoverageTreeView.cs

@ -21,9 +21,25 @@ namespace ICSharpCode.CodeCoverage @@ -21,9 +21,25 @@ namespace ICSharpCode.CodeCoverage
public void AddModules(List<CodeCoverageModule> modules)
{
foreach (CodeCoverageModule module in modules) {
Nodes.Add(new CodeCoverageModuleTreeNode(module));
BeginUpdate();
try {
foreach (CodeCoverageModule module in modules) {
Nodes.Add(new CodeCoverageModuleTreeNode(module));
}
Sort();
} finally {
EndUpdate();
}
}
protected override void OnAfterSelect(TreeViewEventArgs e)
{
CodeCoverageTreeNode node = e.Node as CodeCoverageTreeNode;
if (node != null) {
node.PerformInitialization();
}
base.OnAfterSelect(e);
}
}
}

70
src/AddIns/Misc/CodeCoverage/Test/ClassWithNoNamespaceInTreeViewTestFixture.cs

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.CodeCoverage;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ICSharpCode.CodeCoverage.Tests
{
[TestFixture]
public class ClassWithNoNamespaceInTreeViewTestFixture
{
CodeCoverageMethodTreeNode methodNode;
CodeCoverageModule module;
[SetUp]
public void Init()
{
CodeCoverageMethod method = new CodeCoverageMethod("FileElementHasAttributeNamedType", "AbstractElementSchemaTestFixture");
module = new CodeCoverageModule("XmlEditor.Tests");
module.Methods.Add(method);
List<CodeCoverageModule> modules = new List<CodeCoverageModule>();
modules.Add(module);
TreeNodeCollection nodes;
using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) {
treeView.AddModules(modules);
nodes = treeView.Nodes;
}
CodeCoverageModuleTreeNode moduleNode = (CodeCoverageModuleTreeNode)nodes[0];
moduleNode.Expanding();
CodeCoverageClassTreeNode classNode = (CodeCoverageClassTreeNode)moduleNode.Nodes[0];
classNode.Expanding();
methodNode = (CodeCoverageMethodTreeNode)classNode.Nodes[0];
}
[Test]
public void MethodNodeName()
{
Assert.AreEqual("FileElementHasAttributeNamedType", methodNode.Name);
}
[Test]
public void NoRootNamespaces()
{
Assert.AreEqual(0, module.RootNamespaces.Count,
"Should not be any root namespaces since the class does not have one.");
}
[Test]
public void OneClassWithNoNamespace()
{
Assert.AreEqual(1, CodeCoverageMethod.GetClassNames(module.Methods, String.Empty).Count);
}
[Test]
public void ClassWithNoNamespace()
{
Assert.AreEqual("AbstractElementSchemaTestFixture", (CodeCoverageMethod.GetClassNames(module.Methods, String.Empty))[0]);
}
}
}

2
src/AddIns/Misc/CodeCoverage/Test/CodeCoverage.Tests.csproj

@ -68,6 +68,8 @@ @@ -68,6 +68,8 @@
<Compile Include="MethodHasNoNamespaceTestFixture.cs" />
<Compile Include="DisplayItemTestFixture.cs" />
<Compile Include="NUnitResultsTestFixture.cs" />
<Compile Include="CodeCoverageNamespaceTestFixture.cs" />
<Compile Include="ClassWithNoNamespaceInTreeViewTestFixture.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

104
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageNamespaceTestFixture.cs

@ -0,0 +1,104 @@ @@ -0,0 +1,104 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using ICSharpCode.CodeCoverage;
using NUnit.Framework;
using System;
using System.Collections.Generic;
namespace ICSharpCode.CodeCoverage.Tests
{
[TestFixture]
public class CodeCoverageNamespaceTestFixture
{
CodeCoverageModule module;
CodeCoverageMethod attributeNameTestFixtureMethod;
CodeCoverageMethod abstractElementSchemaTestFixtureMethod;
CodeCoverageMethod differentRootNamespaceTestFixtureMethod;
string sharpDevelopNamespace;
string differentRootNamespace;
string xmlEditorNamespace;
[SetUp]
public void Init()
{
module = new CodeCoverageModule("XmlEditor.Tests");
attributeNameTestFixtureMethod = new CodeCoverageMethod("SuccessTest1", "ICSharpCode.XmlEditor.Parser.AttributeNameTestFixture");
module.Methods.Add(attributeNameTestFixtureMethod);
abstractElementSchemaTestFixtureMethod = new CodeCoverageMethod("FileElementHasAttributeNamedType", "ICSharpCode.XmlEditor.Schema.AbstractElementSchemaTestFixture");
module.Methods.Add(abstractElementSchemaTestFixtureMethod);
differentRootNamespaceTestFixtureMethod = new CodeCoverageMethod("DifferentRootNamespaceTestMethod", "RootNamespace.XmlEditor.DifferentRootNamespaceTestFixture");
module.Methods.Add(differentRootNamespaceTestFixtureMethod);
sharpDevelopNamespace = module.RootNamespaces[0];
differentRootNamespace = module.RootNamespaces[1];
xmlEditorNamespace = (CodeCoverageMethod.GetChildNamespaces(module.Methods, sharpDevelopNamespace))[0];
}
[Test]
public void SharpDevelopRootNamespace()
{
Assert.AreEqual("ICSharpCode", sharpDevelopNamespace);
}
[Test]
public void DifferentRootNamespace()
{
Assert.AreEqual("RootNamespace", differentRootNamespace);
}
[Test]
public void GetAllICSharpCodeNamespaceMethods()
{
List<CodeCoverageMethod> methods = CodeCoverageMethod.GetAllMethods(module.Methods, "ICSharpCode");
Assert.AreSame(attributeNameTestFixtureMethod, methods[0]);
}
[Test]
public void GetAllICSharpCodeXmlEditorNamespaceMethods()
{
List<CodeCoverageMethod> methods = CodeCoverageMethod.GetAllMethods(module.Methods, "ICSharpCode.XmlEditor");
Assert.AreSame(attributeNameTestFixtureMethod, methods[0]);
}
[Test]
public void XmlEditorNamespace()
{
Assert.AreEqual("XmlEditor", xmlEditorNamespace);
}
[Test]
public void OnlyOneSharpDevelopChildNamespace()
{
Assert.AreEqual(1, CodeCoverageMethod.GetChildNamespaces(module.Methods, sharpDevelopNamespace).Count);
}
[Test]
public void NoNamespacesBelowXmlEditorSchemaNamespace()
{
Assert.AreEqual(0, CodeCoverageMethod.GetChildNamespaces(module.Methods, "ICSharpCode.XmlEditor.Schema").Count);
}
[Test]
public void SchemaNamespaceMethods()
{
List<CodeCoverageMethod> methods = CodeCoverageMethod.GetMethods(module.Methods, "ICSharpCode.XmlEditor.Schema", "AbstractElementSchemaTestFixture");
Assert.AreSame(abstractElementSchemaTestFixtureMethod, methods[0]);
}
[Test]
public void SchemaNamespaceClassNames()
{
List<string> names = CodeCoverageMethod.GetClassNames(module.Methods, "ICSharpCode.XmlEditor.Schema");
Assert.AreEqual("AbstractElementSchemaTestFixture", names[0]);
}
}
}

36
src/AddIns/Misc/CodeCoverage/Test/CodeCoverageTreeViewTestFixture.cs

@ -14,8 +14,13 @@ using System.Windows.Forms; @@ -14,8 +14,13 @@ using System.Windows.Forms;
namespace ICSharpCode.CodeCoverage.Tests
{
/// <summary>
/// Checks that the tree nodes have the correct text, images and
/// text colours as we expand the tree node by node. The tree populates
/// itself lazily as it is expanded.
/// </summary>
[TestFixture]
public class CodeCoverageTreeViewTestFixture
public class NewCodeCoverageTreeViewTestFixture
{
TreeNodeCollection nodes;
CodeCoverageModuleTreeNode fooModuleNode;
@ -25,8 +30,9 @@ namespace ICSharpCode.CodeCoverage.Tests @@ -25,8 +30,9 @@ namespace ICSharpCode.CodeCoverage.Tests
CodeCoverageMethodTreeNode fooTestMethod2TreeNode;
CodeCoverageNamespaceTreeNode fooNamespaceTreeNode;
CodeCoverageNamespaceTreeNode fooTestsNamespaceTreeNode;
CodeCoverageNamespaceTreeNode fooTestsUtilNamespaceTreeNode;
[SetUp]
[TestFixtureSetUp]
public void SetUpFixture()
{
List<CodeCoverageModule> modules = new List<CodeCoverageModule>();
@ -35,28 +41,36 @@ namespace ICSharpCode.CodeCoverage.Tests @@ -35,28 +41,36 @@ namespace ICSharpCode.CodeCoverage.Tests
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(fooModule);
modules.Add(barModule);
modules.Add(fooModule);
using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) {
treeView.AddModules(modules);
treeView.ExpandAll();
nodes = treeView.Nodes;
}
fooModuleNode = (CodeCoverageModuleTreeNode)nodes[0];
barModuleNode = (CodeCoverageModuleTreeNode)nodes[1];
barModuleNode = (CodeCoverageModuleTreeNode)nodes[0];
fooModuleNode = (CodeCoverageModuleTreeNode)nodes[1];
fooModuleNode.Expanding();
fooNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooModuleNode.Nodes[0];
fooTestsNamespaceTreeNode = (CodeCoverageNamespaceTreeNode)fooNamespaceTreeNode.Nodes[0];
fooTestFixtureTreeNode = (CodeCoverageClassTreeNode)fooTestsNamespaceTreeNode.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];
}
@ -166,7 +180,7 @@ namespace ICSharpCode.CodeCoverage.Tests @@ -166,7 +180,7 @@ namespace ICSharpCode.CodeCoverage.Tests
[Test]
public void FooTestsNamespaceTreeNodeChildNodesCount()
{
Assert.AreEqual(1, fooTestsNamespaceTreeNode.Nodes.Count);
Assert.AreEqual(2, fooTestsNamespaceTreeNode.Nodes.Count);
}
[Test]

10
src/AddIns/Misc/CodeCoverage/Test/ZeroCodeCoverageTreeViewTestFixture.cs

@ -40,15 +40,21 @@ namespace ICSharpCode.CodeCoverage.Tests @@ -40,15 +40,21 @@ namespace ICSharpCode.CodeCoverage.Tests
using (CodeCoverageTreeView treeView = new CodeCoverageTreeView()) {
treeView.AddModules(modules);
treeView.ExpandAll();
nodes = treeView.Nodes;
}
fooModuleNode = (CodeCoverageModuleTreeNode)nodes[0];
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];
}

Loading…
Cancel
Save