Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r63c199ecc57c7d9344fce238426ed51bbf352552 -rfd18531c4e5f5c1effb5d8dc2797c5cd57dd2aed --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 63c199ecc57c7d9344fce238426ed51bbf352552) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision fd18531c4e5f5c1effb5d8dc2797c5cd57dd2aed) @@ -1089,8 +1089,8 @@ public void GetContextMenu_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup + var tag = new object(); var gui = mocks.StrictMock(); - var treeViewControl = mocks.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new PipingCalculationGroup(); var nodeData = new PipingCalculationGroupContext(group, @@ -1103,10 +1103,12 @@ var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); - var newCalculationGroupContextNode = new TreeNode(); + var treeViewControl = mocks.StrictMock(); + treeViewControl.Expect(tvc => tvc.SelectNodeForData(tag)); + var newCalculationGroupContextNode = new TreeNode { Tag = tag }; + // Parent node of newly added item, should be expanded from collapsed state to show selected node: - var treeView = new TreeView(); var parentNode = new TreeNode(); var node = new TreeNode { @@ -1117,8 +1119,6 @@ parentNode.Nodes.Add(node); - treeView.Nodes.Add(parentNode); - gui.Expect(cmp => cmp.Get(node, info, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); @@ -1144,18 +1144,15 @@ Assert.AreEqual("Nieuwe map (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); - Assert.AreSame(newCalculationGroupContextNode, treeView.SelectedNode, - "The node of the newly added item should be selected."); - mocks.VerifyAll(); } [Test] public void GetContextMenu_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers() { // Setup + var tag = new object(); var gui = mocks.StrictMock(); - var treeViewControl = mocks.StrictMock(); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var group = new PipingCalculationGroup(); var nodeData = new PipingCalculationGroupContext(group, @@ -1168,10 +1165,12 @@ var observer = mocks.StrictMock(); observer.Expect(o => o.UpdateObserver()); - var newCalculationContextNode = new TreeNode(); + var treeViewControl = mocks.StrictMock(); + treeViewControl.Expect(tvc => tvc.SelectNodeForData(tag)); + var newCalculationContextNode = new TreeNode { Tag = tag }; + // Parent node of newly added item, should be expanded from collapsed state to show selected node: - var treeView = new TreeView(); var parentNode = new TreeNode(); var node = new TreeNode { @@ -1182,8 +1181,6 @@ parentNode.Nodes.Add(node); - treeView.Nodes.Add(parentNode); - gui.Expect(cmp => cmp.Get(node, info, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); @@ -1209,9 +1206,6 @@ Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name, "An item with the same name default name already exists, therefore '(1)' needs to be appended."); - Assert.AreSame(newCalculationContextNode, node.TreeView.SelectedNode, - "The node of the newly added item should be selected."); - mocks.VerifyAll(); }