public void TestBeginUpdateOnlyCalledIfNecessary()
        {
            PutInNavigationMode(NavigationPane.NavigationMode.Objects);

            MW(delegate
            {
                MainWindowTreeBuilder builder = new MainWindowTreeBuilder(MainWindowWrapper.TreeView);
                VirtualTreeNode newRoot = builder.CreateNewRootNode(TreeSearch.DefaultTreeSearch, NavigationPane.NavigationMode.Objects);
                MainWindowWrapper.TreeView.UpdateRootNodes(new [] { newRoot });  // update once to set all the node names properly
                MainWindowWrapper.TreeView.EndUpdate();

                short updateCount = GetTreeUpdateCount();

                MainWindowWrapper.TreeView.UpdateRootNodes(new[] { newRoot });  // update again: nothing should change this time

                short updateCount2 = GetTreeUpdateCount();

                Assert.AreEqual(updateCount, updateCount2, "BeginUpdate shouldn't have been called.");

                // this time there is a different node, so an update should occur
                newRoot = builder.CreateNewRootNode(TreeSearch.DefaultTreeSearch, NavigationPane.NavigationMode.Objects);
                newRoot.Nodes[0].Text = "bla";

                MainWindowWrapper.TreeView.UpdateRootNodes(new[] { newRoot });

                short updateCount3 = GetTreeUpdateCount();

                Assert.AreEqual(updateCount2 + 1, updateCount3, "BeginUpdate should have been called exactly once");

                MainWindowWrapper.TreeView.EndUpdate();

                Assert.AreEqual(0, GetTreeUpdateCount(), "FlickFreeTreeView didn't pass EndUpdate down to TreeView.");
            });
        }
 public void TestState1CorrectlyPopulatedInServerView()
 {
     MW(()=>
     {
         MainWindowTreeBuilder _treeBuilder = new MainWindowTreeBuilder(MainWindowWrapper.TreeView);
         VirtualTreeNode newRoot = _treeBuilder.CreateNewRootNode(new TreeSearchBox().Search, TreeSearchBox.Mode.Infrastructure);
         MainWindowWrapper.TreeView.UpdateRootNodes(new[] {newRoot});
         MainWindowWrapper.TreeView.EndUpdate();
         AssertTreeViewsSame(DeserializeTreeView("state1.treeview.serverview.xml").Nodes, MainWindowWrapper.TreeView.Nodes);
     });
 }
        public void TestState1CorrectlyPopulatedInOrgView()
        {
            MW(() =>
            {
                MainWindowTreeBuilder _treeBuilder = new MainWindowTreeBuilder(MainWindowWrapper.TreeView);
                VirtualTreeNode newRoot = _treeBuilder.CreateNewRootNode(new NavigationPane().Search, NavigationPane.NavigationMode.Objects);
                MainWindowWrapper.TreeView.UpdateRootNodes(new[] { newRoot });
                MainWindowWrapper.TreeView.EndUpdate();
                AssertTreeViewsSame(DeserializeTreeView("state1.treeview.orgview.xml").Nodes, MainWindowWrapper.TreeView.Nodes);
            });

        }