/// <summary> /// Creates a new TestNamespaceTreeNode /// </summary> /// <remarks> /// Note that the Namespace child nodes are added in /// the constructor not whilst the node is expanding /// via the Initialize method. This is so the icon for the /// node can be updated even if the parent node is not /// expanded. The alternative is to have each namespace node, /// even if it does not have any class child nodes, to /// store all the classes that are below it in the tree and /// update the icon based on their results. The assumption /// is that there are fewer namespace nodes than classes so /// adding the namespace nodes here does not matter. /// </remarks> /// <param name="namespacePrefix">The first part of the /// namespace (including any dot characters) before this /// particular namespace.</param> /// <param name="name">The name of the namespace without any /// dot characters (e.g. the name at this particular /// location in the tree).</param> public TestNamespaceTreeNode(TestProject testProject, string namespacePrefix, string name) : base(testProject, name) { ns = name; this.namespacePrefix = namespacePrefix; fullNamespace = GetFullNamespace(namespacePrefix, ns); GetTestClasses(); testProject.TestClasses.TestClassAdded += TestClassAdded; testProject.TestClasses.TestClassRemoved += TestClassRemoved; // Add namespace nodes - do not add them on node expansion. foreach (string namespaceName in TestProject.GetChildNamespaces(fullNamespace)) { TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, fullNamespace, namespaceName); node.AddTo(this); namespaceChildNodes.Add(node); node.ImageIndexChanged += TestNamespaceNodeImageIndexChanged; } // Add a dummy node if there are no namespaces since // there might be class nodes which will be added // lazily when the node is expanded. if (namespaceChildNodes.Count == 0) { dummyNode = new ExtTreeNode(); Nodes.Add(dummyNode); } UpdateImageListIndex(); }
/// <summary> /// Creates a new TestNamespaceTreeNode /// </summary> /// <remarks> /// Note that the Namespace child nodes are added in /// the constructor not whilst the node is expanding /// via the Initialize method. This is so the icon for the /// node can be updated even if the parent node is not /// expanded. The alternative is to have each namespace node, /// even if it does not have any class child nodes, to /// store all the classes that are below it in the tree and /// update the icon based on their results. The assumption /// is that there are fewer namespace nodes than classes so /// adding the namespace nodes here does not matter. /// </remarks> /// <param name="namespacePrefix">The first part of the /// namespace (including any dot characters) before this /// particular namespace.</param> /// <param name="name">The name of the namespace without any /// dot characters (e.g. the name at this particular /// location in the tree).</param> public TestNamespaceTreeNode(TestProject testProject, string namespacePrefix, string name) : base(testProject, name) { ns = name; this.namespacePrefix = namespacePrefix; fullNamespace = GetFullNamespace(namespacePrefix, ns); GetTestClasses(); testProject.TestClasses.TestClassAdded += TestClassAdded; testProject.TestClasses.TestClassRemoved += TestClassRemoved; // Add namespace nodes - do not add them on node expansion. foreach (string namespaceName in TestProject.GetChildNamespaces(fullNamespace)) { TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, fullNamespace, namespaceName); node.AddTo(this); namespaceChildNodes.Add(node); node.ImageIndexChanged += TestNamespaceNodeImageIndexChanged; } // Add a dummy node if there are no namespaces since // there might be class nodes which will be added // lazily when the node is expanded. if (namespaceChildNodes.Count == 0) { dummyNode = new ExtTreeNode(); Nodes.Add(dummyNode); } UpdateImageListIndex(); }
/// <summary> /// A new test class has been added to the project so a new /// tree node is added if the class belongs to this namespace. /// </summary> void TestClassAdded(object source, TestClassEventArgs e) { if (e.TestClass.Namespace == fullNamespace) { // Add test class to our monitored test classes. testClasses.Add(e.TestClass); // Add a new tree node. TestClassTreeNode classNode = new TestClassTreeNode(TestProject, e.TestClass); classNode.AddTo(this); // Sort the nodes. SortChildNodes(); } else if (isInitialized && NamespaceStartsWith(e.TestClass.Namespace)) { // Check if there is a child namespace node for the class. string childNamespace = TestClass.GetChildNamespace(e.TestClass.Namespace, fullNamespace); if (!NamespaceNodeExists(childNamespace)) { // Add a new namespace node. TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, fullNamespace, childNamespace); node.AddTo(this); // Sort the nodes. SortChildNodes(); } } }
/// <summary> /// Adds a new class node to this project node if the /// class added has no root namespace. /// </summary> void TestClassAdded(object source, TestClassEventArgs e) { if (e.TestClass.Namespace == String.Empty) { AddClassNode(e.TestClass); SortChildNodes(); } else if (isInitialized) { // Check that we have a namespace node for this class. if (!NamespaceNodeExists(e.TestClass.RootNamespace)) { // Add a new namespace node. TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, e.TestClass.RootNamespace); node.AddTo(this); SortChildNodes(); } } }
/// <summary> /// Adds a new class node to this project node if the /// class added has no root namespace. /// </summary> void TestClassAdded(object source, TestClassEventArgs e) { if (e.TestClass.Namespace == String.Empty) { AddClassNode(e.TestClass); SortChildNodes(); } else if (isInitialized) { // Check that we have a namespace node for this class. if (!NamespaceNodeExists(e.TestClass.RootNamespace)) { // Add a new namespace node. TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, e.TestClass.RootNamespace); node.AddTo(this); SortChildNodes(); } } }
/// <summary> /// Adds the child nodes after this node has been expanded. /// </summary> protected override void Initialize() { Nodes.Clear(); // Add namespace nodes. foreach (string rootNamespace in TestProject.RootNamespaces) { TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, rootNamespace); node.AddTo(this); } // Add class nodes. foreach (TestClass c in TestProject.GetTestClasses(String.Empty)) { AddClassNode(c); } // Sort the nodes. SortChildNodes(); }
/// <summary> /// Adds the child nodes after this node has been expanded. /// </summary> protected override void Initialize() { Nodes.Clear(); // Add namespace nodes. foreach (string rootNamespace in TestProject.RootNamespaces) { TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, rootNamespace); node.AddTo(this); } // Add class nodes. foreach (TestClass c in TestProject.GetTestClasses(String.Empty)) { AddClassNode(c); } // Sort the nodes. SortChildNodes(); }
/// <summary> /// A new test class has been added to the project so a new /// tree node is added if the class belongs to this namespace. /// </summary> void TestClassAdded(object source, TestClassEventArgs e) { if (e.TestClass.Namespace == fullNamespace) { // Add test class to our monitored test classes. testClasses.Add(e.TestClass); // Add a new tree node. TestClassTreeNode classNode = new TestClassTreeNode(TestProject, e.TestClass); classNode.AddTo(this); // Sort the nodes. SortChildNodes(); } else if (isInitialized && NamespaceStartsWith(e.TestClass.Namespace)) { // Check if there is a child namespace node for the class. string childNamespace = TestClass.GetChildNamespace(e.TestClass.Namespace, fullNamespace); if (!NamespaceNodeExists(childNamespace)) { // Add a new namespace node. TestNamespaceTreeNode node = new TestNamespaceTreeNode(TestProject, fullNamespace, childNamespace); node.AddTo(this); // Sort the nodes. SortChildNodes(); } } }