Esempio n. 1
0
        public void GetAllLoadedNodes()
        {
            /*
             * RootNode
             |-LoadedChild
             |-NotLoadedChild
             |-LoadedChild2
             |-LoadedGrandChild
             |-NotLoadedChild2
             |-LoadedGrandChild2
             */
            var treeView = new TreeView();

            ITreeNode rootNode = new MockTestNode(treeView, true)
            {
                Text = "RootNode"
            };
            var loadedChild = new MockTestNode(treeView, true)
            {
                Text = "LoadedChild"
            };

            rootNode.Nodes.Add(loadedChild);
            var notLoadedChild = new MockTestNode(treeView, false)
            {
                Text = "NotLoadedChild"
            };

            rootNode.Nodes.Add(notLoadedChild);

            var loadedChild2 = new MockTestNode(treeView, true)
            {
                Text = "LoadedChild2"
            };

            rootNode.Nodes.Add(loadedChild2);
            var loadedGrandChild = new MockTestNode(treeView, true)
            {
                Text = "LoadedGrandChild"
            };

            loadedChild2.Nodes.Add(loadedGrandChild);

            var notLoadedChild2 = new MockTestNode(treeView, false)
            {
                Text = "NotLoadedChild2"
            };

            rootNode.Nodes.Add(notLoadedChild2);
            notLoadedChild2.Nodes.Add(new MockTestNode(treeView, true)
            {
                Text = "LoadedGrandChild2"
            });
            //reset the loaded flag. It was set set to true by the previous call
            notLoadedChild2.SetLoaded(false);

            treeView.Nodes.Add(rootNode);

            Assert.AreEqual(new[] { rootNode, loadedChild, notLoadedChild, loadedChild2, loadedGrandChild, notLoadedChild2 }, treeView.AllLoadedNodes.ToArray());
        }
Esempio n. 2
0
        public void ExceptionWhenTwoNodePresentersUseTheSameNodeTagType()
        {
            var treeView = new TreeView();

            var parentNodePresenter1 = new ParentNodePresenter();
            var parentNodePresenter2 = new ParentNodePresenter();

            treeView.NodePresenters.Add(parentNodePresenter1);
            treeView.NodePresenters.Add(parentNodePresenter2);
        }
Esempio n. 3
0
        public void GetNodeByTag()
        {
            var o1 = new object();

            var       treeView = new TreeView();
            ITreeNode node     = treeView.NewNode();

            node.Tag = o1;
            treeView.Nodes.Add(node);
            ITreeNode node1 = treeView.GetNodeByTag(o1);

            Assert.AreEqual(node, node1);
        }
Esempio n. 4
0
        public void GetNodePresenterForDataType()
        {
            var presenter = mockRepository.Stub <ITreeNodePresenter>();

            Expect.Call(presenter.NodeTagType).Return(typeof(object));
            var treeView = new TreeView();

            //treeview is assigned to presenter when it's added to the list of nodepresenters
            treeView.NodePresenters.Add(presenter);
            Assert.AreEqual(treeView, presenter.TreeView);

            mockRepository.ReplayAll();
            Assert.AreEqual(presenter, treeView.GetTreeViewNodePresenter(new object()));
            mockRepository.VerifyAll();
        }
Esempio n. 5
0
        public void RefreshShouldNotRefreshNodesWhichAreNotLoaded()
        {
            var treeView = new TreeView();

            var parent = new Parent {
                Name = "parent1"
            };
            var child = new Child();

            parent.Children.Add(child);

            var parentNodePresenter = new ParentNodePresenter();
            var childNodePresenter  = new ChildNodePresenter();

            treeView.NodePresenters.Add(parentNodePresenter);
            treeView.NodePresenters.Add(childNodePresenter);

            childNodePresenter.AfterUpdate += delegate { Assert.Fail("Child nodes which are not loaded should not be updated"); };

            treeView.Refresh();
        }