예제 #1
0
        public TreeNode FindNodeByPath(string path, bool expandIfNeeded = false)
        {
            TreeNode nodeForPath = ObjectExplorerUtils.FindNode(this, node =>
            {
                return(node.GetNodePath() == path);
            }, nodeToFilter =>
            {
                return(path.StartsWith(nodeToFilter.GetNodePath()));
            }, expandIfNeeded);

            return(nodeForPath);
        }
예제 #2
0
        public TreeNode FindNodeByPath(string path)
        {
            TreeNode nodeForPath = ObjectExplorerUtils.FindNode(this, node =>
            {
                return(node.GetNodePath() == path);
            }, nodeToFilter =>
            {
                return(path.StartsWith(nodeToFilter.GetNodePath()));
            });

            return(nodeForPath);
        }
예제 #3
0
        public void FindNodeCanExpandParentNodes()
        {
            var mockTreeNode = new Mock <TreeNode>();

            object[] populateChildrenArguments = { ItExpr.Is <bool>(x => x == false), ItExpr.IsNull <string>() };
            mockTreeNode.Protected().Setup("PopulateChildren", populateChildrenArguments);
            mockTreeNode.Object.IsAlwaysLeaf = false;

            // If I try to find a child node of the mock tree node with the expand parameter set to true
            ObjectExplorerUtils.FindNode(mockTreeNode.Object, node => false, node => false, true);

            // Then PopulateChildren gets called to expand the tree node
            mockTreeNode.Protected().Verify("PopulateChildren", Times.Once(), populateChildrenArguments);
        }