상속: System.Windows.Controls.TreeViewItem
예제 #1
0
        public void find_immediate_treenode_parent_as_top()
        {
            var parent = new TreeNode(new Test("name"));
            parent.Items.Add(node);

            node.Top().ShouldBeTheSameAs(parent);
        }
        public void can_get_contextual_commands_for_a_TreeNode()
        {
            var node = new TreeNode(new Test("test1"));
            IEnumerable<IContextualAction> actions = _objectLocator.BuildActions(node);

            actions.Count(x => x is CollapseAllCommand).ShouldEqual(1);
            actions.Count(x => x is ExpandAllCommand).ShouldEqual(1);
        }
 public static void Show(TreeNode hierarchyNode)
 {
     List<TreeNodeToken> list = getActual(hierarchyNode);
     foreach (TreeNodeToken token in list)
     {
         Debug.WriteLine(token);
     }
 }
 private static void addChildren(TreeNode node, List<TreeNodeToken> actual)
 {
     foreach (TreeNode child in node.Items)
     {
         addToken(child, actual);
         addChildren(child, actual);
     }
 }
예제 #5
0
        public void add_a_test_node_directly_to_the_hierarchy()
        {
            var top = new TreeNode(new Hierarchy("project1"));
            var builder = new TreeBuilder(top);

            var test = new Test("test1");
            builder.Test(test);

            top.Children.ShouldEqual(new INamedItem[] {test});
        }
예제 #6
0
        public void add_a_suite_node_directly_to_the_hierarchy()
        {
            var top = new TreeNode(new Hierarchy("project1"));
            var builder = new TreeBuilder(top);

            var suite = new Suite("suite1");
            builder.StartSuite(suite);

            top.Children.ShouldEqual(new INamedItem[] {suite});
        }
예제 #7
0
        public void find_ultimate_anscestor_as_top()
        {
            var parent = new TreeNode(new Test("name"));
            parent.Items.Add(node);

            var top = new TreeNode(new Hierarchy("project"));
            top.Items.Add(parent);

            node.Top().ShouldBeTheSameAs(top);
        }
예제 #8
0
        public void add_suite_then_add_test()
        {
            var top = new TreeNode(new Hierarchy("project1"));
            var builder = new TreeBuilder(top);
            var suite = new Suite("suite1");
            var test = new Test("test1");

            builder.StartSuite(suite);
            builder.Test(test);

            top.Items[0].ShouldBeOfType<TreeNode>().Children.ShouldEqual(new INamedItem[] {test});
        }
        private static void addToken(TreeNode node, List<TreeNodeToken> actual)
        {
            string locator = node.Subject.GetPath().Locator;
            string typeName = node.Subject.GetType().Name.ToLower();
            var token = new TreeNodeToken
            {
                Path = locator,
                Type = typeName
            };

            actual.Add(token);
        }
예제 #10
0
        public void ctrl_left_clicking_the_node_fires_the_on_run_node_gesture()
        {
            TreeNode nodeThatWasCalled = null;
            var parent = new TreeNode(new Test("name"));
            parent.Items.Add(node);

            var top = new TreeNode(new Hierarchy("project"));
            top.Items.Add(parent);
            top.OnRunNodeGesture = n => nodeThatWasCalled = n.Top();

            ControlDriver.ExecuteMouseGestureCommand(node, new MouseGesture(MouseAction.LeftClick, ModifierKeys.Control));
            nodeThatWasCalled.ShouldBeTheSameAs(top);
        }
예제 #11
0
        public IList<ActionMenuItem> BuildMenuItems(TreeNode node)
        {
            var list = new List<ActionMenuItem>();

            IEnumerable<ActionMenuItem> nodeItems = _screenObjects.BuildActions(node).Select(x => new ActionMenuItem(x));
            IEnumerable<ActionMenuItem> subjectItems =
                _screenObjects.BuildActions(node.Subject).Select(x => new ActionMenuItem(x));

            list.AddRange(nodeItems);
            list.AddRange(subjectItems);

            return list;
        }
예제 #12
0
        public void add_suite_then_add_test_then_finish_suite_then_add_test_directly_to_hierarchy()
        {
            var top = new TreeNode(new Hierarchy("project1"));
            var builder = new TreeBuilder(top);
            var suite = new Suite("suite1");
            var test1 = new Test("test1");
            var test2 = new Test("test2");

            builder.StartSuite(suite);
            builder.Test(test1);
            builder.EndSuite(suite);
            builder.Test(test2);

            top.Children.ShouldEqual(new INamedItem[] {suite, test2});
        }
