Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1084 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
13 changed files with 475 additions and 116 deletions
@ -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; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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]); |
||||
} |
||||
} |
||||
} |
@ -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]); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue