Пример #1
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);
                    }
                }
            }
        }
Пример #2
0
 void AddProjectTreeNodeToTree(TestProjectTreeNode node)
 {
     if (Nodes.Count == 0)
     {
         node.AddTo(this);
     }
     else
     {
         AllTestsTreeNode allTestsNode = GetAllTestsNode();
         allTestsNode.AddProjectNode(node);
     }
 }
Пример #3
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 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));
			}
		}
Пример #5
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);
					}
				}
			}
		}
Пример #6
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);
			}
		}
Пример #7
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;
 }
Пример #8
0
		void AddProjectTreeNodeToTree(TestProjectTreeNode node)
		{
			if (Nodes.Count == 0) {
				node.AddTo(this);
			} else {
				AllTestsTreeNode allTestsNode = GetAllTestsNode();
				allTestsNode.AddProjectNode(node);
			}
		}
Пример #9
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;
		}