示例#1
0
 private void EnsureNonRunnableFilesAreVisible(TestNode testNode)
 {
     // HACK: Temporary fix switches the display strategy if no
     // tests are found. Should handle other error situations
     // including one non-runnable file out of several files.
     if (testNode.TestCount == 0)
     {
         Strategy = new NUnitTreeDisplayStrategy(_view, _model);
     }
 }
示例#2
0
        private void CreateDisplayStrategy(string format)
        {
            switch (format.ToUpperInvariant())
            {
            default:
            case "NUNIT_TREE":
                Strategy = new NUnitTreeDisplayStrategy(_view, _model);
                break;

            case "FIXTURE_LIST":
                Strategy = new FixtureListDisplayStrategy(_view, _model);
                break;

            case "TEST_LIST":
                Strategy = new TestListDisplayStrategy(_view, _model);
                break;
            }
        }
        private void CreateDisplayStrategy(string format)
        {
            switch (format.ToUpperInvariant())
            {
            default:
            case "NUNIT_TREE":
                _strategy = new NUnitTreeDisplayStrategy(_view, _model);
                break;

            case "FIXTURE_LIST":
                _strategy = new FixtureListDisplayStrategy(_view, _model);
                break;

            case "TEST_LIST":
                _strategy = new TestListDisplayStrategy(_view, _model);
                break;
            }

            _view.FormatButton.ToolTipText   = _strategy.Description;
            _view.DisplayFormat.SelectedItem = format;
        }
示例#4
0
        public override void OnTestFinished(ResultNode result)
        {
            var imageIndex = DisplayStrategy.CalcImageIndex(result.Outcome);

            if (imageIndex >= TestTreeView.SuccessIndex)
            {
                var treeNodes = _displayStrategy.GetTreeNodesForTest(result);
                foreach (var treeNode in treeNodes)
                {
                    var parentNode = treeNode.Parent;
                    if (parentNode != null)
                    {
                        var group = parentNode.Tag as TestGroup;
                        if (group != null && imageIndex > group.ImageIndex)
                        {
                            parentNode.SelectedImageIndex = parentNode.ImageIndex = group.ImageIndex = imageIndex;
                        }
                    }
                }
            }
        }
示例#5
0
        public void ChangeGroupsBasedOnTestResult(ResultNode result, bool updateImages)
        {
            var treeNodes = _displayStrategy.GetTreeNodesForTest(result);

            // Result may be for a TestNode not shown in the tree
            if (treeNodes.Count == 0)
            {
                return;
            }

            // This implementation ignores any but the first node
            // since changing of groups is currently only needed
            // for groupings that display each node once.
            var treeNode  = treeNodes[0];
            var oldParent = treeNode.Parent;
            var oldGroup  = oldParent.Tag as TestGroup;

            // We only have to proceed for tests that are direct
            // descendants of a group node.
            if (oldGroup == null)
            {
                return;
            }

            var newGroup = SelectGroups(result)[0];

            // If the group didn't change, we can get out of here
            if (oldGroup == newGroup)
            {
                return;
            }

            var newParent = newGroup.TreeNode;

            _displayStrategy.Tree.InvokeIfRequired(() =>
            {
                oldGroup.RemoveId(result.Id);
                // TODO: Insert in order
                newGroup.Add(result);

                // Remove test from tree
                treeNode.Remove();

                // If it was last test in group, remove group
                if (oldGroup.Count == 0)
                {
                    oldParent.Remove();
                }
                else // update old group
                {
                    oldParent.Text = _displayStrategy.GroupDisplayName(oldGroup);
                    if (updateImages)
                    {
                        oldParent.ImageIndex = oldParent.SelectedImageIndex = oldGroup.ImageIndex =
                            _displayStrategy.CalcImageIndexForGroup(oldGroup);
                    }
                }

                newParent.Nodes.Add(treeNode);
                newParent.Text = _displayStrategy.GroupDisplayName(newGroup);
                newParent.Expand();

                if (updateImages)
                {
                    var imageIndex = DisplayStrategy.CalcImageIndex(result.Outcome);
                    if (imageIndex >= TestTreeView.SuccessIndex && imageIndex > newGroup.ImageIndex)
                    {
                        newParent.ImageIndex = newParent.SelectedImageIndex = newGroup.ImageIndex = imageIndex;
                    }
                }

                if (newGroup.Count == 1)
                {
                    _displayStrategy.Tree.Clear();
                    TreeNode topNode = null;
                    foreach (var group in Groups)
                    {
                        if (group.Count > 0)
                        {
                            _displayStrategy.Tree.Add(group.TreeNode);
                            if (topNode == null)
                            {
                                topNode = group.TreeNode;
                            }
                        }
                    }

                    if (topNode != null)
                    {
                        topNode.EnsureVisible();
                    }
                }
            });
        }