Index: Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs =================================================================== diff -u -r3a2348c5fe73aa8d0979407c45ce70519288cf3f -rfafe08c402bd6ab5a283556660e34df47ce01dea --- Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision 3a2348c5fe73aa8d0979407c45ce70519288cf3f) +++ Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision fafe08c402bd6ab5a283556660e34df47ce01dea) @@ -113,6 +113,14 @@ } } + public object SelectedData + { + get + { + return treeView.SelectedNode != null ? treeView.SelectedNode.Tag : null; + } + } + /// /// This method registers the provided . /// @@ -196,18 +204,6 @@ return treeNode != null ? treeNode.FullPath : ""; } - /// - /// This method searches all nodes in the tree view for a node with a matching tag. - /// - /// The node data to search the corresponding for. - /// The corresponding the provided node data or null if not found. - public TreeNode GetNodeByTag(object nodeData) - { - var node = treeView.Nodes.Count > 0 ? GetNodeByTag(treeView.Nodes[0], nodeData) : null; - - return node; - } - private bool CanRename(TreeNode treeNode) { var treeNodeInfo = GetTreeNodeInfoForData(treeNode.Tag); @@ -281,6 +277,18 @@ return result; } + /// + /// This method searches all nodes in the tree view for a node with a matching tag. + /// + /// The node data to search the corresponding for. + /// The corresponding the provided node data or null if not found. + private TreeNode GetNodeByTag(object nodeData) + { + var node = treeView.Nodes.Count > 0 ? GetNodeByTag(treeView.Nodes[0], nodeData) : null; + + return node; + } + private static TreeNode GetNodeByTag(TreeNode rootNode, object tag) { if (Equals(rootNode.Tag, tag)) Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj =================================================================== diff -u -r8598c47dd25fb62ccaab803cc9fc01e7b0be5299 -rfafe08c402bd6ab5a283556660e34df47ce01dea --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj (.../Core.Plugins.ProjectExplorer.Test.csproj) (revision 8598c47dd25fb62ccaab803cc9fc01e7b0be5299) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/Core.Plugins.ProjectExplorer.Test.csproj (.../Core.Plugins.ProjectExplorer.Test.csproj) (revision fafe08c402bd6ab5a283556660e34df47ce01dea) @@ -121,6 +121,10 @@ {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} Core.Common.Gui + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E} Core.Common.Gui.TestUtil Index: Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs =================================================================== diff -u -rb8e09b3d2c44242360c4426659bcf30a0d674df3 -rfafe08c402bd6ab5a283556660e34df47ce01dea --- Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision b8e09b3d2c44242360c4426659bcf30a0d674df3) +++ Core/Plugins/test/Core.Plugins.ProjectExplorer.Test/ProjectExplorerTest.cs (.../ProjectExplorerTest.cs) (revision fafe08c402bd6ab5a283556660e34df47ce01dea) @@ -8,6 +8,7 @@ using Core.Common.Gui.Forms; using Core.Common.Gui.Selection; using Core.Common.TestUtil; +using Core.Common.Utils.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -222,16 +223,15 @@ }) { WindowsFormsTestHelper.Show(explorer.TreeViewControl); - var node = explorer.TreeViewControl.GetNodeByTag(stringA); // Precondition - Assert.IsFalse(node.IsSelected); + Assert.AreNotSame(explorer.TreeViewControl.SelectedData, stringA); // Call explorer.TreeViewControl.SelectNodeForData(stringA); // Assert - Assert.IsTrue(node.IsSelected); + Assert.AreSame(explorer.TreeViewControl.SelectedData, stringA); } WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll(); @@ -280,11 +280,10 @@ form.Controls.Add(explorer); form.Show(); - var node = explorer.TreeViewControl.GetNodeByTag(project); - node.TreeView.Name = treeIdentifier; + TypeUtils.GetField(explorer.TreeViewControl, "treeView").Name = treeIdentifier; // Precondition - Assert.IsTrue(node.IsSelected); + Assert.AreSame(explorer.TreeViewControl.SelectedData, project); var tester = new TreeViewTester(treeIdentifier); @@ -341,16 +340,15 @@ }) { WindowsFormsTestHelper.Show(explorer.TreeViewControl); - var node = explorer.TreeViewControl.GetNodeByTag(project); // Precondition - Assert.IsTrue(node.IsSelected); + Assert.AreSame(explorer.TreeViewControl.SelectedData, project); // Call applicationSelection.Raise(s => s.SelectionChanged += null, null, new SelectedItemChangedEventArgs(null)); // Assert - Assert.IsTrue(node.IsSelected); + Assert.AreSame(explorer.TreeViewControl.SelectedData, project); } WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll(); @@ -404,16 +402,15 @@ }) { WindowsFormsTestHelper.Show(explorer.TreeViewControl); - var node = explorer.TreeViewControl.GetNodeByTag(stringA); // Precondition - Assert.IsFalse(node.IsSelected); + Assert.AreNotSame(explorer.TreeViewControl.SelectedData, stringA); // Call applicationSelection.Raise(s => s.SelectionChanged += null, null, new SelectedItemChangedEventArgs(stringA)); // Assert - Assert.IsTrue(node.IsSelected); + Assert.AreSame(explorer.TreeViewControl.SelectedData, stringA); } WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll();