public void SetUpFixture()
		{
			string xml = "<PartCoverReport date=\"2008-07-10T02:59:13.7198656+01:00\">\r\n" +
				"    <File id=\"1\" url=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" +
				"    <Assembly id=\"1\" name=\"Foo.Tests\" module=\"C:\\Projects\\Test\\Foo.Tests\\bin\\Foo.Tests.DLL\" domain=\"test-domain-Foo.Tests.dll\" domainIdx=\"1\" />\r\n" +
				"    <Type asmref=\"1\" name=\"Foo.Tests.FooTestFixture\" flags=\"1232592\">\r\n" +
				"        <Method name=\"SimpleTest\" sig=\"void  ()\" bodysize=\"42\" flags=\"2182\" iflags=\"0\">\r\n" +
				"            <pt visit=\"1\" pos=\"0\" len=\"1\" fid=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" />\r\n" +
				"            <pt visit=\"1\" pos=\"0\" len=\"1\" fid=\"1\" sl=\"21\" sc=\"13\" el=\"21\" ec=\"32\" />\r\n" +
				"            <pt visit=\"0\" pos=\"0\" len=\"1\" fid=\"1\" sl=\"24\" sc=\"3\" el=\"24\" ec=\"4\" />\r\n" +
				"        </Method>\r\n" +
				"    </Type>\r\n" +
				"</PartCoverReport>";
			results = new CodeCoverageResults(new StringReader(xml));
			if (results.Modules.Count > 0) {
				module = results.Modules[0];
				if (module.Methods.Count > 0) {
					method = module.Methods[0];
					if (method.SequencePoints.Count == 3) {
						point1 = method.SequencePoints[0];
						point2 = method.SequencePoints[1];
						point3 = method.SequencePoints[2];
					}
				}			
			}
		}
Example #2
0
        /// <summary>
        /// Add module if it does not already exist.
        /// </summary>
        CodeCoverageModule AddModule(XElement reader, string className)
        {
            string             assemblyName = GetAssemblyName(reader);
            CodeCoverageModule module       = null;

            foreach (CodeCoverageModule existingModule in modules)
            {
                if (existingModule.Name == assemblyName)
                {
                    module = existingModule;
                    break;
                }
            }
            if (module == null)
            {
                module = new CodeCoverageModule(assemblyName);
                modules.Add(module);
            }
            var methods = reader
                          .Elements("Classes")
                          .Elements("Class")
                          .Where(c => c.Element("FullName").Value.Equals(className, StringComparison.Ordinal))
                          .Elements("Methods")
                          .Elements("Method");

            foreach (XElement method in methods)
            {
                AddMethod(module, className.Replace('/', '.'), method);
            }
            return(module);
        }
        CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XmlReader reader)
        {
            CodeCoverageMethod method = new CodeCoverageMethod(className, reader);

            module.Methods.Add(method);
            return(method);
        }
Example #4
0
        CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XmlReader reader)
        {
            CodeCoverageMethod method = new CodeCoverageMethod(reader.GetAttribute("name"), className, GetMethodAttributes(reader));

            module.Methods.Add(method);
            return(method);
        }
		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];
		}
