/// <summary>
		/// Removes the project node.
		/// </summary>
		public void RemoveProjectNode(TestProjectTreeNode node)
		{
			if (Nodes.Contains(node)) {
				node.ImageIndexChanged -= TestProjectTreeNodeImageIndexChanged;
				node.Remove();
			}
		}
Esempio n. 2
0
        /// <summary>
        /// Removes the specified project from the test tree view.
        /// </summary>
        public void RemoveProject(IProject project)
        {
            TestProjectTreeNode projectNode = GetProjectTreeNode(project);

            RemoveProjectNode(projectNode);
            RemoveAllTestsNodeIfOnlyOneProjectLeft();
        }
Esempio n. 3
0
        /// <summary>
        /// Adds the project to the test tree view if the project
        /// has a reference to a supported test framework.
        /// </summary>
        /// <remarks>
        /// If the project is already in the tree then it will
        /// not be added again. If a project is already in the tree then
        /// an All Tests root node will be added.
        /// </remarks>
        public void AddProject(IProject project)
        {
            if (TestProject.IsTestProject(project))
            {
                if (GetProjectTreeNode(project) == null)
                {
                    // Add a new tree node.
                    IProjectContent projectContent = GetProjectContent(project);
                    if (projectContent != null)
                    {
                        TestProject         testProject = new TestProject(project, projectContent);
                        TestProjectTreeNode node        = new TestProjectTreeNode(testProject);

                        if (Nodes.Count == 0)
                        {
                            node.AddTo(this);
                        }
                        else
                        {
                            AllTestsTreeNode allTestsNode = GetAllTestsNode();
                            allTestsNode.AddProjectNode(node);
                        }

                        // Sort the nodes.
                        SortNodes(Nodes, true);
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Removes the project node.
 /// </summary>
 public void RemoveProjectNode(TestProjectTreeNode node)
 {
     if (Nodes.Contains(node))
     {
         node.ImageIndexChanged -= TestProjectTreeNodeImageIndexChanged;
         node.Remove();
     }
 }
Esempio n. 5
0
        void AddProjectTreeNode(IProject project)
        {
            TestProjectTreeNode node = CreateProjectTreeNode(project);

            if (node != null)
            {
                AddProjectTreeNodeToTree(node);
                SortNodes(Nodes, true);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Returns the TestProject associated with the specified project.
        /// </summary>
        public TestProject GetTestProject(IProject project)
        {
            TestProjectTreeNode node = GetProjectTreeNode(project);

            if (node != null)
            {
                return(node.TestProject);
            }
            return(null);
        }
Esempio n. 7
0
 void AddProjectTreeNodeToTree(TestProjectTreeNode node)
 {
     if (Nodes.Count == 0)
     {
         node.AddTo(this);
     }
     else
     {
         AllTestsTreeNode allTestsNode = GetAllTestsNode();
         allTestsNode.AddProjectNode(node);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Removes the specified project from the test tree view.
        /// </summary>
        public void RemoveProject(IProject project)
        {
            TestProjectTreeNode projectNode = GetProjectTreeNode(project);

            RemoveProjectNode(projectNode);

            // Remove the All Tests node if it exists and there
            // is only one project tree node left.
            if (allTestsNode != null && GetProjectNodes().Count == 1)
            {
                RemoveAllTestsNode();
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Removes the project node from the tree.
 /// </summary>
 void RemoveProjectNode(TestProjectTreeNode projectNode)
 {
     if (projectNode != null)
     {
         if (allTestsNode != null)
         {
             allTestsNode.RemoveProjectNode(projectNode);
         }
         else
         {
             projectNode.Remove();
         }
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Adds or removes a project from the test tree view based on
        /// whether a reference to a testing framework has been added or
        /// removed.
        /// </summary>
        public void ProjectReferencesChanged(IProject project)
        {
            TestProjectTreeNode projectNode = GetProjectTreeNode(project);

            if (TestProject.IsTestProject(project))
            {
                if (projectNode == null)
                {
                    TestProject testProject = new TestProject(project, GetProjectContent(project));
                    projectNode = new TestProjectTreeNode(testProject);
                    projectNode.AddTo(this);
                }
            }
            else
            {
                RemoveProjectNode(projectNode);
            }
        }
		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();
		}
		public void TreeNodeContextMenuMatches()
		{
			using (DerivedTestTreeView treeView = new DerivedTestTreeView()) {
				ContextMenuStrip menuStrip = new ContextMenuStrip();
				treeView.ContextMenuStrip = menuStrip;
				
				// Add a root node to the tree.
				TestProject project = new TestProject(new MockCSharpProject(), new MockProjectContent(), new MockTestFrameworksWithNUnitFrameworkSupport());
				TestProjectTreeNode node = new TestProjectTreeNode(project);
				node.AddTo(treeView);
				
				// Select the tree node.
				treeView.SelectedNode = node;
				
				// Call the treeView's OnBeforeSelect so the context menu 
				// is connected to the tree node.
				treeView.CallOnBeforeSelect(new TreeViewCancelEventArgs(node, false, TreeViewAction.ByMouse));
				
				// Context menu strip on tree node should match
				// the tree view's context menu strip.
				Assert.IsTrue(Object.ReferenceEquals(menuStrip, node.ContextMenuStrip));
			}
		}
Esempio n. 13
0
		/// <summary>
		/// Adds the project to the test tree view if the project
		/// has a reference to a supported test framework.
		/// </summary>
		/// <remarks>
		/// If the project is already in the tree then it will 
		/// not be added again. If a project is already in the tree then
		/// an All Tests root node will be added.
		/// </remarks>
		public void AddProject(IProject project)
		{
			if (TestProject.IsTestProject(project)) {
				if (GetProjectTreeNode(project) == null) {
					// Add a new tree node.
					IProjectContent projectContent = GetProjectContent(project);
					if (projectContent != null) {
						TestProject testProject = new TestProject(project, projectContent);
						TestProjectTreeNode node = new TestProjectTreeNode(testProject);
						
						if (Nodes.Count == 0) {
							node.AddTo(this);
						} else {
							AllTestsTreeNode allTestsNode = GetAllTestsNode();
							allTestsNode.AddProjectNode(node);
						}
						
						// Sort the nodes.
						SortNodes(Nodes, true);
					}
				}
			}
		}
Esempio n. 14
0
		/// <summary>
		/// Removes the project node from the tree.
		/// </summary>
		void RemoveProjectNode(TestProjectTreeNode projectNode)
		{
			if (projectNode != null) {
				if (allTestsNode != null) {
					allTestsNode.RemoveProjectNode(projectNode);
				} else {
					projectNode.Remove();
				}
			}
		}
Esempio n. 15
0
		/// <summary>
		/// Adds or removes a project from the test tree view based on 
		/// whether a reference to a testing framework has been added or
		/// removed.
		/// </summary>
		public void ProjectReferencesChanged(IProject project)
		{
			TestProjectTreeNode projectNode = GetProjectTreeNode(project);
			if (TestProject.IsTestProject(project)) {
				if (projectNode == null) {
					TestProject testProject = new TestProject(project, GetProjectContent(project));
					projectNode = new TestProjectTreeNode(testProject);
					projectNode.AddTo(this);
				}
			} else {
				RemoveProjectNode(projectNode);
			}
		}
		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");
		}
Esempio n. 17
0
		/// <summary>
		/// Adds a new project node as a child of the All Tests node.
		/// </summary>
		public void AddProjectNode(TestProjectTreeNode node)
		{
			node.AddTo(this);
			node.ImageIndexChanged += TestProjectTreeNodeImageIndexChanged;
		}
Esempio n. 18
0
 /// <summary>
 /// Adds a new project node as a child of the All Tests node.
 /// </summary>
 public void AddProjectNode(TestProjectTreeNode node)
 {
     node.AddTo(this);
     node.ImageIndexChanged += TestProjectTreeNodeImageIndexChanged;
 }
Esempio n. 19
0
		void AddProjectTreeNodeToTree(TestProjectTreeNode node)
		{
			if (Nodes.Count == 0) {
				node.AddTo(this);
			} else {
				AllTestsTreeNode allTestsNode = GetAllTestsNode();
				allTestsNode.AddProjectNode(node);
			}
		}