Ejemplo n.º 1
0
 protected virtual string PathTo(TreeNode givenNode)
 {
     StringBuilder nodePath = new StringBuilder();
     List<TreeNode> selectedNodePath = tree.GetPathTo(givenNode);
     foreach (TreeNode currentNode in selectedNodePath)
     {
         nodePath.AppendFormat("\"{0}\"", currentNode.Name);
         if (!selectedNodePath[selectedNodePath.Count - 1].Equals(currentNode)) nodePath.Append(",");
     }
     return nodePath.ToString();
 }
Ejemplo n.º 2
0
                private static TestGroup ParseTestGroup(TreeNode testGroupNode)
                {
                    TestGroup testGroup = new TestGroup(testGroupNode.Text);

                    testGroupNode.Expand();
                    for (int i = 0; i < testGroupNode.Nodes.Count; i++)
                    {
                        if (i < testGroupNode.Nodes.Count - 1)
                        {
                            EnsureTestCaseNodeIsOnScreen(testGroupNode.Nodes[i + 1]);
                        }
                        testGroup.Add(ParseTestCase(testGroupNode.Nodes[i]));
                    }

                    return testGroup;
                }
Ejemplo n.º 3
0
                private static TestCase ParseTestCase(TreeNode testNode)
                {
                    TestCase testResult = new TestCase();
                    testNode.Get<Label>("TestListViewDisplayNameTextBlock").Click();
                    testNode.Nodes.Count.Should().Be(0, "Test case tree node expected to have no children.");

                    SearchCriteria isControlTypeLabel = SearchCriteria.ByControlType(typeof(Label), WindowsFramework.Wpf);
                    // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
                    foreach (Label label in GetTestExplorerDetailsPanel().GetMultiple(isControlTypeLabel))
                    {
                        if (label.IsOffScreen || string.IsNullOrWhiteSpace(label.Text))
                            continue;

                        AddInfoFromDetailPane(testResult, label);
                    }

                    return testResult;
                }
Ejemplo n.º 4
0
 public TreeNodeSelectEvent(Tree tree, TreeNode node)
     : base(tree)
 {
     selectedNode = node;
 }
Ejemplo n.º 5
0
        private void CheckEntityProperties(TreeNode node, string entityType, string entityProperty, string propertyValue)
        {
            Dte.ExecuteCommand("View.EntityDataModelBrowser");
            ((ExpandCollapsePattern)node.AutomationElement.GetCurrentPattern(ExpandCollapsePattern.Pattern)).Expand();
            foreach (var childNode in node.Nodes)
            {
                var currentNode = _entityNames.Find(el => el.Equals(childNode.Text));
                if (string.IsNullOrEmpty(currentNode))
                {
                    continue;
                }
                Assert.AreEqual(string.Format(entityType, currentNode), childNode.Text);
                Dte.ExecuteCommand("View.EntityDataModelBrowser");
                ((ExpandCollapsePattern)childNode.AutomationElement.GetCurrentPattern(ExpandCollapsePattern.Pattern)).Expand();
                foreach (var propertyNode in childNode.Nodes)
                {
                    Dte.ExecuteCommand("View.EntityDataModelBrowser");
                    ((SelectionItemPattern)propertyNode.AutomationElement.GetCurrentPattern(SelectionItemPattern.Pattern)).Select();
                    var cleanProperty = propertyNode.Text.Replace(entityProperty, "");

                    CheckProperties(string.Format(propertyValue, ModelName, currentNode, cleanProperty));
                    Assert.IsTrue(_entityAttributes.Contains(cleanProperty));
                }
            }
        }
Ejemplo n.º 6
0
 public TreeNodeClickedEvent(Tree tree, TreeNode node, bool isExpanded) : base(tree)
 {
     clickedNode = node;
     this.isExpanded = isExpanded;
 }
Ejemplo n.º 7
0
 public virtual void Accept(TreeNode treeNode)
 {
     if (treeNode.Bounds.Top <= Mouse.Instance.Location.Y && treeNode.Bounds.Bottom >= Mouse.Instance.Location.Y)
         clickedNode = treeNode;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Finds path to the TreeNode. It doesn't expand the nodes to find it.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public virtual List<TreeNode> GetPathTo(TreeNode node)
 {
     return Nodes.GetPathTo(node);
 }
Ejemplo n.º 9
0
 private static bool SafeIsNodeOnScreen(TreeNode node)
 {
     try
     {
         return node.Visible;
     }
     catch (ElementNotAvailableException)
     {
         return false;
     }
 }
Ejemplo n.º 10
0
            // ReSharper disable once UnusedMethodReturnValue.Local
            private static bool EnsureTestCaseNodeIsOnScreen(TreeNode node)
            {
                if (SafeIsNodeOnScreen(node))
                {
                    return true;
                }

                Tree tree = GetTestCaseTree();
                IVScrollBar scrollBar = tree.ScrollBars.Vertical;
                double initialValue = scrollBar.Value;
                while (scrollBar.Value < scrollBar.MaximumValue && !SafeIsNodeOnScreen(node))
                {
                    scrollBar.ScrollDownLarge();
                }

                if (!SafeIsNodeOnScreen(node))
                {
                    scrollBar.SetToMinimum();
                    while (scrollBar.Value < initialValue && !SafeIsNodeOnScreen(node))
                    {
                        scrollBar.ScrollDownLarge();
                    }
                }

                return SafeIsNodeOnScreen(node);
            }
Ejemplo n.º 11
0
 private static bool EnsureTestGroupNodeIsOnScreen(TreeNode testGroupNode)
 {
     if (!SafeIsNodeOnScreen(testGroupNode) && testGroupNode.Nodes.Count > 0)
     {
         EnsureTestCaseNodeIsOnScreen(testGroupNode.Nodes[0]);
     }
     return SafeIsNodeOnScreen(testGroupNode);
 }
Ejemplo n.º 12
0
 private static void ClickNode(TreeNode node)
 {
     EnsureTestCaseNodeIsOnScreen(node);
     node.Get<Label>("TestListViewDisplayNameTextBlock").Click();
 }
Ejemplo n.º 13
0
 private static IDictionary<string, TreeNode> FindTestCaseNodes(TreeNode testGroupNode, List<string> displayNames)
 {
     IDictionary<string, TreeNode> result = new Dictionary<string, TreeNode>();
     testGroupNode.Expand();
     for (int i = 0; result.Count < displayNames.Count && i < testGroupNode.Nodes.Count; i++)
     {
         TreeNode node = testGroupNode.Nodes[i];
         EnsureTestCaseNodeIsOnScreen(node);
         foreach (string displayName in displayNames)
         {
             if (node.Text.StartsWith(displayName))
             {
                 result.Add(displayName, node);
             }
         }
     }
     return result;
 }