public void SetUpFixture() { doc = new XmlDocument(); doc.LoadXml("<root><firstChild><secondChild/></firstChild><textChild>some text</textChild></root>"); using (XmlTreeViewControl treeView = new XmlTreeViewControl()) { treeView.Document = doc; treeView.SelectedNode = treeView.Nodes[0]; rootNodeElement = treeView.SelectedElement; isRootElementSelected = treeView.IsElementSelected; rootNode = (ExtTreeNode)treeView.SelectedNode; rootNodeHadChildrenBeforeExpansion = rootNode.Nodes.Count > 0; rootNode.Expanding(); firstChildNode = (ExtTreeNode)rootNode.Nodes[0]; firstChildNodeHadChildrenBeforeExpansion = firstChildNode.Nodes.Count > 0; firstChildNode.Expanding(); secondChildNode = (ExtTreeNode)firstChildNode.Nodes[0]; textChildNode = (ExtTreeNode)rootNode.Nodes[1]; textChildNode.Expanding(); textNode = (ExtTreeNode)textChildNode.Nodes[0]; isTextContentSelectedBeforeTextNodeSelected = treeView.IsTextNodeSelected; textContentBefore = treeView.SelectedTextNode; treeView.SelectedNode = textNode; isTextContentSelectedAfterTextNodeSelected = treeView.IsTextNodeSelected; textContentAfter = treeView.SelectedTextNode; textNodeElement = treeView.SelectedElement; } }
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 SetUp() { // Create solution. solution = new Solution(); // Create a project to display in the test tree view. project = new MockCSharpProject(); project.Name = "TestProject"; ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; testClass = new MockClass("MyTestFixture"); testClass.Attributes.Add(new MockAttribute("TestFixture")); testClass.ProjectContent = projectContent; projectContent.Classes.Add(testClass); // Init mock project content to be returned. dummyTreeView = new DummyParserServiceTestTreeView(); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. treeView = dummyTreeView as TestTreeView; solution.Folders.Add(project); treeView.AddSolution(solution); nodes = treeView.Nodes; rootNode = (ExtTreeNode)treeView.Nodes[0]; // Expand the root node so any child nodes are // lazily created. rootNode.Expanding(); rootChildNodes = rootNode.Nodes; testFixtureNode = (ExtTreeNode)rootNode.Nodes[0]; }
public void SetUp() { // Create a project to display in the test tree view. project = new MockCSharpProject(); project.Name = "TestProject"; nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); List<IProject> projects = new List<IProject>(); projects.Add(project); // Add second non-test project. projects.Add(new MockCSharpProject()); // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; testClass = new MockClass("RootNamespace.Tests.MyTestFixture"); testClass.Namespace = "RootNamespace.Tests"; testClass.Attributes.Add(new MockAttribute("TestFixture")); testClass.ProjectContent = projectContent; projectContent.Classes.Add(testClass); // Add two methods to the test class only // one of which has test attributes. testMethod = new MockMethod("NameExists"); testMethod.Attributes.Add(new MockAttribute("Test")); testMethod.DeclaringType = testClass; testClass.Methods.Add(testMethod); testClass.Methods.Add(new MockMethod()); // Add a second class that has no test fixture attribute. MockClass nonTestClass = new MockClass(); nonTestClass.ProjectContent = projectContent; projectContent.Classes.Add(nonTestClass); // Init mock project content to be returned. dummyTreeView = new DummyParserServiceTestTreeView(); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. treeView = dummyTreeView as TestTreeView; treeView.AddProjects(projects); nodes = treeView.Nodes; rootNode = (ExtTreeNode)treeView.Nodes[0]; // Expand the root node so any child nodes are // lazily created. rootNode.Expanding(); rootChildNodes = rootNode.Nodes; rootNamespaceNode = (ExtTreeNode)rootNode.Nodes[0]; // Expand the first namespace node. rootNamespaceNode.Expanding(); rootNamespaceChildNodes = rootNamespaceNode.Nodes; testsNamespaceNode = (ExtTreeNode)rootNamespaceNode.Nodes[0]; // Expand the tests namespace node. testsNamespaceNode.Expanding(); testsNamespaceChildNodes = testsNamespaceNode.Nodes; testFixtureNode = (ExtTreeNode)testsNamespaceNode.Nodes[0]; // Expand the test node. testFixtureNode.Expanding(); testFixtureChildNodes = testFixtureNode.Nodes; testNode = (ExtTreeNode)testFixtureChildNodes[0]; }