public void EmptyNamespaceNodesRemovedWhenChildNamespaceNodeNotExpanded() { // Expand the project node. TestProjectTreeNode projectNode = (TestProjectTreeNode)pad.TestTreeView.Nodes[0]; projectNode.Expanding(); // Add a new class to a non-empty namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); // Get the root namespace node. TestNamespaceTreeNode rootNamespaceNode = (TestNamespaceTreeNode)projectNode.Nodes[0]; // Check that the rootNamespaceNode does not consider itself // empty. Assert.IsFalse(rootNamespaceNode.IsEmpty); // Expand RootNamespace tree node. rootNamespaceNode.Expanding(); // Remove the test class from the test project. projectNode.TestProject.TestClasses.Remove(testClass); Assert.AreEqual(0, projectNode.Nodes.Count, "Namespace nodes should have been removed from project node."); }
public void EmptyNamespaceNodesRemoved() { // Expand the project node. TestProjectTreeNode projectNode = (TestProjectTreeNode)pad.TestTreeView.Nodes[0]; projectNode.Expanding(); // Add a new class to a non-empty namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); // Expand RootNamespace tree node. TestNamespaceTreeNode rootNamespaceNode = (TestNamespaceTreeNode)projectNode.Nodes[0]; rootNamespaceNode.Expanding(); // Expand the Tests namespace tree node. TestNamespaceTreeNode testsNamespaceNode = (TestNamespaceTreeNode)rootNamespaceNode.Nodes[0]; testsNamespaceNode.Expanding(); // Get the test class node. TestClassTreeNode classNode = (TestClassTreeNode)testsNamespaceNode.Nodes[0]; // Remove the test class from the test project. projectNode.TestProject.TestClasses.Remove(testClass); Assert.AreEqual(0, projectNode.Nodes.Count, "Namespace nodes should have been removed from project node."); // Make sure the two namespace nodes are properly disposed. Assert.IsTrue(testsNamespaceNode.IsDisposed); Assert.IsTrue(rootNamespaceNode.IsDisposed); // Make sure the test class node has been disposed. Assert.IsTrue(classNode.IsDisposed); // Make sure the namespace node Dispose method removes // the TestProject.TestClasses.TestClassAdded event handler. Assert.AreEqual(0, testsNamespaceNode.Nodes.Count); projectNode.TestProject.TestClasses.Add(testClass); Assert.AreEqual(0, testsNamespaceNode.Nodes.Count); }
public void ClassNodeAddedAfterProjectNodeExpanded() { // Expand the project node. TestProjectTreeNode projectNode = (TestProjectTreeNode)pad.TestTreeView.Nodes[0]; projectNode.Expanding(); // Add a new class to a non-empty namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.MyTestFixture"); TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); Assert.AreEqual(1, projectNode.Nodes.Count, "Project node should have one child node."); }