예제 #13
0
        public void double_clicking_fires_the_OnSelection_action_on_the_top()
        {
            TreeNode nodeThatWasCalled = null;

            var parent = new TreeNode(new Test("name"));
            parent.Items.Add(node);

            var top = new TreeNode(new Hierarchy("project"));
            top.Items.Add(parent);
            top.OnSelection = n => nodeThatWasCalled = n.Top();

            ControlDriver.FireEvent(node, "MouseDoubleClick");

            nodeThatWasCalled.ShouldBeTheSameAs(top);
        }
        public void AssertMatch(TreeNode hierarchyNode)
        {
            List<TreeNodeToken> actual = getActual(hierarchyNode);

            try
            {
                Assert.AreEqual(_tokens.Count, actual.Count, "the count");
                actual.ShouldHaveTheSameElementsAs((IList) _tokens);
            }
            catch (Exception)
            {
                actual.ForEach(x => Debug.WriteLine(x));

                throw;
            }
        }
예제 #15
0
 public void RunNode(TreeNode node)
 {
     IContextualAction action = null;
     //Something smells.  I can't quite make out what it is.  Oh wait, it's this LSP violation.
     if (node.Subject is Suite)
     {
         action = _screenObjects.CommandForSubject<RunSuiteCommand, Suite>(node.Subject);
     }
     else
     {
         action = _screenObjects.CommandForSubject<RunTestCommand, Test>(node.Subject);
     }
     if(action != null)
     {
         action.Execute();
     }
 }
예제 #16
0
 public bool Equals(TreeNode obj)
 {
     if (ReferenceEquals(null, obj)) return false;
     if (ReferenceEquals(this, obj)) return true;
     return base.Equals(obj) && Equals(obj._subject, _subject);
 }
예제 #17
0
        private void activateNode(TreeNode node, TreeView tree)
        {
            if (tree.Items.Count > 0)
            {
                tree.Items[0].As<TreeNode>().OnSelection = n => { };
            }

            tree.Items.Clear();
            node.IsExpanded = true;

            node.OnSelection = n => SelectNode(n);
            node.OnRunNodeGesture = n => RunNode(n);
            node.BuildItems = n => BuildMenuItems(n);

            tree.Items.Add(node);
        }
예제 #18
0
        public void update_icon_two_levels_up()
        {
            var veryTop = new TreeNode(new FixtureLibrary());
            veryTop.Add(top);
            veryTop.Add(new TreeNode(new FixtureLibrary()));

            veryTop.NodeAt(1).Icon = Icon.Success;
            top.NodeAt(3).Icon = Icon.Failed;

            veryTop.Icon.ShouldEqual(Icon.Failed);
        }
예제 #19
0
 public void Remove(TreeNode node)
 {
     Items.Remove(node);
 }
예제 #20
0
 public void SetUp()
 {
     test = new Test("some test");
     node = new TreeNode(test);
 }
예제 #21
0
 public void SetUp()
 {
     top = new TreeNode(new FixtureLibrary());
     top.Add(new TreeNode(new FixtureLibrary()));
     top.Add(new TreeNode(new FixtureLibrary()));
     top.Add(new TreeNode(new FixtureLibrary()));
     top.Add(new TreeNode(new FixtureLibrary()));
     top.Add(new TreeNode(new FixtureLibrary()));
 }
 private static List<TreeNodeToken> getActual(TreeNode hierarchyNode)
 {
     var actual = new List<TreeNodeToken>();
     addChildren(hierarchyNode, actual);
     return actual;
 }
예제 #23
0
        public void UpdateIcon()
        {
            if (Items.Count == 0) return;

            var nodes = new TreeNode[Items.Count];
            Items.CopyTo(nodes, 0);

            Icon = nodes.Select(x => x.As<TreeNode>().Icon).OrderBy(x => x).First();
            updateParentIcon();
        }
예제 #24
0
 public TreeBuilder(TreeNode topNode)
     : this(topNode, new TestNodeCache(), new SuiteNodeCache())
 {
 }
예제 #25
0
 public TreeBuilder(TreeNode topNode, TestNodeCache testCache, SuiteNodeCache suiteCache)
 {
     _testCache = testCache;
     _suiteCache = suiteCache;
     _parent.Push(topNode);
 }
예제 #26
0
        private void activateNode(TreeNode node, TreeView tree)
        {
            tree.Items.Clear();
            node.IsExpanded = true;

            node.BuildItems = n => BuildMenuItems(n);

            tree.Items.Add(node);
        }
예제 #27
0
 public void ApplyFixtureNode(TreeNode node)
 {
     activateNode(node, _fixtureTree);
 }
예제 #28
0
 public void ApplyProjectNode(TreeNode node)
 {
     activateNode(node, _testTree);
 }
예제 #29
0
        public void SelectNode(TreeNode node)
        {
            if (_latched)
            {
                if (ReferenceEquals(node, node.Top()))
                {
                    _latched = false;
                }

                return;
            }

            // TODO -- harden this
            _conductor.OpenScreen(node.Subject);
            _latched = true;
        }
예제 #30
0
        public void Add(TreeNode node)
        {
            node.ClearParent();

            Items.Add(node);
        }