Exemplo n.º 1
0
        public void ClassOccursBeforeNamespaceOnInitialLoad()
        {
            MockCSharpProject project = new MockCSharpProject();

            project.Name = "TestProject";
            ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);

            nunitFrameworkReferenceItem.Include = "NUnit.Framework";
            ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
            List <IProject> projects = new List <IProject>();

            projects.Add(project);

            // Add a test class with a TestFixture attributes.
            TestClass testClass = CreateTestClass("MyTests.MyTestFixture");

            projectContent.Classes.Add(testClass.Class);

            // Add a second class with no namespace.
            testClass = CreateTestClass("AppleTestFixture");
            projectContent.Classes.Add(testClass.Class);

            // Add another class that exists in a namespace inside
            // MyTests.
            testClass = CreateTestClass("MyTests.ZebraTests.AddZebra");
            projectContent.Classes.Add(testClass.Class);

            // Load the project into the tree.
            treeView.Clear();
            treeView.AddProject(project);
            projectNode = (TestProjectTreeNode)treeView.Nodes[0];
            projectNode.PerformInitialization();

            ExtTreeNode treeNode = (ExtTreeNode)projectNode.LastNode;

            treeNode.PerformInitialization();

            // Get the class node without a root namespace and
            // the my tests namespace node.
            TestClassTreeNode     appleTestFixtureNode = projectNode.FirstNode as TestClassTreeNode;
            TestNamespaceTreeNode myTestsNamespaceNode = projectNode.LastNode as TestNamespaceTreeNode;

            // Get the zebra namespace tree node.
            TestNamespaceTreeNode zebraTestsNamespaceNode = treeNode.LastNode as TestNamespaceTreeNode;

            Assert.IsNotNull(appleTestFixtureNode);
            Assert.AreEqual(appleTestFixtureNode.Text, "AppleTestFixture");
            Assert.IsNotNull(myTestsNamespaceNode);
            Assert.AreEqual(myTestsNamespaceNode.Text, "MyTests");
            Assert.IsNotNull(zebraTestsNamespaceNode);
            Assert.AreEqual(zebraTestsNamespaceNode.Text, "ZebraTests");
        }
Exemplo n.º 2
0
        public void Init()
        {
            // Create a project to display in the test tree view.
            MockCSharpProject project = new MockCSharpProject();

            project.Name = "TestProject";
            ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project);

            nunitFrameworkReferenceItem.Include = "NUnit.Framework";
            ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem);
            List <IProject> projects = new List <IProject>();

            projects.Add(project);

            // Add a test class with a TestFixture attributes.
            projectContent          = new MockProjectContent();
            projectContent.Language = LanguageProperties.None;
            TestClass testClass = CreateTestClass("MyTests.MyTestFixture");

            projectContent.Classes.Add(testClass.Class);

            // Add two methods to the test class only
            // one of which has test attributes.
            MockMethod testMethod = new MockMethod("NameExists");

            testMethod.Attributes.Add(new MockAttribute("Test"));
            testMethod.DeclaringType = testClass.Class;
            testClass.Class.Methods.Add(testMethod);

            // Init mock project content to be returned.
            treeView = new DummyParserServiceTestTreeView();
            treeView.ProjectContentForProject = projectContent;

            // Load the projects into the test tree view.
            treeView.AddProjects(projects);
            projectNode = (TestProjectTreeNode)treeView.Nodes[0];
            testProject = projectNode.TestProject;

            // Initialise the root node so the child nodes are created.
            projectNode.PerformInitialization();
            myTestsNamespaceNode = (TestNamespaceTreeNode)projectNode.FirstNode;

            // Initialise the first namespace node.
            myTestsNamespaceNode.PerformInitialization();
            testFixtureNode = (TestClassTreeNode)myTestsNamespaceNode.FirstNode;

            // Initialise the test method tree nodes.
            testFixtureNode.PerformInitialization();
        }