Example #6
0
        /// <summary>
        /// Sequence points that do not have a file id are not
        /// added to the code coverage method. Typically these are
        /// for types that are not part of the project but types from
        /// the .NET framework.
        /// </summary>
        CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
        {
            var method = new CodeCoverageMethod(className, reader, this);

            module.Methods.Add(method);
            return(method);
        }
		public void SetUpFixture()
		{
			string xml = "<PartCoverReport>\r\n" +
				"\t<File id=\"1\" url=\"c:\\Projects\\Foo\\FooTestFixture.cs\"/>\r\n" +
				"\t<File id=\"2\" url=\"c:\\Projects\\Foo\\FooTestFixture2.cs\"/>\r\n" +
				"\t<File id=\"3\" url=\"c:\\Projects\\Foo\\BarTestFixture.cs\"/>\r\n" +
				"\t<Assembly id=\"1\" name=\"Foo.Tests\" module=\"C:\\Projects\\Test\\bin\\Foo.Tests.DLL\" domain=\"test-domain-Foo.Tests.dll\" domainIdx=\"1\" />\r\n" +
				"\t<Assembly id=\"2\" name=\"Bar.Tests\" module=\"C:\\Projects\\Test\\bin\\Bar.Tests.DLL\" domain=\"test-domain-Bar.Tests.dll\" domainIdx=\"1\" />\r\n" +
				"\t<Type name=\"Foo.Tests.FooTestFixture1\" asmref=\"1\">\r\n" +
				"\t\t<Method name=\"SimpleTest1\">\r\n" +
				"\t\t\t<pt visit=\"12\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fid=\"1\" />\r\n" +
				"\t\t\t<pt visit=\"4\" sl=\"21\" sc=\"13\" el=\"21\" ec=\"32\" fid=\"1\" />\r\n" +
				"\t\t\t<pt visit=\"0\" sl=\"24\" sc=\"3\" el=\"24\" ec=\"4\" fid=\"1\"/>\r\n" +
				"\t\t</Method>\r\n" +
				"\t</Type>\r\n" +
				"\t<Type name=\"Foo.Tests.FooTestFixture2\" asmref=\"1\">\r\n" +
				"\t\t<Method name=\"SimpleTest2\">\r\n" +
				"\t\t\t<pt visit=\"1\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fid=\"2\" />\r\n" +
				"\t\t\t<pt visit=\"10\" sl=\"21\" sc=\"13\" el=\"21\" ec=\"32\" fid=\"2\"/>\r\n" +
				"\t\t\t<pt visit=\"0\" sl=\"24\" sc=\"3\" el=\"24\" ec=\"4\" fid=\"2\" />\r\n" +
				"\t\t</Method>\r\n" +
				"\t</Type>\r\n" +
				"\t<Type name=\"Bar.Tests.FooTestFixture3\" asmref=\"2\">\r\n" +
				"\t\t<Method name=\"SimpleTest3\">\r\n" +
				"\t\t\t<pt visit=\"5\" sl=\"20\" sc=\"3\" el=\"20\" ec=\"4\" fid=\"3\" />\r\n" +
				"\t\t\t<pt visit=\"1\" sl=\"21\" sc=\"13\" el=\"21\" ec=\"32\" fid=\"3\" />\r\n" +
				"\t\t\t<pt visit=\"0\" sl=\"24\" sc=\"3\" el=\"24\" ec=\"4\" fid=\"3\" />\r\n" +
				"\t\t</Method>\r\n" +
				"\t</Type>\r\n" +				
				"</PartCoverReport>";
			results = new CodeCoverageResults(new StringReader(xml));
			fooModule = results.Modules[0];
			barModule = results.Modules[1];
		}
		public CodeCoverageModuleTreeNode(CodeCoverageModule module) : base(module.Name, CodeCoverageImageListIndex.Module, module.VisitedSequencePointsCount, module.NotVisitedSequencePointsCount)
		{
			this.module = module;
			if (module.Methods.Count > 0) {
				// Add dummy node.
				Nodes.Add(new ExtTreeNode());
			}
		}
Example #9
0
 public CodeCoverageModuleTreeNode(CodeCoverageModule module) : base(module.Name, CodeCoverageImageListIndex.Module, module.VisitedSequencePointsCount, module.NotVisitedSequencePointsCount)
 {
     this.module = module;
     if (module.Methods.Count > 0)
     {
         // Add dummy node.
         Nodes.Add(new ExtTreeNode());
     }
 }
		public void IsExcluded()
		{
			CodeCoverageModule module = new CodeCoverageModule("test");
			CodeCoverageMethod method = new CodeCoverageMethod("Test1", "MyTestFixture");
			CodeCoverageSequencePoint pt = new CodeCoverageSequencePoint(@"c:\test\MyTestFixture.cs", 0, 10, 0, 10, 20, true);
			method.SequencePoints.Add(pt);
			module.Methods.Add(method);
			
			Assert.IsTrue(module.IsExcluded, "Module should be excluded.");
		}
Example #11
0
        /// <summary>
        /// Sequence points that do not have a file id are not
        /// added to the code coverage method. Typically these are
        /// for types that are not part of the project but types from
        /// the .NET framework.
        /// </summary>
        CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
        {
            var method = new CodeCoverageMethod(className, reader, this);

            if (!method.Name.Contains("__"))
            {
                module.Methods.Add(method);
            }
            return(method);
        }
