Ejemplo n.º 1
0
        private void RemoveFromMap(TestSuiteTreeNode node)
        {
            foreach (TestSuiteTreeNode child in node.Nodes)
            {
                RemoveFromMap(child);
            }

            treeMap.Remove(node.Test.UniqueName);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// When Collapse context menu item is clicked, collapse the node
        /// </summary>
        private void collapseMenuItem_Click(object sender, System.EventArgs e)
        {
            TestSuiteTreeNode targetNode = contextNode != null ? contextNode : (TestSuiteTreeNode)SelectedNode;

            if (targetNode != null)
            {
                targetNode.Collapse();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// When Expand context menu item is clicked, expand the node
        /// </summary>
        private void expandMenuItem_Click(object sender, System.EventArgs e)
        {
            TestSuiteTreeNode targetNode = explicitlySelectedNode != null ? explicitlySelectedNode : (TestSuiteTreeNode)SelectedNode;

            if (targetNode != null)
            {
                targetNode.Expand();
            }
        }
Ejemplo n.º 4
0
 public override void Visit(TestSuiteTreeNode node)
 {
     if (!node.Test.IsSuite && node.HasResult &&
         (node.Result.ResultState == ResultState.Failure ||
          node.Result.ResultState == ResultState.Error))
     {
         tests.Add(node.Test);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Remove a node from the tree itself and the hashtable
 /// </summary>
 /// <param name="node">Node to remove</param>
 private void RemoveNode(TestSuiteTreeNode node)
 {
     if (explicitlySelectedNode == node)
     {
         explicitlySelectedNode = null;
     }
     RemoveFromMap(node);
     node.Remove();
 }
Ejemplo n.º 6
0
        private void propertiesMenuItem_Click(object sender, System.EventArgs e)
        {
            TestSuiteTreeNode targetNode = contextNode != null ? contextNode : (TestSuiteTreeNode)SelectedNode;

            if (targetNode != null)
            {
                ShowPropertiesDialog(targetNode);
            }
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Remove a node from the tree itself and the hashtable
 /// </summary>
 /// <param name="node">Node to remove</param>
 private void RemoveNode(TestSuiteTreeNode node)
 {
     if (contextNode == node)
     {
         contextNode = null;
     }
     RemoveFromMap(node);
     node.Remove();
 }
Ejemplo n.º 8
0
        private void FindCheckedNodes(TestSuiteTreeNode node, bool topLevel)
        {
            if (node.Checked)
            {
                checkedTests.Add(new CheckedTestInfo(node.Test, topLevel));
                topLevel = false;
            }

            FindCheckedNodes(node.Nodes, topLevel);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Reload the tree with a changed test hierarchy
        /// while maintaining as much gui state as possible
        /// </summary>
        /// <param name="test">Test suite to be loaded</param>
        public void Reload(UITestNode test)
        {
            TestSuiteTreeNode rootNode = (TestSuiteTreeNode)Nodes[0];

// Temporary change till framework is updated
//			if ( !Match( rootNode, test ) )
//				throw( new ArgumentException( "Reload called with non-matching test" ) );

            UpdateNode(rootNode, test);
        }
Ejemplo n.º 10
0
        private TestSuiteTreeNode FindNode(ITest test)
        {
            TestSuiteTreeNode node = treeMap[test.TestName.UniqueName] as TestSuiteTreeNode;

            if (node == null)
            {
                node = FindNodeByName(test.TestName.FullName);
            }

            return(node);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Helper returns true if the node test is not in
        /// the list of tests provided.
        /// </summary>
        /// <param name="node">Node to examine</param>
        /// <param name="tests">List of tests to match with node</param>
        private bool NodeWasDeleted(TestSuiteTreeNode node, IList tests)
        {
            foreach (TestNode test in tests)
            {
                if (Match(node, test))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 12
0
 public override void Visit(TestSuiteTreeNode node)
 {
     if (!node.Test.IsSuite && node.Result != null && node.Result.IsFailure)
     {
         node.Checked = true;
         node.EnsureVisible();
     }
     else
     {
         node.Checked = false;
     }
 }
Ejemplo n.º 13
0
		public TestPropertiesDialog( TestSuiteTreeNode node )
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			this.node = node;
		}
Ejemplo n.º 14
0
        public TestPropertiesDialog(TestSuiteTreeNode node)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            this.node = node;
        }
Ejemplo n.º 15
0
        private void ProcessTreeNodes(TestSuiteTreeNode node)
        {
            if (IsInteresting(node))
            {
                this.Nodes.Add(new VisualTreeNode(node));
            }

            foreach (TestSuiteTreeNode childNode in node.Nodes)
            {
                ProcessTreeNodes(childNode);
            }
        }
Ejemplo n.º 16
0
        private void TestSuiteTreeView_DoubleClick(object sender, System.EventArgs e)
        {
            TestSuiteTreeNode node = SelectedNode as TestSuiteTreeNode;

            if (runCommandSupported && runCommandEnabled && node.Nodes.Count == 0 && node.Included)
            {
                runCommandEnabled = false;

                // TODO: Since this is a terminal node, don't use a category filter
                RunTests(new ITest[] { SelectedTest }, true);
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Helper expands all fixtures under a node
 /// </summary>
 /// <param name="node">Node under which to expand fixtures</param>
 private void ExpandFixturesUnderNode(TestSuiteTreeNode node)
 {
     if (node.Test.IsFixture)
     {
         node.Expand();
     }
     else
     {
         foreach (TestSuiteTreeNode child in node.Nodes)
         {
             ExpandFixturesUnderNode(child);
         }
     }
 }
Ejemplo n.º 18
0
        protected override void OnAfterSelect(System.Windows.Forms.TreeViewEventArgs e)
        {
            explicitlySelectedNode = null;

            if (!suppressEvents)
            {
                if (SelectedTestChanged != null)
                {
                    SelectedTestChanged(SelectedTest);
                }

                base.OnAfterSelect(e);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Helper collapses all fixtures under a node
 /// </summary>
 /// <param name="node">Node under which to collapse fixtures</param>
 private void CollapseFixturesUnderNode(TestSuiteTreeNode node)
 {
     if (node.Test.IsFixture)
     {
         node.Collapse();
     }
     else
     {
         foreach (TestSuiteTreeNode child in node.Nodes)
         {
             CollapseFixturesUnderNode(child);
         }
     }
 }
Ejemplo n.º 20
0
 public override void Visit(TestSuiteTreeNode node)
 {
     if (!node.Test.IsSuite && node.HasResult &&
         (node.Result.ResultState == ResultState.Failure ||
          node.Result.ResultState == ResultState.Error))
     {
         node.Checked = true;
         node.EnsureVisible();
     }
     else
     {
         node.Checked = false;
     }
 }
Ejemplo n.º 21
0
        private void failedAssumptionsMenuItem_Click(object sender, System.EventArgs e)
        {
            TestSuiteTreeNode targetNode = explicitlySelectedNode != null ? explicitlySelectedNode : (TestSuiteTreeNode)SelectedNode;
            TestSuiteTreeNode theoryNode = targetNode != null?targetNode.GetTheoryNode() : null;

            if (theoryNode != null)
            {
                MenuItem item = (MenuItem)sender;

                BeginUpdate();
                item.Checked = !item.Checked;
                theoryNode.ShowFailedAssumptions = item.Checked;
                EndUpdate();
            }
        }
Ejemplo n.º 22
0
        public void Restore(TestSuiteTreeView treeView)
        {
            treeView.CheckBoxes = this.ShowCheckBoxes;

            foreach (VisualTreeNode visualNode in this.Nodes)
            {
                TestSuiteTreeNode treeNode = treeView[visualNode.UniqueName];
                if (treeNode != null)
                {
                    if (treeNode.IsExpanded != visualNode.Expanded)
                    {
                        treeNode.Toggle();
                    }

                    treeNode.Checked = visualNode.Checked;
                }
            }

            if (this.SelectedNode != null)
            {
                TestSuiteTreeNode treeNode = treeView[this.SelectedNode];
                if (treeNode != null)
                {
                    treeView.SelectedNode = treeNode;
                }
            }

            if (this.TopNode != null)
            {
                TestSuiteTreeNode treeNode = treeView[this.TopNode];
                if (treeNode != null)
                {
                    treeView.TopNode = treeNode;
                }
            }

            if (this.SelectedCategories != null)
            {
                TestFilter filter = new CategoryFilter(this.SelectedCategories.Split(new char[] { ',' }));
                if (this.ExcludeCategories)
                {
                    filter = new NotFilter(filter);
                }
                treeView.CategoryFilter = filter;
            }

            treeView.Select();
        }
Ejemplo n.º 23
0
        public VisualTreeNode(TestSuiteTreeNode treeNode)
        {
            this.UniqueName = treeNode.Test.TestName.UniqueName;
            this.Expanded   = treeNode.IsExpanded;
            this.Checked    = treeNode.Checked;
            int count = treeNode.Nodes.Count;

            if (count > 0)
            {
                this.Nodes = new VisualTreeNode[count];
                for (int i = 0; i < count; i++)
                {
                    this.Nodes[i] = new VisualTreeNode((TestSuiteTreeNode)treeNode.Nodes[i]);
                }
            }
        }
Ejemplo n.º 24
0
        private void AddToMap(TestSuiteTreeNode node)
        {
            string key = node.Test.TestName.UniqueName;

            if (treeMap.ContainsKey(key))
            {
                Trace.WriteLine("Duplicate entry: " + key);
            }
            //				UserMessage.Display( string.Format(
            //					"The test {0} is duplicated\r\rResults will not be displayed correctly in the tree.", node.Test.FullName ), "Duplicate Test" );
            else
            {
                //Trace.WriteLine( "Added to map: " + node.Test.UniqueName );
                treeMap.Add(key, node);
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Gets the Theory node associated with the current
        /// node. If the current node is a Theory, then the
        /// current node is returned. Otherwise, if the current
        /// node is a test case under a theory node, then that
        /// node is returned. Otherwise, null is returned.
        /// </summary>
        /// <returns></returns>
        public TestSuiteTreeNode GetTheoryNode()
        {
            if (this.Test.TestType == "Theory")
            {
                return(this);
            }

            TestSuiteTreeNode parent = this.Parent as TestSuiteTreeNode;

            if (parent != null && parent.Test.TestType == "Theory")
            {
                return(parent);
            }

            return(null);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Add the result of a test to the tree
        /// </summary>
        /// <param name="result">The result of the test</param>
        public void SetTestResult(TestResult result)
        {
            TestSuiteTreeNode node = this[result];

            if (node == null)
            {
                throw new ArgumentException("Test not found in tree");
            }

            node.SetResult(result);

            if (DisplayTestProgress)
            {
                Invalidate(node.Bounds);
                Update();
            }
        }
Ejemplo n.º 27
0
 private void ShowPropertiesDialog(TestSuiteTreeNode node)
 {
     if (propertiesDialog == null)
     {
         Form owner = this.FindForm();
         propertiesDialog               = new TestPropertiesDialog(node);
         propertiesDialog.Owner         = owner;
         propertiesDialog.StartPosition = FormStartPosition.Manual;
         propertiesDialog.Left          = owner.Left + (owner.Width - propertiesDialog.Width) / 2;
         propertiesDialog.Top           = owner.Top + (owner.Height - propertiesDialog.Height) / 2;
         propertiesDialog.Show();
         propertiesDialog.Closed += new EventHandler(OnPropertiesDialogClosed);
     }
     else
     {
         propertiesDialog.DisplayProperties(node);
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Add nodes to the tree constructed from a test
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection to which the new node should  be added</param>
        /// <param name="rootTest">The test for which a node is to be built</param>
        /// <param name="highlight">If true, highlight the text for this node in the tree</param>
        /// <returns>A newly constructed TestNode, possibly with descendant nodes</returns>
        private TestSuiteTreeNode AddTreeNodes(IList nodes, ITest rootTest, bool highlight)
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(rootTest);

//			if ( highlight ) node.ForeColor = Color.Blue;
            treeMap.Add(node.Test.UniqueName, node);
            nodes.Add(node);

            if (rootTest.IsSuite)
            {
                foreach (UITestNode test in rootTest.Tests)
                {
                    AddTreeNodes(node.Nodes, test, highlight);
                }
            }

            return(node);
        }
Ejemplo n.º 29
0
        /// <summary>
        /// A node has been matched with a test, so update it
        /// and then process child nodes and tests recursively.
        /// If a child was added or removed, then this node
        /// will expand itself.
        /// </summary>
        /// <param name="node">Node to be updated</param>
        /// <param name="test">Test to plug into node</param>
        /// <returns>True if a child node was added or deleted</returns>
        private bool UpdateNode(TestSuiteTreeNode node, UITestNode test)
        {
            node.UpdateTest(test);

            if (!test.IsSuite)
            {
                return(false);
            }

            bool showChildren = UpdateNodes(node.Nodes, test.Tests);

            if (showChildren)
            {
                node.Expand();
            }

            return(showChildren);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Load the tree with a test hierarchy
        /// </summary>
        /// <param name="test">Test to be loaded</param>
        public void Load(TestNode test)
        {
            using (new CP.Windows.Forms.WaitCursor())
            {
                Clear();
                BeginUpdate();

                try
                {
                    AddTreeNodes(Nodes, test, false);
                    SetInitialExpansion();
                }
                finally
                {
                    EndUpdate();
                    contextNode = null;
                }
            }
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Add nodes to the tree constructed from a test
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection to which the new node should  be added</param>
        /// <param name="rootTest">The test for which a node is to be built</param>
        /// <param name="highlight">If true, highlight the text for this node in the tree</param>
        /// <returns>A newly constructed TestNode, possibly with descendant nodes</returns>
        private TestSuiteTreeNode AddTreeNodes(IList nodes, TestNode rootTest, bool highlight)
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode(rootTest);

            //			if ( highlight ) node.ForeColor = Color.Blue;
            AddToMap(node);

            nodes.Add(node);

            if (rootTest.IsSuite)
            {
                foreach (TestNode test in rootTest.Tests)
                {
                    AddTreeNodes(node.Nodes, test, highlight);
                }
            }

            return(node);
        }
Ejemplo n.º 32
0
 private bool IsInteresting(TestSuiteTreeNode node)
 {
     return node.IsExpanded || node.Checked;
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Helper routine that compares a node with a test
 /// </summary>
 /// <param name="node">Node to compare</param>
 /// <param name="test">Test to compare</param>
 /// <returns>True if the test has the same name</returns>
 private bool Match( TestSuiteTreeNode node, TestNode test )
 {
     return node.Test.TestName.FullName == test.TestName.FullName;
 }
Ejemplo n.º 34
0
        private void OnTestUnloaded( object sender, TestEventArgs e)
        {
            ClosePropertiesDialog();

            if ( Services.UserSettings.GetSetting( "Gui.TestTree.SaveVisualState", true ) && loader != null)
                try
                {
                    new VisualState(this).Save(VisualState.GetVisualStateFileName(loader.TestFileName));
                }
                catch(Exception ex)
                {
                    Debug.WriteLine( "Unable to save visual state." );
                    Debug.WriteLine( ex );
                }

            Clear();
            contextNode = null;
            runCommandEnabled = false;
        }
Ejemplo n.º 35
0
 public override void Visit(TestSuiteTreeNode node)
 {
     if (!node.Test.IsSuite && node.Result != null &&
             (node.Result.ResultState == ResultState.Failure ||
              node.Result.ResultState == ResultState.Error) )
     {
         tests.Add(node.Test);
         filter.Add(node.Test.TestName);
     }
 }
        public TestPropertiesDialog(TestSuiteTreeNode node)
        {
            InitializeComponent();

            this.node = node;
        }
Ejemplo n.º 37
0
		/// <summary>
		/// Match a set of nodes against a set of tests.
		/// Remove nodes that are no longer represented
		/// in the tests. Update any nodes that match.
		/// Add new nodes for new tests.
		/// </summary>
		/// <param name="nodes">List of nodes to be matched</param>
		/// <param name="tests">List of tests to be matched</param>
        /// <param name="deletedNodes">List of nodes previously removed,
        /// in case they show up lower in the tree.</param>
		/// <returns>True if the parent should expand to show that something was added or deleted</returns>
		private bool UpdateNodes( IList nodes, IList tests, IList deletedNodes )
		{
			// As of NUnit 2.3.6006, the newly reloaded tests 
			// are guaranteed to be in the same order as the
			// originally loaded tests. Hence, we can merge
			// the two lists. However, we can only use an
			// equality comparison, since we don't know what
			// determines the order. Hence the two passes.

			bool showChanges = false;

			// Pass1: delete nodes that are not in the list of tests.
            // Some of these nodes may reappear lower in the tree,
            // if we are switching from fixture display to tree display,
            // so we save them for checking later.
			int nodeIndex = nodes.Count;
			while( --nodeIndex >= 0 )
			{
				TestSuiteTreeNode node = (TestSuiteTreeNode)nodes[nodeIndex];
				if ( NodeWasDeleted( node, tests ) )
				{
					log.Debug( "Deleting " + node.Test.TestName.Name );
                    deletedNodes.Add(node);
					RemoveNode( node );
					showChanges = true;
				}
			}

			// Pass2: All nodes in the node list are also
			// in the tests, so we can merge in changes
			// and add any new nodes.
			nodeIndex = 0;
			foreach( TestNode test in tests )
			{
				TestSuiteTreeNode node = nodeIndex < nodes.Count ? (TestSuiteTreeNode)nodes[nodeIndex] : null;

				if ( node != null && node.Test.TestName.FullName == test.TestName.FullName )
					UpdateNode( node, test, deletedNodes );
				else
				{
                    // Create a new node or use a deleted node
					TestSuiteTreeNode newNode = null;
                    
                    // Check previously deleted nodes
                    foreach( TestSuiteTreeNode deletedNode in deletedNodes )
                        if (deletedNode.Test.TestName.FullName == test.TestName.FullName)
                        {
                            newNode = deletedNode;
                            deletedNodes.Remove(deletedNode);
                            break;
                        }

                    // If not found, it's completely new
                    if (newNode == null)
                        newNode = new TestSuiteTreeNode(test);

					AddToMap( newNode );
					nodes.Insert( nodeIndex, newNode );
			
					if ( test.IsSuite )
					{
                        if ( UpdateNodes(newNode.Nodes, test.Tests, deletedNodes) )
                            newNode.Expand();
                        //foreach( TestNode childTest in test.Tests )
                        //    AddTreeNodes(newNode.Nodes, childTest, false);
					}

					showChanges = true;
				}

				nodeIndex++;
			}

			return showChanges;
		}
Ejemplo n.º 38
0
		/// <summary>
		/// Helper returns true if the node test is not in
		/// the list of tests provided.
		/// </summary>
		/// <param name="node">Node to examine</param>
		/// <param name="tests">List of tests to match with node</param>
		private bool NodeWasDeleted( TestSuiteTreeNode node, IList tests )
		{
			foreach ( TestNode test in tests )
				if( Match( node, test ) )
					return false;

			return true;
		}
Ejemplo n.º 39
0
        /// <summary>
        /// Helper collapses all fixtures under a node
        /// </summary>
        /// <param name="node">Node under which to collapse fixtures</param>
        private void HideTestsUnderNode( TestSuiteTreeNode node )
        {
            bool expand = false;
            foreach( TestSuiteTreeNode child in node.Nodes )
                if ( child.Test.IsSuite )
                {
                    expand = true;
                    HideTestsUnderNode( child );
                }

            if ( expand )
                node.Expand();
            else
                node.Collapse();
        }
Ejemplo n.º 40
0
        private TestSuiteTreeNode AddTreeNodes( IList nodes, TestResult rootResult, bool highlight )
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode( rootResult );
            AddToMap( node );

            nodes.Add( node );

            if ( rootResult.HasResults )
            {
                foreach( TestResult result in rootResult.Results )
                    AddTreeNodes( node.Nodes, result, highlight );
            }

            node.UpdateImageIndex();

            return node;
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Add nodes to the tree constructed from a test
        /// </summary>
        /// <param name="nodes">The TreeNodeCollection to which the new node should  be added</param>
        /// <param name="rootTest">The test for which a node is to be built</param>
        /// <param name="highlight">If true, highlight the text for this node in the tree</param>
        /// <returns>A newly constructed TestNode, possibly with descendant nodes</returns>
        private TestSuiteTreeNode AddTreeNodes( IList nodes, TestNode rootTest, bool highlight )
        {
            TestSuiteTreeNode node = new TestSuiteTreeNode( rootTest );
            //			if ( highlight ) node.ForeColor = Color.Blue;
            AddToMap( node );

            nodes.Add( node );

            if ( rootTest.IsSuite )
            {
                foreach( TestNode test in rootTest.Tests )
                    AddTreeNodes( node.Nodes, test, highlight );
            }

            return node;
        }
Ejemplo n.º 42
0
        private void AddToMap( TestSuiteTreeNode node )
        {
            string key = node.Test.TestName.UniqueName;

            if ( treeMap.ContainsKey( key ) )
                log.Error( "Duplicate entry: " + key );
                //				UserMessage.Display( string.Format(
                //					"The test {0} is duplicated\r\rResults will not be displayed correctly in the tree.", node.Test.FullName ), "Duplicate Test" );
            else
            {
                log.Debug( "Added to map: " + node.Test.TestName.UniqueName );
                treeMap.Add( key, node );
            }
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Handles right mouse button down by
        /// remembering the proper context item
        /// and implements multiple select with the left button.
        /// </summary>
        /// <param name="e">MouseEventArgs structure with information about the mouse position and button state</param>
        protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right )
            {
                CheckPropertiesDialog();
                TreeNode theNode = GetNodeAt( e.X, e.Y );
                contextNode = theNode as TestSuiteTreeNode;
            }
            //			else if (e.Button == MouseButtons.Left )
            //			{
            //				if ( Control.ModifierKeys == Keys.Control )
            //				{
            //					TestSuiteTreeNode theNode = GetNodeAt( e.X, e.Y ) as TestSuiteTreeNode;
            //					if ( theNode != null )
            //						theNode.IsSelected = true;
            //				}
            //				else
            //				{
            //					ClearSelected();
            //				}
            //			}

            base.OnMouseDown( e );
        }
Ejemplo n.º 44
0
 public override void Visit( TestSuiteTreeNode node )
 {
     node.Included = filter.Pass( node.Test );
 }
Ejemplo n.º 45
0
        /// <summary>
        /// Load the tree with a test hierarchy
        /// </summary>
        /// <param name="test">Test to be loaded</param>
        public void Load( TestNode test )
        {
            using( new CP.Windows.Forms.WaitCursor() )
            {
                Clear();
                BeginUpdate();

                try
                {

                    AddTreeNodes( Nodes, test, false );
                    SetInitialExpansion();
                }
                finally
                {
                    EndUpdate();
                    contextNode = null;
                    this.Select();
                }

                if ( Services.UserSettings.GetSetting( "Gui.TestTree.SaveVisualState", true ) && loader != null)
                    RestoreVisualState();
            }
        }
Ejemplo n.º 46
0
        private void ProcessTreeNodes(TestSuiteTreeNode node)
        {
            if (IsInteresting(node))
                this.Nodes.Add(new VisualTreeNode(node));

            foreach (TestSuiteTreeNode childNode in node.Nodes)
                ProcessTreeNodes(childNode);
        }
Ejemplo n.º 47
0
		public VisualTreeNode( TestSuiteTreeNode treeNode )
		{
			this.UniqueName = treeNode.Test.TestName.UniqueName;
			this.Expanded = treeNode.IsExpanded;
			this.Checked = treeNode.Checked;
		}
Ejemplo n.º 48
0
        /// <summary>
        /// A node has been matched with a test, so update it
        /// and then process child nodes and tests recursively.
        /// If a child was added or removed, then this node
        /// will expand itself.
        /// </summary>
        /// <param name="node">Node to be updated</param>
        /// <param name="test">Test to plug into node</param>
        /// <returns>True if a child node was added or deleted</returns>
        private bool UpdateNode( TestSuiteTreeNode node, TestNode test, IList deletedNodes )
        {
            if ( node.Test.TestName.FullName != test.TestName.FullName )
                throw( new TreeStructureChangedException(
                    string.Format( "Attempting to update {0} with {1}", node.Test.TestName.FullName, test.TestName.FullName ) ) );

            treeMap.Remove( node.Test.TestName.UniqueName );
            node.Test = test;
            treeMap.Add( test.TestName.UniqueName, node );

            if ( !test.IsSuite )
                return false;

            bool showChildren = UpdateNodes( node.Nodes, test.Tests, deletedNodes );

            if ( showChildren ) node.Expand();

            return showChildren;
        }
Ejemplo n.º 49
0
 private void ShowPropertiesDialog( TestSuiteTreeNode node )
 {
     if ( propertiesDialog == null )
     {
         Form owner = this.FindForm();
         propertiesDialog = new TestPropertiesDialog( node );
         propertiesDialog.Owner = owner;
         propertiesDialog.StartPosition = FormStartPosition.Manual;
         propertiesDialog.Left = Math.Max(0, owner.Left + ( owner.Width - propertiesDialog.Width ) / 2);
         propertiesDialog.Top = Math.Max(0, owner.Top + ( owner.Height - propertiesDialog.Height ) / 2);
         propertiesDialog.Show();
         propertiesDialog.Closed += new EventHandler( OnPropertiesDialogClosed );
     }
     else
     {
         propertiesDialog.DisplayProperties( node );
     }
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Remove a node from the tree itself and the hashtable
 /// </summary>
 /// <param name="node">Node to remove</param>
 private void RemoveNode( TestSuiteTreeNode node )
 {
     if ( contextNode == node )
         contextNode = null;
     RemoveFromMap( node );
     node.Remove();
 }
        public void DisplayProperties(TestSuiteTreeNode node)
        {
            this.node = node;
            this.test = node.Test;
            this.result = node.Result;

            SetTitleBarText();

            testResult.Text = node.StatusText;
            testResult.Font = new Font(this.Font, FontStyle.Bold);
            if (node.TestType == "Project" || node.TestType == "Assembly")
                testName.Text = Path.GetFileName(test.TestName.Name);
            else
                testName.Text = test.TestName.Name;

            testType.Text = node.TestType;
            fullName.Text = test.TestName.FullName;
            description.Text = test.Description;

            StringBuilder sb1 = new StringBuilder();
            foreach (string cat in test.Categories)
                if (sb1.Length > 0)
                {
                    sb1.Append(", ");
                    sb1.Append(cat);
                }
            categories.Text = sb1.ToString();

            testCaseCount.Text = test.TestCount.ToString();

            switch (test.RunState)
            {
                case RunState.Explicit:
                    shouldRun.Text = "Explicit";
                    break;
                case RunState.Runnable:
                    shouldRun.Text = "Yes";
                    break;
                default:
                    shouldRun.Text = "No";
                    break;
            }
            ignoreReason.Text = test.IgnoreReason;

            FillPropertyList();

            elapsedTime.Text = "Execution Time:";
            assertCount.Text = "Assert Count:";
            message.Text = "";
            stackTrace.Text = "";

            if (result != null)
            {
                elapsedTime.Text = string.Format("Execution Time: {0}", result.Time);

                assertCount.Text = string.Format("Assert Count: {0}", result.AssertCount);
                // message may have a leading blank line
                // TODO: take care of this in label?
                if (result.Message != null)
                {
                    if (result.Message.Length > 64000)
                        message.Text = TrimLeadingBlankLines(result.Message.Substring(0, 64000));
                    else
                        message.Text = TrimLeadingBlankLines(result.Message);
                }

                stackTrace.Text = result.StackTrace;
            }

            BeginPanel();

            CreateRow(testTypeLabel, testType);
            CreateRow(fullNameLabel, fullName);
            CreateRow(descriptionLabel, description);
            CreateRow(categoriesLabel, categories);
            CreateRow(testCaseCountLabel, testCaseCount, shouldRunLabel, shouldRun);
            CreateRow(ignoreReasonLabel, ignoreReason);
            CreateRow(propertiesLabel, properties);
            CreateRow(hiddenProperties);

            groupBox1.ClientSize = new Size(
                groupBox1.ClientSize.Width, maxY + 12);

            groupBox2.Location = new Point(
                groupBox1.Location.X, groupBox1.Bottom + 12);

            BeginPanel();

            CreateRow(elapsedTime, assertCount);
            CreateRow(messageLabel, message);
            CreateRow(stackTraceLabel, stackTrace);

            groupBox2.ClientSize = new Size(
                groupBox2.ClientSize.Width, this.maxY + 12);

            this.ClientSize = new Size(
                this.ClientSize.Width, groupBox2.Bottom + 12);
        }
Ejemplo n.º 52
0
 private void RemoveFromMap( TestSuiteTreeNode node )
 {
     foreach( TestSuiteTreeNode child in node.Nodes )
         RemoveFromMap( child );
     treeMap.Remove( node.Test.TestName.UniqueName );
 }
Ejemplo n.º 53
0
        /// <summary>
        /// Match a set of nodes against a set of tests.
        /// Remove nodes that are no longer represented
        /// in the tests. Update any nodes that match.
        /// Add new nodes for new tests.
        /// </summary>
        /// <param name="nodes">List of nodes to be matched</param>
        /// <param name="tests">List of tests to be matched</param>
        /// <param name="deletedNodes">List of nodes previously removed,
        /// in case they show up lower in the tree.</param>
        /// <returns>True if the parent should expand to show that something was added or deleted</returns>
        private bool UpdateNodes( IList nodes, IList tests, IList deletedNodes )
        {
            // For NUnit 2.4 and the original release of 2.5, the newly
            // reloaded tests were guaranteed to be in the same order as
            // the originally loaded tests, so we simply merged the two
            // lists. Beginning with NUnit 2.5.1, this is no longer
            // guaranteed - parameterized tests may be re-ordered within
            // their containing suite. Therefore, we no longer rely on
            // ordering of tests within a suite.

            bool showChanges = false;

            // We use two passes to keep the code as simple as possible
            //
            // Pass1: delete nodes that are not in the list of tests.
            // Some of these nodes may reappear lower in the tree,
            // if we are switching from fixture display to tree display,
            // so we save them for checking later.
            int nodeIndex = nodes.Count;
            while( --nodeIndex >= 0 )
            {
                TestSuiteTreeNode node = (TestSuiteTreeNode)nodes[nodeIndex];
                if ( !IsTestInList( node.Test, tests ) )
                {
                    log.Debug( "Deleting " + node.Test.TestName.Name );
                    deletedNodes.Add(node);
                    RemoveNode( node );
                    showChanges = true;
                }
            }

            // Pass2: All nodes in the node list are also
            // in the tests, so we can merge in changes
            // and add any new nodes.
            nodeIndex = 0;
            foreach( TestNode test in tests )
            {
                TestSuiteTreeNode node = nodeIndex < nodes.Count ? (TestSuiteTreeNode)nodes[nodeIndex] : null;

                if ( node != null && node.Test.TestName.FullName == test.TestName.FullName )
                    UpdateNode( node, test, deletedNodes );
                else
                {
                    TestSuiteTreeNode newNode = null;
                    for (int i = nodeIndex + 1; i < nodes.Count; i++)
                    {
                        TestSuiteTreeNode tryNode = (TestSuiteTreeNode)nodes[i];
                        if (tryNode.Test.TestName.FullName == test.TestName.FullName)
                        {
                            // Exchange the two nodes
                            nodes.Remove(tryNode);
                            if (node != null) nodes.Remove(node);

                            nodes.Insert(nodeIndex, tryNode);
                            if ( node != null )nodes.Insert(i, node);

                            UpdateNode(tryNode, test, deletedNodes);
                            newNode = tryNode;
                            break;
                        }
                    }

                    // Create a new node or use a deleted node
                    if (newNode == null)
                    {
                        // Check previously deleted nodes
                        foreach (TestSuiteTreeNode deletedNode in deletedNodes)
                            if (deletedNode.Test.TestName.FullName == test.TestName.FullName)
                            {
                                newNode = deletedNode;
                                deletedNodes.Remove(deletedNode);
                                break;
                            }

                        // If not found, it's completely new
                        if (newNode == null)
                            newNode = new TestSuiteTreeNode(test);

                        AddToMap(newNode);
                        nodes.Insert(nodeIndex, newNode);

                        if (test.IsSuite)
                        {
                            if (UpdateNodes(newNode.Nodes, test.Tests, deletedNodes))
                                newNode.Expand();
                            //foreach( TestNode childTest in test.Tests )
                            //    AddTreeNodes(newNode.Nodes, childTest, false);
                        }

                        showChanges = true;
                    }
                }

                nodeIndex++;
            }

            return showChanges;
        }
		public override void Visit(TestSuiteTreeNode node)
		{
			if (!node.Test.IsSuite && node.HasResult && 
                    (node.Result.ResultState == ResultState.Failure || 
                     node.Result.ResultState == ResultState.Error) )
			{
				tests.Add(node.Test);
			}
		}
Ejemplo n.º 55
0
        private void FindCheckedNodes( TestSuiteTreeNode node, bool topLevel )
        {
            if ( node.Checked )
            {
                checkedTests.Add( new CheckedTestInfo( node.Test, topLevel ) );
                topLevel = false;
            }

            FindCheckedNodes( node.Nodes, topLevel );
        }
Ejemplo n.º 56
0
 public override void Visit(TestSuiteTreeNode node)
 {
     if (!node.Test.IsSuite && node.Result != null &&
         (node.Result.ResultState == ResultState.Failure ||
          node.Result.ResultState == ResultState.Error) )
     {
         node.Checked = true;
         node.EnsureVisible();
     }
     else
         node.Checked = false;
 }
Ejemplo n.º 57
0
		public void DisplayProperties( TestSuiteTreeNode node)
		{
			this.node = node;
			this.test = node.Test;
			this.result = node.Result;

			SetTitleBarText();

			categories.Items.Clear();
			foreach( string cat in test.Categories )
				categories.Items.Add( cat );

			testResult.Text = node.StatusText;
			testName.Text = test.TestName.Name;

			testType.Text = node.TestType;
			fullName.Text = test.TestName.FullName;
			switch( test.RunState )
			{
				case RunState.Explicit:
					shouldRun.Text = "Explicit";
					break;
				case RunState.Runnable:
					shouldRun.Text = "Yes";
					break;
				default:
					shouldRun.Text = "No";
					break;
			}
			description.Text = test.Description;
			ignoreReason.Text = test.IgnoreReason;
			testCaseCount.Text = test.TestCount.ToString();
			properties.Items.Clear();
			foreach( DictionaryEntry entry in test.Properties )
				properties.Items.Add( entry.Key + "=" + entry.Value.ToString() );

			message.Text = "";
			elapsedTime.Text = "Execution Time:";
			assertCount.Text = "Assert Count:";
			stackTrace.Text = "";

			if ( result != null )
			{
				// message may have a leading blank line
				// TODO: take care of this in label?
                if (result.Message != null)
                {
                    if (result.Message.Length > 64000)
                        message.Text = TrimLeadingBlankLines(result.Message.Substring(0, 64000));
                    else
                        message.Text = TrimLeadingBlankLines(result.Message);
                }

				elapsedTime.Text = string.Format( "Execution Time: {0}", result.Time );
				assertCount.Text = string.Format( "Assert Count: {0}", result.AssertCount );
				stackTrace.Text = result.StackTrace;
			}
		}
Ejemplo n.º 58
0
 public override void Visit(TestSuiteTreeNode node)
 {
     node.Checked = false;
 }
Ejemplo n.º 59
0
		public abstract void Visit(TestSuiteTreeNode node);
		/// <summary>
		/// Helper collapses all fixtures under a node
		/// </summary>
		/// <param name="node">Node under which to collapse fixtures</param>
		private void HideTestsUnderNode( TestSuiteTreeNode node )
		{
            if (node.Test.IsSuite)
            {
                if (node.Test.TestType == "TestFixture")
                    node.Collapse();
                else
                {
                    node.Expand();

                    foreach (TestSuiteTreeNode child in node.Nodes)
                        HideTestsUnderNode(child);
                }
            }
		}