Example #12
0
 /// <summary>
 /// Removes any modules that do not contain any methods.
 /// </summary>
 void RemoveModulesWithNoMethods()
 {
     for (int i = modules.Count - 1; i >= 0; --i)
     {
         CodeCoverageModule module = modules[i];
         if (module.Methods.Count == 0)
         {
             modules.Remove(module);
         }
     }
 }
		public void SetUpFixture()
		{
			CodeCoverageModule module = new CodeCoverageModule("Root.Tests");
		
			// Add two methods in namespaces that start with the
			// same initial characters.
			CodeCoverageMethod rootTestsMethod = new CodeCoverageMethod("RunThis", "Root.Tests.MyTestFixture");
			module.Methods.Add(rootTestsMethod);
			CodeCoverageMethod rootBarMethod = new CodeCoverageMethod("RunThis", "RootBar.MyTestFixture");
			module.Methods.Add(rootBarMethod);
			
			childNamespaces = CodeCoverageMethod.GetChildNamespaces(module.Methods, "Root");	
		}
		public void SetUpFixture()
		{
			string xml = "<PartCoverReport date=\"2008-07-10T02:59:13.7198656+01:00\">\r\n" +
				"    <File id=\"1\" url=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" +
				"    <Assembly id=\"1\" name=\"Foo.Tests\" module=\"C:\\Projects\\Test\\Foo.Tests\\bin\\Foo.Tests.DLL\" domain=\"test-domain-Foo.Tests.dll\" domainIdx=\"1\" />\r\n" +
				"    <Type asmref=\"1\" name=\"Foo.Tests.FooTestFixture\" flags=\"1232592\">\r\n" +
				"        <Method name=\"SimpleTest\" sig=\"void  ()\" bodysize=\"42\" flags=\"2182\" iflags=\"0\" />\r\n" +
				"    </Type>\r\n" +
				"</PartCoverReport>";
			results = new CodeCoverageResults(new StringReader(xml));
			if (results.Modules.Count > 0) {
				module = results.Modules[0];
			}
		}
        CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
        {
            CodeCoverageMethod method = new CodeCoverageMethod(className, reader);

            module.Methods.Add(method);
            var points = reader
                         .Elements("SequencePoints")
                         .Elements("SequencePoint");

            foreach (XElement point in points)
            {
                AddSequencePoint(method, point, reader);
            }
            return(method);
        }
Example #16
0
        void ReadResults(XmlReader reader)
        {
            CodeCoverageModule currentModule    = null;
            CodeCoverageMethod currentMethod    = null;
            string             currentClassName = String.Empty;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name == "Type")
                    {
                        currentModule    = AddModule(reader);
                        currentClassName = reader.GetAttribute("name");
                    }
                    else if ((reader.Name == "Method") && (currentModule != null) && (!reader.IsEmptyElement))
                    {
                        currentMethod = AddMethod(currentModule, currentClassName, reader);
                    }
                    else if ((reader.Name == "pt") && (currentMethod != null))
                    {
                        AddSequencePoint(currentMethod, reader);
                    }
                    else if (reader.Name == "File")
                    {
                        AddFileName(reader);
                    }
                    else if (reader.Name == "Assembly")
                    {
                        AddAssembly(reader);
                    }
                    break;

                case XmlNodeType.EndElement:
                    if (currentMethod != null && reader.Name == "Method" && currentMethod.SequencePoints.Count == 0)
                    {
                        // Remove method that has no sequence points.
                        currentModule.Methods.Remove(currentMethod);
                    }
                    break;
                }
            }
            reader.Close();

            RemoveModulesWithNoMethods();
        }
        /// <summary>
        /// Add module if it does not already exist.
        /// </summary>
        CodeCoverageModule AddModule(XmlReader reader)
        {
            string assemblyName = GetAssemblyName(reader);

            foreach (CodeCoverageModule existingModule in modules)
            {
                if (existingModule.Name == assemblyName)
                {
                    return(existingModule);
                }
            }

            CodeCoverageModule module = new CodeCoverageModule(assemblyName);

            modules.Add(module);
            return(module);
        }
		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];
		}
Example #19
0
        /// <summary>
        /// Add module if it does not already exist.
        /// </summary>
        CodeCoverageModule AddModule(XmlReader reader)
        {
            string id           = reader.GetAttribute("asmref");
            string assemblyName = GetAssembly(id);

            foreach (CodeCoverageModule existingModule in modules)
            {
                if (existingModule.Name == assemblyName)
                {
                    return(existingModule);
                }
            }

            CodeCoverageModule module = new CodeCoverageModule(assemblyName);

            modules.Add(module);
            return(module);
        }
		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 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];
		}
		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];
		}
        void ReadResults(XmlReader reader)
        {
            CodeCoverageModule currentModule    = null;
            CodeCoverageMethod currentMethod    = null;
            string             currentClassName = String.Empty;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    if (reader.Name == "Type")
                    {
                        currentModule    = AddModule(reader);
                        currentClassName = reader.GetAttribute("name");
                    }
                    else if ((reader.Name == "Method") && (currentModule != null))
                    {
                        currentMethod = AddMethod(currentModule, currentClassName, reader);
                    }
                    else if ((reader.Name == "pt") && (currentMethod != null))
                    {
                        AddSequencePoint(currentMethod, reader);
                    }
                    else if (reader.Name == "File")
                    {
                        AddFileName(reader);
                    }
                    else if (reader.Name == "Assembly")
                    {
                        AddAssembly(reader);
                    }
                    break;
                }
            }
            reader.Close();
        }
		CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XmlReader reader)
		{
			CodeCoverageMethod method = new CodeCoverageMethod(reader.GetAttribute("name"), className, GetMethodAttributes(reader));
			module.Methods.Add(method);
			return method;
		}
		/// <summary>
		/// Add module if it does not already exist.
		/// </summary>
		CodeCoverageModule AddModule(XmlReader reader)
		{
			string assemblyName = GetAssemblyName(reader);
			foreach (CodeCoverageModule existingModule in modules) {
				if (existingModule.Name == assemblyName) {
					return existingModule;
				}
			}
			
			CodeCoverageModule module = new CodeCoverageModule(assemblyName);
			modules.Add(module);
			return module;
		}
		public CodeCoverageModuleTreeNode(CodeCoverageModule module)
			: base(module, CodeCoverageImageListIndex.Module)
		{
			this.module = module;
			AddDummyNodeIfModuleHasNoMethods();
		}
		CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XmlReader reader)
		{
			CodeCoverageMethod method = new CodeCoverageMethod(className, reader);
			module.Methods.Add(method);
			return method;
		}
		/// <summary>
		/// Sequence points that do not have a file id are not
		/// added to the code coverage method. Typically these are
		/// for types that are not part of the project but types from
		/// the .NET framework. 
		/// </summary>
		CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
		{
			var method = new CodeCoverageMethod(className, reader, this);
			module.Methods.Add(method);
			return method;
		}
		/// <summary>
		/// Sequence points that do not have a file id are not
		/// added to the code coverage method. Typically these are
		/// for types that are not part of the project but types from
		/// the .NET framework. 
		/// </summary>
		CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
		{
			var method = new CodeCoverageMethod(className, reader, this);
			if (!method.Name.Contains("__")) {
			    module.Methods.Add(method);
			}
			return method;
		}
		public void SetUpFixture()
		{
			treeView = new CodeCoverageTreeView();
			nodeSorter = treeView.NodeSorter;
			
			List<CodeCoverageModule> modules = new List<CodeCoverageModule>();
			
			// Create a module called Z.
			CodeCoverageModule zModule = new CodeCoverageModule("Z");
			modules.Add(zModule);
		
			// Create a module called CodeCoverage.
			CodeCoverageModule codeCoverageModule = new CodeCoverageModule("CodeCoverage");
			modules.Add(codeCoverageModule);
			
			// Add a method that lives in a class without any namespace.
			CodeCoverageMethod testMethod = new CodeCoverageMethod("Test", "TestFixture");
			codeCoverageModule.Methods.Add(testMethod);
			
			// Add a method which produces a namespace that alphabetically 
			// occurs after the class already added.
			CodeCoverageMethod removeCodeMarkersMethod = new CodeCoverageMethod("RemoveCodeMarkersMethod", "Beta.TestFixture");
			codeCoverageModule.Methods.Add(removeCodeMarkersMethod);
			
			// Add a method that lives in a namespace that 
			// occurs before the removeCodeMarkersMethod. We want to 
			// make sure that this namespace node gets added before the Beta one.
			CodeCoverageMethod zebraMethod = new CodeCoverageMethod("Zebra", "Aardvark.TestFixture");
			codeCoverageModule.Methods.Add(zebraMethod);
			
			// Add a second class in the beta namespace so we check the 
			// sorting of classes.
			CodeCoverageMethod addCodeMarkersMethod = new CodeCoverageMethod("AddCodeMarkersMethod", "Beta.AnotherTestFixture");
			codeCoverageModule.Methods.Add(addCodeMarkersMethod);
			
			// Add a method which produces occurs before the remove code markers method.
			CodeCoverageMethod addNodeMethod = new CodeCoverageMethod("AddNode", "Beta.TestFixture");
			codeCoverageModule.Methods.Add(addNodeMethod);
			
			// Add two get and set properties.
			CodeCoverageMethod method = new CodeCoverageMethod("get_Zebra", "Beta.AnotherTestFixture");
			codeCoverageModule.Methods.Add(method);
			method = new CodeCoverageMethod("set_Zebra", "Beta.AnotherTestFixture");
			codeCoverageModule.Methods.Add(method);
			
			method = new CodeCoverageMethod("set_Aardvark", "Beta.AnotherTestFixture");
			codeCoverageModule.Methods.Add(method);
			method = new CodeCoverageMethod("get_Aardvark", "Beta.AnotherTestFixture");
			codeCoverageModule.Methods.Add(method);
			
			// Add a method which should appear between the two properties.
			method = new CodeCoverageMethod("Chimp", "Beta.AnotherTestFixture");
			codeCoverageModule.Methods.Add(method);

			
			// Add the modules to the tree.
			treeView.AddModules(modules);
			
			codeCoverageModuleTreeNode = (CodeCoverageModuleTreeNode)treeView.Nodes[0];
			zModuleTreeNode = (CodeCoverageModuleTreeNode)treeView.Nodes[1];
			
			// Initialise the code coverage module tree node.
			codeCoverageModuleTreeNode.PerformInitialization();
			aardvarkNamespaceTreeNode = (CodeCoverageTreeNode)codeCoverageModuleTreeNode.Nodes[0];
			betaNamespaceTreeNode = (CodeCoverageTreeNode)codeCoverageModuleTreeNode.Nodes[1];
			testFixtureClassTreeNode = (CodeCoverageTreeNode)codeCoverageModuleTreeNode.Nodes[2];
		
			// Initialise the beta namespace tree node.
			betaNamespaceTreeNode.PerformInitialization();
			anotherTestFixtureTreeNode = (CodeCoverageTreeNode)betaNamespaceTreeNode.Nodes[0];
			testFixtureTreeNode = (CodeCoverageTreeNode)betaNamespaceTreeNode.Nodes[1];
		
			// Initialise the test fixture class tree node
			testFixtureTreeNode.PerformInitialization();
			addNodeTestTreeNode = (CodeCoverageTreeNode)testFixtureTreeNode.Nodes[0];
			removeMarkersTestTreeNode = (CodeCoverageTreeNode)testFixtureTreeNode.Nodes[1];
		
			// Initialise the anotherTestFixtureTreeNode
			anotherTestFixtureTreeNode.PerformInitialization();
		}
		CodeCoverageMethod AddMethod(CodeCoverageModule module, string className, XElement reader)
		{
			CodeCoverageMethod method = new CodeCoverageMethod(className, reader);
			module.Methods.Add(method);
			var points = reader
				.Elements("SequencePoints")
				.Elements("SequencePoint");
			foreach (XElement point in points) {
				AddSequencePoint(method, point, reader);
			}
			return method;
		}
		/// <summary>
		/// Add module if it does not already exist.
		/// </summary>
		CodeCoverageModule AddModule(XElement reader, string className)
		{
			string assemblyName = GetAssemblyName(reader);
			CodeCoverageModule module = null;
			foreach (CodeCoverageModule existingModule in modules) {
				if (existingModule.Name == assemblyName) {
					module = existingModule;
					break;
				}
			}
			if (module == null) {
				module = new CodeCoverageModule(assemblyName);
				modules.Add(module);
			}
			var methods = reader
				.Elements("Classes")
				.Elements("Class")
				.Where(c => c.Element("FullName").Value.Equals(className, StringComparison.Ordinal))
				.Elements("Methods")
				.Elements("Method");
			foreach (XElement method in methods) {
				AddMethod(module, className, method);
			}
			return module;
		}
 public CodeCoverageModuleTreeNode(CodeCoverageModule module)
     : base(module, CodeCoverageImageListIndex.Module)
 {
     this.module = module;
     AddDummyNodeIfModuleHasNoMethods();
 }
		/// <summary>
		/// Add module if it does not already exist.
		/// </summary>
		CodeCoverageModule AddModule(XmlReader reader)
		{
			string id = reader.GetAttribute("asmref");
			string assemblyName = GetAssembly(id);
			foreach (CodeCoverageModule existingModule in modules) {
				if (existingModule.Name == assemblyName) {
					return existingModule;
				}
			}
			
			CodeCoverageModule module = new CodeCoverageModule(assemblyName);
			modules.Add(module);
			return module;
		}