Index: Core/Common/src/Core.Common.Controls.TreeView/Properties/Resources.Designer.cs =================================================================== diff -u -rfea3ed82dfb6dfcad535eef16efcbaa9c01564ed -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Controls.TreeView/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fea3ed82dfb6dfcad535eef16efcbaa9c01564ed) +++ Core/Common/src/Core.Common.Controls.TreeView/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -82,6 +82,15 @@ } /// + /// Looks up a localized string similar to Weet u zeker dat u de subonderdelen van het geselecteerde element wilt verwijderen?. + /// + internal static string TreeViewControl_Are_you_sure_you_want_to_remove_children_of_the_selected_item { + get { + return ResourceManager.GetString("TreeViewControl_Are_you_sure_you_want_to_remove_children_of_the_selected_item", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Weet u zeker dat u het geselecteerde element wilt verwijderen?. /// internal static string TreeViewControl_Are_you_sure_you_want_to_remove_the_selected_item { Index: Core/Common/src/Core.Common.Controls.TreeView/Properties/Resources.resx =================================================================== diff -u -rf24e27cd856cf597082209f97478815b5e9cebbe -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Controls.TreeView/Properties/Resources.resx (.../Resources.resx) (revision f24e27cd856cf597082209f97478815b5e9cebbe) +++ Core/Common/src/Core.Common.Controls.TreeView/Properties/Resources.resx (.../Resources.resx) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -126,4 +126,7 @@ Het geselecteerde element kan niet worden hernoemd. + + Weet u zeker dat u de subonderdelen van het geselecteerde element wilt verwijderen? + \ No newline at end of file Index: Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs =================================================================== diff -u -re7e22e69b16b23c89c063f18444c82aa818dc176 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision e7e22e69b16b23c89c063f18444c82aa818dc176) +++ Core/Common/src/Core.Common.Controls.TreeView/TreeViewControl.cs (.../TreeViewControl.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -224,6 +224,19 @@ } /// + /// This method returns whether or not the tree node corresponding to the + /// has children which can be removed. + /// + /// The data object to obtain the corresponding tree node for. + /// true if the tree node has a child node which can be removed or false otherwise. + public bool CanRemoveChildNodesOfData(object dataObject) + { + var treeNode = GetNodeByTag(dataObject); + + return treeNode != null && CanRemoveChildNodes(treeNode); + } + + /// /// This method tries to remove the tree node corresponding to the . /// /// The data object to obtain the corresponding tree node for. @@ -238,10 +251,20 @@ if (treeNode != null) { - Remove(treeNode); + TryRemoveNode(treeNode); } } + public void TryRemoveChildNodesOfData(object dataObject) + { + var treeNode = GetNodeByTag(dataObject); + + if (treeNode != null) + { + TryRemoveChildNodes(treeNode); + } + } + /// /// This method returns whether or not the tree node corresponding to the /// can be collapsed/expanded. @@ -340,22 +363,66 @@ return treeNodeInfo.CanRemove != null && treeNodeInfo.CanRemove(treeNode.Tag, parentTag); } - private void Remove(TreeNode treeNode) + private bool CanRemoveChildNodes(TreeNode treeNode) { + var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag); + if (treeNodeInfo.ChildNodeObjects != null) + { + return treeNodeInfo.ChildNodeObjects(treeNode.Tag).Any(childData => CanRemove(GetNodeByTag(childData))); + } + return false; + } + + private void TryRemoveNode(TreeNode treeNode) + { if (!CanRemove(treeNode)) { MessageBox.Show(Resources.TreeViewControl_The_selected_item_cannot_be_removed, BaseResources.Confirm, MessageBoxButtons.OK); return; } - var message = string.Format(Resources.TreeViewControl_Are_you_sure_you_want_to_remove_the_selected_item); + var message = Resources.TreeViewControl_Are_you_sure_you_want_to_remove_the_selected_item; if (MessageBox.Show(message, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } + RemoveNode(treeNode); + } + + private void TryRemoveChildNodes(TreeNode treeNode) + { + var message = Resources.TreeViewControl_Are_you_sure_you_want_to_remove_children_of_the_selected_item; + if (MessageBox.Show(message, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) + { + return; + } + + RemoveChildNodes(treeNode); + } + + private void RemoveChildNodes(TreeNode treeNode) + { var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag); + if (treeNodeInfo.ChildNodeObjects != null) + { + foreach (var childNodeObject in treeNodeInfo.ChildNodeObjects(treeNode.Tag)) + { + var childNode = GetNodeByTag(childNodeObject); + + if (CanRemove(childNode)) + { + RemoveNode(childNode); + } + } + } + } + + private void RemoveNode(TreeNode treeNode) + { + var treeNodeInfo = TryGetTreeNodeInfoForData(treeNode.Tag); + if (treeNodeInfo.OnNodeRemoved != null) { var parentTag = GetParentTag(treeNode); @@ -774,7 +841,7 @@ } case Keys.Delete: // Try to delete the selected tree node { - Remove(selectedNode); + TryRemoveNode(selectedNode); break; } Index: Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs =================================================================== diff -u -rf00ef5699ccc950bf9d347e8e935c77a4f5f5833 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision f00ef5699ccc950bf9d347e8e935c77a4f5f5833) +++ Core/Common/src/Core.Common.Gui/ContextMenu/ContextMenuBuilder.cs (.../ContextMenuBuilder.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -91,6 +91,12 @@ return this; } + public IContextMenuBuilder AddDeleteChildrenItem() + { + AddItem(treeViewItemsFactory.CreateDeleteChildrenItem()); + return this; + } + public IContextMenuBuilder AddExpandAllItem() { AddItem(treeViewItemsFactory.CreateExpandAllItem()); Index: Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs =================================================================== diff -u -r586ee3c66ed8191b42a3626a9a79fc35faffb6d4 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs (.../IContextMenuBuilder.cs) (revision 586ee3c66ed8191b42a3626a9a79fc35faffb6d4) +++ Core/Common/src/Core.Common.Gui/ContextMenu/IContextMenuBuilder.cs (.../IContextMenuBuilder.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -41,6 +41,13 @@ IContextMenuBuilder AddDeleteItem(); /// + /// Adds an item to the , which deletes the children + /// of . + /// + /// The itself. + IContextMenuBuilder AddDeleteChildrenItem(); + + /// /// Adds an item to the , which expands the . /// /// The itself. Index: Core/Common/src/Core.Common.Gui/ContextMenu/TreeViewContextMenuItemFactory.cs =================================================================== diff -u -rd03f2b52982110a0f804adfefe73f86551c59e62 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Gui/ContextMenu/TreeViewContextMenuItemFactory.cs (.../TreeViewContextMenuItemFactory.cs) (revision d03f2b52982110a0f804adfefe73f86551c59e62) +++ Core/Common/src/Core.Common.Gui/ContextMenu/TreeViewContextMenuItemFactory.cs (.../TreeViewContextMenuItemFactory.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -91,6 +91,23 @@ } /// + /// Creates a which is bound to the action of deleting + /// the children of . + /// + /// The created . + public ToolStripItem CreateDeleteChildrenItem() + { + var toolStripMenuItem = new ToolStripMenuItem(Resources.DeleteChildren) + { + ToolTipText = Resources.DeleteChildren_ToolTip, + Image = Resources.DeleteChildrenIcon, + Enabled = treeViewControl.CanRemoveChildNodesOfData(dataObject) + }; + toolStripMenuItem.Click += (s, e) => treeViewControl.TryRemoveChildNodesOfData(dataObject); + return toolStripMenuItem; + } + + /// /// Creates a which is bound to the action of expanding /// the . /// Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -rc625517c051161c0b306e3a554d2227fce06e614 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision c625517c051161c0b306e3a554d2227fce06e614) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -363,6 +363,7 @@ + Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs =================================================================== diff -u -rcf5500705e6163f283ab151a0a489bbfe60d2f7e -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision cf5500705e6163f283ab151a0a489bbfe60d2f7e) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -330,8 +330,36 @@ } /// + /// Looks up a localized string similar to &Onderliggende elementen verwijderen.... + /// + public static string DeleteChildren { + get { + return ResourceManager.GetString("DeleteChildren", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Verwijder alle onderliggende elementen van dit element.. + /// + public static string DeleteChildren_ToolTip { + get { + return ResourceManager.GetString("DeleteChildren_ToolTip", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// + public static System.Drawing.Bitmap DeleteChildrenIcon { + get { + object obj = ResourceManager.GetObject("DeleteChildrenIcon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// public static System.Drawing.Bitmap DeleteIcon { get { object obj = ResourceManager.GetObject("DeleteIcon", resourceCulture); Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx =================================================================== diff -u -rcf5500705e6163f283ab151a0a489bbfe60d2f7e -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision cf5500705e6163f283ab151a0a489bbfe60d2f7e) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -553,4 +553,13 @@ Opslaan als + + ..\resources\broom.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + &Onderliggende elementen verwijderen... + + + Verwijder alle onderliggende elementen van dit element. + \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Resources/broom.png =================================================================== diff -u Binary files differ Index: Core/Common/test/Core.Common.Controls.TreeView.Test/TreeViewControlTest.cs =================================================================== diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/test/Core.Common.Controls.TreeView.Test/TreeViewControlTest.cs (.../TreeViewControlTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a) +++ Core/Common/test/Core.Common.Controls.TreeView.Test/TreeViewControlTest.cs (.../TreeViewControlTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -488,6 +488,247 @@ [Test] [RequiresSTA] + public void TryRemoveChildNodesOfData_CancelClicked_OnNodeRemovedOnChildrenNotCalled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var onNodeRemovedHit = 0; + var treeNodeInfo = new TreeNodeInfo + { + TagType = typeof(object), + ChildNodeObjects = o => new[] + { + string.Empty + } + }; + var childTreeNodeInfo = new TreeNodeInfo + { + TagType = typeof(string), + CanRemove = (o, p) => true, + OnNodeRemoved = (o, p) => onNodeRemovedHit++ + }; + treeViewControl.RegisterTreeNodeInfo(treeNodeInfo); + treeViewControl.RegisterTreeNodeInfo(childTreeNodeInfo); + var dataObject = new object(); + treeViewControl.Data = dataObject; + + try + { + WindowsFormsTestHelper.Show(treeViewControl); + + string messageBoxText = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + + messageBoxText = helper.Text; + + helper.ClickCancel(); + }; + + // Call + treeViewControl.TryRemoveChildNodesOfData(dataObject); + + // Assert + Assert.AreEqual(0, onNodeRemovedHit); + + Assert.AreEqual("Weet u zeker dat u de subonderdelen van het geselecteerde element wilt verwijderen?", messageBoxText); + } + finally + { + WindowsFormsTestHelper.CloseAll(); + } + } + } + + [Test] + [RequiresSTA] + public void TryRemoveChildNodesOfData_OkClicked_OnNodeRemovedAndDataDeletedOnChildrenCalled() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var onNodeRemovedHit = 0; + var onDataDeletedHit = 0; + + var treeNodeInfo = new TreeNodeInfo + { + TagType = typeof(object), + ChildNodeObjects = o => new[] + { + string.Empty + } + }; + var childTreeNodeInfo = new TreeNodeInfo + { + TagType = typeof(string), + CanRemove = (o, p) => true, + OnNodeRemoved = (o, p) => onNodeRemovedHit++ + }; + treeViewControl.DataDeleted += (sender, args) => onDataDeletedHit++; + treeViewControl.RegisterTreeNodeInfo(treeNodeInfo); + treeViewControl.RegisterTreeNodeInfo(childTreeNodeInfo); + var dataObject = new object(); + treeViewControl.Data = dataObject; + + try + { + WindowsFormsTestHelper.Show(treeViewControl); + + string messageBoxText = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + + messageBoxText = helper.Text; + + helper.ClickOk(); + }; + + // Call + treeViewControl.TryRemoveChildNodesOfData(dataObject); + + // Assert + Assert.AreEqual(1, onNodeRemovedHit); + Assert.AreEqual(1, onDataDeletedHit); + + Assert.AreEqual("Weet u zeker dat u de subonderdelen van het geselecteerde element wilt verwijderen?", messageBoxText); + } + finally + { + WindowsFormsTestHelper.CloseAll(); + } + } + } + + [Test] + [RequiresSTA] + public void CanRemoveChildNodesOfData_NoChildren_ReturnsFalse() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var treeNodeInfo = new TreeNodeInfo + { + TagType = typeof(object) + }; + treeViewControl.RegisterTreeNodeInfo(treeNodeInfo); + var dataObject = new object(); + treeViewControl.Data = dataObject; + + try + { + WindowsFormsTestHelper.Show(treeViewControl); + + // Call + var result = treeViewControl.CanRemoveChildNodesOfData(dataObject); + + // Assert + Assert.IsFalse(result); + + } + finally + { + WindowsFormsTestHelper.CloseAll(); + } + } + } + + [Test] + [RequiresSTA] + public void CanRemoveChildNodesOfData_NoRemovableChildren_ReturnsFalse() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var treeNodeInfo = new TreeNodeInfo + { + TagType = typeof(object), + ChildNodeObjects = o => new[] + { + string.Empty + } + }; + var childTreeNodeInfo = new TreeNodeInfo + { + TagType = typeof(string), + CanRemove = (o, p) => false, + }; + treeViewControl.RegisterTreeNodeInfo(treeNodeInfo); + treeViewControl.RegisterTreeNodeInfo(childTreeNodeInfo); + var dataObject = new object(); + treeViewControl.Data = dataObject; + + try + { + WindowsFormsTestHelper.Show(treeViewControl); + + // Call + var result = treeViewControl.CanRemoveChildNodesOfData(dataObject); + + // Assert + Assert.IsFalse(result); + } + finally + { + WindowsFormsTestHelper.CloseAll(); + } + } + } + + [Test] + [RequiresSTA] + public void CanRemoveChildNodesOfData_OneRemovableChild_ReturnsTrue() + { + // Setup + using (var treeViewControl = new TreeViewControl()) + { + var treeNodeInfo = new TreeNodeInfo + { + TagType = typeof(object), + ChildNodeObjects = o => new object[] + { + 0, + string.Empty, + 1 + } + }; + var childStringTreeNodeInfo = new TreeNodeInfo + { + TagType = typeof(string), + CanRemove = (o, p) => true, + }; + var childIntTreeNodeInfo = new TreeNodeInfo + { + TagType = typeof(int), + CanRemove = (o, p) => false, + }; + treeViewControl.RegisterTreeNodeInfo(treeNodeInfo); + treeViewControl.RegisterTreeNodeInfo(childStringTreeNodeInfo); + treeViewControl.RegisterTreeNodeInfo(childIntTreeNodeInfo); + var dataObject = new object(); + treeViewControl.Data = dataObject; + + try + { + WindowsFormsTestHelper.Show(treeViewControl); + + // Call + var result = treeViewControl.CanRemoveChildNodesOfData(dataObject); + + // Assert + Assert.IsTrue(result); + } + finally + { + WindowsFormsTestHelper.CloseAll(); + } + } + } + + [Test] + [RequiresSTA] public void TryRemoveNodeForData_RemoveableCancelClicked_OnNodeRemovedNotCalled() { // Setup Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs =================================================================== diff -u -r2e73db6bbdd25adf8d0e26a2db9f862e2ed3c191 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision 2e73db6bbdd25adf8d0e26a2db9f862e2ed3c191) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/ContextMenuBuilderTest.cs (.../ContextMenuBuilderTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -341,6 +341,43 @@ [Test] [TestCase(true)] [TestCase(false)] + public void AddRemoveAllChildrenItem_WhenBuild_ItemAddedToContextMenu(bool hasChildren) + { + // Setup + var dataObject = new object(); + var applicationFeatureCommandsMock = mocks.StrictMock(); + var importCommandHandlerMock = mocks.StrictMock(); + var exportCommandHandlerMock = mocks.StrictMock(); + var viewCommandsMock = mocks.StrictMock(); + var treeViewControlMock = mocks.StrictMock(); + + treeViewControlMock.Expect(tvc => tvc.CanRemoveChildNodesOfData(dataObject)).Return(hasChildren); + + mocks.ReplayAll(); + + var builder = new ContextMenuBuilder(applicationFeatureCommandsMock, + importCommandHandlerMock, + exportCommandHandlerMock, + viewCommandsMock, + dataObject, + treeViewControlMock); + + // Call + ContextMenuStrip result = builder.AddDeleteChildrenItem().Build(); + + // Assert + Assert.IsInstanceOf(result); + Assert.AreEqual(1, result.Items.Count); + TestHelper.AssertContextMenuStripContainsItem(result, 0, + Resources.DeleteChildren, + Resources.DeleteChildren_ToolTip, + Resources.DeleteChildrenIcon, + hasChildren); + } + + [Test] + [TestCase(true)] + [TestCase(false)] public void AddExpandAllItem_WhenBuild_ItemAddedToContextMenu(bool hasChildren) { // Setup Index: Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs =================================================================== diff -u -r24da3aa72ccc0776599628c9f971081694048d9a -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs (.../TreeViewContextMenuItemFactoryTest.cs) (revision 24da3aa72ccc0776599628c9f971081694048d9a) +++ Core/Common/test/Core.Common.Gui.Test/ContextMenu/TreeViewContextMenuItemFactoryTest.cs (.../TreeViewContextMenuItemFactoryTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -92,19 +92,8 @@ var treeNodeInfoMock = mocks.StrictMock(); var treeViewControlMock = mocks.StrictMock(); - var parentNodeData = new object(); var nodeData = new object(); - treeNodeInfoMock.CanRemove = (nd, pnd) => - { - if (nd == nodeData && pnd == parentNodeData) - { - return canDelete; - } - - return !canDelete; - }; - treeViewControlMock.Expect(tvc => tvc.CanRemoveNodeForData(nodeData)).Return(canDelete); if (canDelete) @@ -132,23 +121,47 @@ [Test] [TestCase(true)] [TestCase(false)] - public void CreateRenameItem_DependingOnCanRenameNodeForData_ItemWithDeleteFunctionWillBeEnabled(bool canRename) + public void CreateDeleteChildrenItem_DependingOnCanRemoveChildNodesOfData_ItemWithDeleteChildrenFunctionWillBeEnabled(bool canDelete) { // Setup - var dataObject = new object(); var treeNodeInfoMock = mocks.StrictMock(); var treeViewControlMock = mocks.StrictMock(); - treeNodeInfoMock.CanRename = (data, parentData) => + var nodeData = new object(); + + treeViewControlMock.Expect(tvc => tvc.CanRemoveChildNodesOfData(nodeData)).Return(canDelete); + + if (canDelete) { - if (data == dataObject) - { - return canRename; - } + treeViewControlMock.Expect(tvc => tvc.TryRemoveChildNodesOfData(nodeData)); + } - return !canRename; - }; + mocks.ReplayAll(); + var factory = new TreeViewContextMenuItemFactory(nodeData, treeViewControlMock); + + // Call + var item = factory.CreateDeleteChildrenItem(); + item.PerformClick(); + + // Assert + Assert.AreEqual(Resources.DeleteChildren, item.Text); + Assert.AreEqual(Resources.DeleteChildren_ToolTip, item.ToolTipText); + TestHelper.AssertImagesAreEqual(Resources.DeleteChildrenIcon, item.Image); + Assert.AreEqual(canDelete, item.Enabled); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void CreateRenameItem_DependingOnCanRenameNodeForData_ItemWithDeleteFunctionWillBeEnabled(bool canRename) + { + // Setup + var dataObject = new object(); + var treeViewControlMock = mocks.StrictMock(); + treeViewControlMock.Expect(tvc => tvc.CanRenameNodeForData(dataObject)).Return(canRename); if (canRename) Index: Core/Common/test/Core.Common.Gui.TestUtil/ContextMenu/CustomItemsOnlyContextMenuBuilder.cs =================================================================== diff -u -r586ee3c66ed8191b42a3626a9a79fc35faffb6d4 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Core/Common/test/Core.Common.Gui.TestUtil/ContextMenu/CustomItemsOnlyContextMenuBuilder.cs (.../CustomItemsOnlyContextMenuBuilder.cs) (revision 586ee3c66ed8191b42a3626a9a79fc35faffb6d4) +++ Core/Common/test/Core.Common.Gui.TestUtil/ContextMenu/CustomItemsOnlyContextMenuBuilder.cs (.../CustomItemsOnlyContextMenuBuilder.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -40,6 +40,7 @@ /// The . public IContextMenuBuilder AddRenameItem() { + contextMenu.Items.Add(StubItem()); return this; } @@ -49,13 +50,24 @@ /// The . public IContextMenuBuilder AddDeleteItem() { + contextMenu.Items.Add(StubItem()); return this; } /// /// Does nothing. /// /// The . + public IContextMenuBuilder AddDeleteChildrenItem() + { + contextMenu.Items.Add(StubItem()); + return this; + } + + /// + /// Does nothing. + /// + /// The . public IContextMenuBuilder AddExpandAllItem() { return this; @@ -67,6 +79,7 @@ /// The . public IContextMenuBuilder AddCollapseAllItem() { + contextMenu.Items.Add(StubItem()); return this; } @@ -85,6 +98,7 @@ /// The . public IContextMenuBuilder AddExportItem() { + contextMenu.Items.Add(StubItem()); return this; } @@ -94,6 +108,7 @@ /// The . public IContextMenuBuilder AddImportItem() { + contextMenu.Items.Add(StubItem()); return this; } @@ -103,6 +118,7 @@ /// The . public IContextMenuBuilder AddPropertiesItem() { + contextMenu.Items.Add(StubItem()); return this; } @@ -135,5 +151,10 @@ { return contextMenu; } + + private static StrictContextMenuItem StubItem() + { + return new StrictContextMenuItem(string.Empty, string.Empty, null, (sender, args) => { }); + } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rc909835782c9416cd44e2c7e43ff28a678928b1c -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -324,7 +324,7 @@ { builder .AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rc909835782c9416cd44e2c7e43ff28a678928b1c -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision c909835782c9416cd44e2c7e43ff28a678928b1c) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs (.../ClosingStructureFailureMechanismContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -270,7 +270,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(7, menu.Items.Count); + Assert.AreEqual(9, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenRelevant, "I&s relevant", @@ -323,7 +323,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(2, menu.Items.Count); + Assert.AreEqual(3, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenNotRelevant, "I&s relevant", Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision 6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -237,7 +237,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSectionMock, treeViewControl)) { // Assert - Assert.AreEqual(6, menu.Items.Count); + Assert.AreEqual(10, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateIndex, "&Valideren", Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 6b6f344a9cf3e6c44b63320dfa3f5c828c4221d8) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/TreeNodeInfos/ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../ClosingStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -28,6 +28,7 @@ using Core.Common.Gui; using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; +using Core.Common.Gui.Properties; using Core.Common.Gui.TestUtil.ContextMenu; using Core.Common.TestUtil; using NUnit.Extensions.Forms; @@ -50,7 +51,6 @@ { private const int contextMenuAddCalculationGroupIndexRootGroup = 0; private const int contextMenuAddCalculationIndexRootGroup = 1; - private const int contextMenuRemoveAllChildrenRootGroupIndex = 3; private const int contextMenuValidateAllIndexRootGroup = 5; private const int contextMenuCalculateAllIndexRootGroup = 6; private const int contextMenuClearAllIndexRootGroup = 7; @@ -186,7 +186,7 @@ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -236,7 +236,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) { // Assert - Assert.AreEqual(10, menu.Items.Count); + Assert.AreEqual(12, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, "&Map toevoegen", @@ -245,12 +245,7 @@ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationIndexRootGroup, "Berekening &toevoegen", "Voeg een nieuwe berekening toe aan deze berekeningsmap.", - RingtoetsCommonFormsResources.FailureMechanismIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenRootGroupIndex, - "Map &leegmaken...", - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, - false); + RingtoetsCommonFormsResources.FailureMechanismIcon);; TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, "Alles &valideren", @@ -341,7 +336,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl)) { // Assert - Assert.AreEqual(9, menu.Items.Count); + Assert.AreEqual(13, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, "&Map toevoegen", @@ -682,56 +677,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroup_RemovesAllChildren() - { - // Setup - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var group = new CalculationGroup(); - var failureMechanism = new ClosingStructuresFailureMechanism(); - var assessmentSectionMock = mocks.Stub(); - var nodeData = new ClosingStructuresCalculationGroupContext(group, - failureMechanism, - assessmentSectionMock); - var calculation = new ClosingStructuresCalculation - { - Name = "Nieuwe berekening" - }; - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - var observerMock = mocks.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); - - using (var treeViewControl = new TreeViewControl()) - { - guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - guiMock.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - group.Children.Add(calculation); - nodeData.Attach(observerMock); - - plugin.Gui = guiMock; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllChildrenRootGroupIndex].PerformClick(); - - // Assert - Assert.IsEmpty(group.Children); - } - } - } - - [Test] public void OnNodeRemoved_NestedCalculationGroup_RemoveGroupAndNotifyObservers() { // Setup Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rf8f4d73db42727f98beb697e6f7613145d66c628 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f8f4d73db42727f98beb697e6f7613145d66c628) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -1538,16 +1538,6 @@ } /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - public static System.Drawing.Bitmap RemoveAllIcon { - get { - object obj = ResourceManager.GetObject("RemoveAllIcon", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// /// Looks up a localized string similar to Algemeen. /// public static string Ringtoets_Category { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -rf8f4d73db42727f98beb697e6f7613145d66c628 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision f8f4d73db42727f98beb697e6f7613145d66c628) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -421,9 +421,6 @@ Voeg een nieuw traject toe aan het project. - - ..\resources\broom.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Map &leegmaken... Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Resources/broom.png =================================================================== diff -u -r95aa0bc669d63fa2aed395e44b5f0ecde84e9828 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 Binary files differ Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -rd39f2e1a0a36628bbd7751d426425d8f99b2b5af -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision d39f2e1a0a36628bbd7751d426425d8f99b2b5af) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -233,11 +233,9 @@ - - Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs =================================================================== diff -u -r776558d53b8a73cf16bdd5b50ff4d1eeff933b2f -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision 776558d53b8a73cf16bdd5b50ff4d1eeff933b2f) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -21,7 +21,6 @@ using System; using System.Windows.Forms; -using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; @@ -248,19 +247,6 @@ return this; } - /// - /// Adds an item to the , which removes all children of the given - /// . - /// - /// The calculation group from which all the children will be removed. - /// The object implementing a method for closing views for the removed children. - /// The itself. - public RingtoetsContextMenuBuilder AddRemoveAllChildrenItem(CalculationGroup calculationGroup, IViewCommands viewCommands) - { - contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommands)); - return this; - } - # region Decorated members /// @@ -284,6 +270,17 @@ } /// + /// Adds an item to the , which removes all children of the given + /// . + /// + /// The itself. + public RingtoetsContextMenuBuilder AddRemoveAllChildrenItem() + { + contextMenuBuilder.AddDeleteChildrenItem(); + return this; + } + + /// /// Adds an item to the , which expands the . /// /// The itself. Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs =================================================================== diff -u -r776558d53b8a73cf16bdd5b50ff4d1eeff933b2f -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision 776558d53b8a73cf16bdd5b50ff4d1eeff933b2f) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuItemFactory.cs (.../RingtoetsContextMenuItemFactory.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -368,35 +368,6 @@ }); } - /// - /// Creates a which is bound to the action of removing all children - /// in the . - /// - /// The calculation from which to remove all children. - /// The object implementing a method for closing views for the removed children. - /// The created . - public static StrictContextMenuItem CreateRemoveAllChildrenFromGroupItem(CalculationGroup calculationGroup, IViewCommands viewCommands) - { - if (viewCommands == null) - { - throw new ArgumentNullException("viewCommands"); - } - var menuItem = new StrictContextMenuItem( - Resources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - Resources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, - Resources.RemoveAllIcon, - (sender, args) => RemoveAllChildrenFromGroup(calculationGroup, viewCommands)); - - var errorMessage = calculationGroup.Children.Any() ? null : Resources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove; - - if (errorMessage != null) - { - menuItem.Enabled = false; - menuItem.ToolTipText = errorMessage; - } - return menuItem; - } - private static void RemoveAllChildrenFromGroup(CalculationGroup calculationGroup, IViewCommands viewCommands) { if (MessageBox.Show(Resources.CalculationGroup_RemoveAllChildrenFromGroup_Are_you_sure_you_want_to_remove_everything_from_this_group, BaseResources.Confirm, MessageBoxButtons.OKCancel) != DialogResult.OK) Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs =================================================================== diff -u -r776558d53b8a73cf16bdd5b50ff4d1eeff933b2f -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision 776558d53b8a73cf16bdd5b50ff4d1eeff933b2f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -1565,89 +1565,6 @@ #endregion - #region AddRemoveAllChildrenItem - - [Test] - public void AddRemoveAllChildrenItem_CalculationGroupWithChildren_ItemAddedToContextMenuEnabled() - { - // Setup - var mocks = new MockRepository(); - var applicationFeatureCommandsMock = mocks.StrictMock(); - var importHandlerMock = mocks.StrictMock(); - var exportHandlerMock = mocks.StrictMock(); - var viewCommandsMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); - - var failureMechanism = new TestFailureMechanism(Enumerable.Empty()); - var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock); - - var calculationGroup = new CalculationGroup - { - Children = - { - new TestCalculation() - } - }; - - mocks.ReplayAll(); - - using (var treeViewControl = new TreeViewControl()) - { - var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); - var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); - - // Call - ContextMenuStrip result = ringtoetsContextMenuBuilder.AddRemoveAllChildrenItem(calculationGroup, viewCommandsMock).Build(); - - // Assert - Assert.IsInstanceOf(result); - Assert.AreEqual(1, result.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(result, 0, - RingtoetsFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - RingtoetsFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, - RingtoetsFormsResources.RemoveAllIcon); - } - mocks.VerifyAll(); - } - - [Test] - public void AddRemoveAllChildrenItem_CalculationGroupWithNoChildren_ItemAddedToContextMenuDisabledTootipSet() - { - // Setup - var mocks = new MockRepository(); - var applicationFeatureCommandsMock = mocks.StrictMock(); - var importHandlerMock = mocks.StrictMock(); - var exportHandlerMock = mocks.StrictMock(); - var viewCommandsMock = mocks.StrictMock(); - var assessmentSectionMock = mocks.StrictMock(); - - var failureMechanism = new TestFailureMechanism(Enumerable.Empty()); - var failureMechanismContext = new TestFailureMechanismContext(failureMechanism, assessmentSectionMock); - - mocks.ReplayAll(); - - using (var treeViewControl = new TreeViewControl()) - { - var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock, importHandlerMock, exportHandlerMock, viewCommandsMock, failureMechanismContext, treeViewControl); - var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder); - - // Call - ContextMenuStrip result = ringtoetsContextMenuBuilder.AddValidateAllCalculationsInFailureMechanismItem(failureMechanismContext, null, fm => null).Build(); - - // Assert - Assert.IsInstanceOf(result); - Assert.AreEqual(1, result.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(result, 0, - RingtoetsFormsResources.Validate_all, - RingtoetsFormsResources.ValidateAll_No_calculations_to_validate, - RingtoetsFormsResources.ValidateAllIcon, - false); - } - mocks.VerifyAll(); - } - - #endregion - # region Nested types private class TestFailureMechanismContext : FailureMechanismContext Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs =================================================================== diff -u -rdc6599a4fa76a2acac2d0214ec0d736ca167bf9b -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision dc6599a4fa76a2acac2d0214ec0d736ca167bf9b) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -1309,143 +1309,7 @@ } #endregion - - #region CreateRemoveAllChildrenFromGroupItem - - [Test] - public void CreateRemoveAllChildrenFromGroupItem_NoChildren_CreatesDisabledItemWithTooltipSet() - { - // Setup - var mocks = new MockRepository(); - var viewCommandsMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var calculationGroup = new CalculationGroup(); - - // Call - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); - - // Assert - Assert.AreEqual("Map &leegmaken...", toolStripItem.Text); - Assert.AreEqual("Er zijn geen berekeningen of mappen om te verwijderen.", toolStripItem.ToolTipText); - TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.RemoveAllIcon, toolStripItem.Image); - Assert.IsFalse(toolStripItem.Enabled); - - mocks.VerifyAll(); - } - - [Test] - public void CreateRemoveAllChildrenFromGroupItem_WithChildren_CreatesEnabledItem() - { - // Setup - var mocks = new MockRepository(); - var viewCommandsMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var calculation = new TestCalculation(); - var calculationGroup = new CalculationGroup - { - Children = - { - calculation - } - }; - - // Call - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); - - // Assert - Assert.AreEqual("Map &leegmaken...", toolStripItem.Text); - Assert.AreEqual("Verwijder alle berekeningen en mappen binnen deze map.", toolStripItem.ToolTipText); - TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.RemoveAllIcon, toolStripItem.Image); - Assert.IsTrue(toolStripItem.Enabled); - - mocks.VerifyAll(); - } - - [Test] - public void CreateRemoveAllChildrenFromGroupItem_WithChildrenPerformClickOnCreatedItemAndCancelChange_GroupUnchanged() - { - // Setup - var mocks = new MockRepository(); - var viewCommandsMock = mocks.StrictMock(); - mocks.ReplayAll(); - - var calculation = new TestCalculation(); - var calculationGroup = new CalculationGroup - { - Children = - { - calculation - } - }; - - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - Assert.AreEqual("Weet u zeker dat u alles binnen deze Berekeningen map wilt verwijderen?", dialog.Text); - dialog.ClickCancel(); - }; - - // Call - toolStripItem.PerformClick(); - - // Assert - CollectionAssert.AreEqual(new[] - { - calculation - }, calculationGroup.Children); - - mocks.VerifyAll(); - } - - [Test] - public void CreateRemoveAllChildrenFromGroupItem_WithNestedChildrenPerformClickOnCreatedItemAndConfirmChange_ClearsGroup() - { - // Setup - var calculation = new TestCalculation(); - - var mocks = new MockRepository(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - mocks.ReplayAll(); - - var calculationGroup = new CalculationGroup - { - Children = - { - new CalculationGroup - { - Children = - { - calculation - } - } - } - }; - - StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateRemoveAllChildrenFromGroupItem(calculationGroup, viewCommandsMock); - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - Assert.AreEqual("Weet u zeker dat u alles binnen deze Berekeningen map wilt verwijderen?", dialog.Text); - dialog.ClickOk(); - }; - - // Call - toolStripItem.PerformClick(); - - // Assert - CollectionAssert.IsEmpty(calculationGroup.Children); - - mocks.VerifyAll(); - } - - #endregion - + # region Nested types private class TestFailureMechanismContext : FailureMechanismContext Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r38600213ce6ca43c1819c81dd95c8ce786650ac3 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 38600213ce6ca43c1819c81dd95c8ce786650ac3) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -450,7 +450,7 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() @@ -526,6 +526,12 @@ var parentGroupContext = (GrassCoverErosionInwardsCalculationGroupContext) parentNodeData; parentGroupContext.WrappedData.Children.Remove(context.WrappedData); + foreach (var calculation in context.WrappedData.GetCalculations().Cast()) + { + GrassCoverErosionInwardsHelper.Delete(context.FailureMechanism.SectionResults, + calculation, + context.FailureMechanism.Calculations.Cast()); + } parentGroupContext.NotifyObservers(); } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rd3ee3323c871a2796496b0f2ab1fe65ead8ad81d -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision d3ee3323c871a2796496b0f2ab1fe65ead8ad81d) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -243,7 +243,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSectionMock, treeViewControl)) { // Assert - Assert.AreEqual(6, menu.Items.Count); + Assert.AreEqual(10, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateIndex, RingtoetsCommonFormsResources.Validate, Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -59,7 +59,6 @@ private const int contextMenuGenerateCalculationsIndexRootGroup = 0; private const int contextMenuAddCalculationGroupIndexRootGroup = 2; private const int contextMenuAddCalculationIndexRootGroup = 3; - private const int contextMenuRemoveAllChildrenRootGroupIndex = 5; private const int contextMenuValidateAllIndexRootGroup = 7; private const int contextMenuCalculateAllIndexRootGroup = 8; private const int contextMenuClearAllIndexRootGroup = 9; @@ -190,7 +189,7 @@ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -239,7 +238,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) { // Assert - Assert.AreEqual(12, menu.Items.Count); + Assert.AreEqual(14, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup_Tooltip, @@ -248,11 +247,7 @@ RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation_Tooltip, RingtoetsCommonFormsResources.FailureMechanismIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenRootGroupIndex, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove, - RingtoetsCommonFormsResources.RemoveAllIcon, - false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, RingtoetsCommonFormsResources.Validate_all, RingtoetsCommonFormsResources.ValidateAll_No_calculations_to_validate, @@ -341,7 +336,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl)) { // Assert - Assert.AreEqual(9, menu.Items.Count); + Assert.AreEqual(13, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, @@ -913,55 +908,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroup_RemovesAllChildren() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var calculation = mocks.Stub(); - var group = new CalculationGroup - { - Children = - { - calculation - } - }; - - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - guiMock.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = guiMock; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllChildrenRootGroupIndex].PerformClick(); - - // Assert - Assert.IsEmpty(group.Children); - } - } - } - - [Test] public void GivenCalculationsViewGenerateScenariosButtonClicked_WhenDikeProfileSelectedAndDialogClosed_ThenCalculationsAddedWithProfileAssigned() { // Given Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -265,7 +265,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(7, menu.Items.Count); + Assert.AreEqual(9, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenRelevant, RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant, @@ -320,7 +320,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(2, menu.Items.Count); + Assert.AreEqual(3, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenNotRelevant, RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant, Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r98929f84fbf311bd19d8e61cc8499cdb40b22ea0 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 98929f84fbf311bd19d8e61cc8499cdb40b22ea0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -619,7 +619,7 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -32,7 +32,6 @@ using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.MainWindow; -using Core.Common.Gui.Properties; using Core.Common.Gui.TestUtil.ContextMenu; using Core.Common.TestUtil; using NUnit.Extensions.Forms; @@ -50,6 +49,7 @@ using Ringtoets.HydraRing.Data; using Ringtoets.Revetment.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.TreeNodeInfos { @@ -66,20 +66,13 @@ private const int contextMenuCollapseAllIndexRootGroup = 13; private const int contextMenuPropertiesIndexRootGroup = 15; + private const int contextMenuAddGenerateCalculationsIndex = 0; private const int contextMenuAddCalculationGroupIndexNestedGroup = 2; private const int contextMenuAddCalculationIndexNestedGroup = 3; private const int contextMenuValidateAllIndexNestedGroup = 5; private const int contextMenuCalculateAllIndexNestedGroup = 6; private const int contextMenuClearOutputNestedGroupIndex = 7; - private const int customOnlyContextMenuAddGenerateCalculationsIndex = 0; - private const int contextMenuValidateAllIndexNestedGroupNoCalculations = 4; - private const int contextMenuCalculateAllIndexNestedGroupNoCalculations = 5; - - private const int contextMenuRemoveAllInGroup = 5; - - private const int customOnlyContextMenuRemoveAllChildrenIndex = 5; - private MockRepository mocks; private GrassCoverErosionOutwardsPlugin plugin; private TreeNodeInfo info; @@ -251,9 +244,9 @@ Assert.AreEqual(16, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, 0, - Resources.Export, - Resources.Export_ToolTip, - Resources.ExportIcon); + CoreCommonGuiResources.Export, + CoreCommonGuiResources.Export_ToolTip, + CoreCommonGuiResources.ExportIcon); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, @@ -280,29 +273,29 @@ false); TestHelper.AssertContextMenuStripContainsItem(menu, 9, - Resources.Rename, - Resources.Rename_ToolTip, - Resources.RenameIcon); + CoreCommonGuiResources.Rename, + CoreCommonGuiResources.Rename_ToolTip, + CoreCommonGuiResources.RenameIcon); TestHelper.AssertContextMenuStripContainsItem(menu, 10, - Resources.Delete, - Resources.Delete_ToolTip, - Resources.DeleteIcon); + CoreCommonGuiResources.Delete, + CoreCommonGuiResources.Delete_ToolTip, + CoreCommonGuiResources.DeleteIcon); TestHelper.AssertContextMenuStripContainsItem(menu, 12, - Resources.Expand_all, - Resources.Expand_all_ToolTip, - Resources.ExpandAllIcon, + CoreCommonGuiResources.Expand_all, + CoreCommonGuiResources.Expand_all_ToolTip, + CoreCommonGuiResources.ExpandAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, 13, - Resources.Collapse_all, - Resources.Collapse_all_ToolTip, - Resources.CollapseAllIcon, + CoreCommonGuiResources.Collapse_all, + CoreCommonGuiResources.Collapse_all_ToolTip, + CoreCommonGuiResources.CollapseAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, 15, - Resources.Properties, - Resources.Properties_ToolTip, - Resources.PropertiesHS, + CoreCommonGuiResources.Properties, + CoreCommonGuiResources.Properties_ToolTip, + CoreCommonGuiResources.PropertiesHS, false); CollectionAssert.AllItemsAreInstancesOfType(new[] @@ -354,7 +347,7 @@ { // Assert Assert.AreEqual(16, menu.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, "Genereer &berekeningen...", "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de randvoorwaardenberekeningen te genereren.", RingtoetsCommonFormsResources.GenerateScenariosIcon, false); @@ -366,11 +359,13 @@ RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, "Voeg een nieuwe berekening toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.FailureMechanismIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, + CoreCommonGuiResources.DeleteChildren, + CoreCommonGuiResources.DeleteChildren_ToolTip, + CoreCommonGuiResources.DeleteChildrenIcon, false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, RingtoetsCommonFormsResources.Validate_all, "Er zijn geen berekeningen om te valideren.", @@ -388,20 +383,20 @@ false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, - Resources.Expand_all, - Resources.Expand_all_ToolTip, - Resources.ExpandAllIcon, + CoreCommonGuiResources.Expand_all, + CoreCommonGuiResources.Expand_all_ToolTip, + CoreCommonGuiResources.ExpandAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, - Resources.Collapse_all, - Resources.Collapse_all_ToolTip, - Resources.CollapseAllIcon, + CoreCommonGuiResources.Collapse_all, + CoreCommonGuiResources.Collapse_all_ToolTip, + CoreCommonGuiResources.CollapseAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, - Resources.Properties, - Resources.Properties_ToolTip, - Resources.PropertiesHS, + CoreCommonGuiResources.Properties, + CoreCommonGuiResources.Properties_ToolTip, + CoreCommonGuiResources.PropertiesHS, false); CollectionAssert.AllItemsAreInstancesOfType(new[] { @@ -459,7 +454,7 @@ { // Assert Assert.AreEqual(16, menu.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, "Genereer &berekeningen...", "Genereer randvoorwaardenberekeningen.", RingtoetsCommonFormsResources.GenerateScenariosIcon); @@ -473,9 +468,9 @@ RingtoetsCommonFormsResources.FailureMechanismIcon); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, + CoreCommonGuiResources.DeleteChildren, + CoreCommonGuiResources.DeleteChildren_ToolTip, + CoreCommonGuiResources.DeleteChildrenIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, @@ -495,20 +490,20 @@ false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuExpandAllIndexRootGroup, - Resources.Expand_all, - Resources.Expand_all_ToolTip, - Resources.ExpandAllIcon, + CoreCommonGuiResources.Expand_all, + CoreCommonGuiResources.Expand_all_ToolTip, + CoreCommonGuiResources.ExpandAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCollapseAllIndexRootGroup, - Resources.Collapse_all, - Resources.Collapse_all_ToolTip, - Resources.CollapseAllIcon, + CoreCommonGuiResources.Collapse_all, + CoreCommonGuiResources.Collapse_all_ToolTip, + CoreCommonGuiResources.CollapseAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuPropertiesIndexRootGroup, - Resources.Properties, - Resources.Properties_ToolTip, - Resources.PropertiesHS, + CoreCommonGuiResources.Properties, + CoreCommonGuiResources.Properties_ToolTip, + CoreCommonGuiResources.PropertiesHS, false); CollectionAssert.AllItemsAreInstancesOfType(new[] { @@ -552,8 +547,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run, calculateItem.ToolTipText); @@ -593,8 +588,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported, calculateItem.ToolTipText); @@ -638,8 +633,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); var message = "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': Bestandspad mag niet leeg of ongedefinieerd zijn."; @@ -723,7 +718,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - Action test = () => contextMenu.Items[4].PerformClick(); + Action test = () => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); // Assert TestHelper.AssertLogMessages(test, m => @@ -802,7 +797,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - Action test = () => contextMenu.Items[5].PerformClick(); + Action test = () => contextMenu.Items[contextMenuCalculateAllIndexNestedGroup].PerformClick(); // Assert TestHelper.AssertLogMessages(test, m => @@ -922,7 +917,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[6]; + var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputNestedGroupIndex]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -1005,7 +1000,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - contextMenu.Items[6].PerformClick(); + contextMenu.Items[contextMenuClearOutputNestedGroupIndex].PerformClick(); // Assert if (confirm) @@ -1018,74 +1013,6 @@ } [Test] - public void ContextMenuStrip_WithoutParentNodeWithNoChildren_RemoveAllChildrenDisabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemDisabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsFalse(removeAllItemDisabled.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove, removeAllItemDisabled.ToolTipText); - } - } - } - - [Test] - public void ContextMenuStrip_WithoutParentNodeWithChildren_RemoveAllChildrenEnabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(mocks.Stub()); - var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemEnabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsTrue(removeAllItemEnabled.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, removeAllItemEnabled.ToolTipText); - } - } - } - - [Test] public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup @@ -1129,7 +1056,7 @@ Assert.AreEqual(1, group.Children.Count); // Call - contextMenu.Items[1].PerformClick(); + contextMenu.Items[contextMenuAddCalculationGroupIndexNestedGroup].PerformClick(); // Assert Assert.AreEqual(2, group.Children.Count); @@ -1142,98 +1069,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroupAndConfirm_RemovesAllChildren() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var calculation = mocks.Stub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - failureMechanism.WaveConditionsCalculationGroup.Attach(observer); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - - // Assert - Assert.IsEmpty(failureMechanism.WaveConditionsCalculationGroup.Children); - } - } - } - - [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroupAndCancel_ChildrenNotRemoved() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var calculation = mocks.Stub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickCancel(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - - // Assert - Assert.AreEqual(new[] - { - calculation - }, failureMechanism.WaveConditionsCalculationGroup.Children); - } - } - } - - [Test] public void GivenCalculationWithoutOutput_ThenClearOutputItemDisabled() { // Given Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r3e79015849651b140c9b496e8f0f57fcdcac0d92 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 3e79015849651b140c9b496e8f0f57fcdcac0d92) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections; using System.Collections.Generic; using System.Drawing; @@ -27,6 +28,7 @@ using System.Windows.Forms; using Core.Common.Base; using Core.Common.Controls.TreeView; +using Core.Common.Gui.Commands; using Core.Common.Gui.ContextMenu; using Core.Common.Gui.Forms.ProgressDialog; using Core.Common.Gui.Plugin; @@ -52,6 +54,7 @@ using HeightStructuresFormsResources = Ringtoets.HeightStructures.Forms.Properties.Resources; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources; +using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; namespace Ringtoets.HeightStructures.Plugin { @@ -414,7 +417,8 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); +// .AddRemoveAllChildrenItem(group, Gui.ViewCommands); } builder.AddSeparator() @@ -494,6 +498,12 @@ var parentGroupContext = (HeightStructuresCalculationGroupContext) parentNodeData; parentGroupContext.WrappedData.Children.Remove(context.WrappedData); + foreach (var calculation in context.WrappedData.GetCalculations().Cast()) + { + HeightStructuresHelper.Delete(context.FailureMechanism.SectionResults, + calculation, + context.FailureMechanism.Calculations.Cast()); + } parentGroupContext.NotifyObservers(); } @@ -585,7 +595,7 @@ if (calculationGroupContext != null) { calculationGroupContext.WrappedData.Children.Remove(context.WrappedData); - HeightStructuresHelper.Delete(context.FailureMechanism.SectionResults, context.WrappedData, context.FailureMechanism.Calculations.OfType()); + HeightStructuresHelper.Delete(context.FailureMechanism.SectionResults, context.WrappedData, context.FailureMechanism.Calculations.Cast()); calculationGroupContext.NotifyObservers(); } } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r3e79015849651b140c9b496e8f0f57fcdcac0d92 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision 3e79015849651b140c9b496e8f0f57fcdcac0d92) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -233,7 +233,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSectionStub, treeViewControl)) { // Assert - Assert.AreEqual(6, menu.Items.Count); + Assert.AreEqual(10, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateIndex, RingtoetsCommonFormsResources.Validate, Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r3e79015849651b140c9b496e8f0f57fcdcac0d92 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 3e79015849651b140c9b496e8f0f57fcdcac0d92) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -44,6 +44,7 @@ using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HeightStructures.Plugin; using Ringtoets.HydraRing.Data; + using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources; @@ -57,7 +58,6 @@ private const int contextGenerateCalculationsIndexRootGroup = 0; private const int contextMenuAddCalculationGroupIndexRootGroup = 2; private const int contextMenuAddCalculationIndexRootGroup = 3; - private const int contextMenuRemoveAllChildrenRootGroupIndex = 5; private const int contextMenuValidateAllIndexRootGroup = 7; private const int contextMenuCalculateAllIndexRootGroup = 8; private const int contextMenuClearAllIndexRootGroup = 9; @@ -187,7 +187,7 @@ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -236,7 +236,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) { // Assert - Assert.AreEqual(12, menu.Items.Count); + Assert.AreEqual(14, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextGenerateCalculationsIndexRootGroup, "Genereer &berekeningen...", @@ -251,11 +251,6 @@ "Berekening &toevoegen", "Voeg een nieuwe berekening toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.FailureMechanismIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenRootGroupIndex, - "Map &leegmaken...", - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, - false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, "Alles &valideren", @@ -301,7 +296,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) { // Assert - Assert.AreEqual(12, menu.Items.Count); + Assert.AreEqual(14, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextGenerateCalculationsIndexRootGroup, "Genereer &berekeningen...", @@ -382,7 +377,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl)) { // Assert - Assert.AreEqual(9, menu.Items.Count); + Assert.AreEqual(13, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, "&Map toevoegen", @@ -1050,56 +1045,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroup_RemovesAllChildren() - { - // Setup - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var group = new CalculationGroup(); - var failureMechanism = new HeightStructuresFailureMechanism(); - var assessmentSectionStub = mocks.Stub(); - var nodeData = new HeightStructuresCalculationGroupContext(group, - failureMechanism, - assessmentSectionStub); - var calculation = new HeightStructuresCalculation - { - Name = "Nieuwe berekening" - }; - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - var observerMock = mocks.StrictMock(); - observerMock.Expect(o => o.UpdateObserver()); - - using (var treeViewControl = new TreeViewControl()) - { - guiStub.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - guiStub.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - group.Children.Add(calculation); - nodeData.Attach(observerMock); - - plugin.Gui = guiStub; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllChildrenRootGroupIndex].PerformClick(); - - // Assert - Assert.IsEmpty(group.Children); - } - } - } - - [Test] public void GivenCalculationsViewGenerateScenariosButtonClicked_WhenDikeProfileSelectedAndDialogClosed_ThenCalculationsAddedWithProfileAssigned() { // Given Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r3e79015849651b140c9b496e8f0f57fcdcac0d92 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision 3e79015849651b140c9b496e8f0f57fcdcac0d92) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../HeightStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -268,7 +268,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(7, menu.Items.Count); + Assert.AreEqual(9, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenRelevant, RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant, @@ -322,7 +322,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(2, menu.Items.Count); + Assert.AreEqual(3, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenNotRelevant, RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant, Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r98929f84fbf311bd19d8e61cc8499cdb40b22ea0 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 98929f84fbf311bd19d8e61cc8499cdb40b22ea0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -674,7 +674,7 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -338,11 +338,6 @@ "Voeg een nieuwe berekening toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.CalculationIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, - RingtoetsCommonFormsResources.RemoveAllIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, RingtoetsCommonFormsResources.Validate_all, "Valideer alle berekeningen binnen deze berekeningsmap.", @@ -561,86 +556,6 @@ } [Test] - public void ContextMenuStrip_WithoutParentNodeWithNoChildren_RemoveAllChildrenDisabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var group = new CalculationGroup(); - - var pipingFailureMechanism = new PipingFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanism, - assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.StrictMock(); - gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemDisabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsFalse(removeAllItemDisabled.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove, removeAllItemDisabled.ToolTipText); - } - } - } - - [Test] - public void ContextMenuStrip_WithoutParentNodeWithChildren_RemoveAllChildrenEnabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var group = new CalculationGroup - { - Children = - { - mocks.Stub() - } - }; - - var pipingFailureMechanism = new PipingFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanism, - assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.StrictMock(); - gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemEnabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsTrue(removeAllItemEnabled.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, removeAllItemEnabled.ToolTipText); - } - } - } - - [Test] public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup @@ -1051,58 +966,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroup_RemovesAllChildren() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var calculation = mocks.Stub(); - var group = new CalculationGroup - { - Children = - { - calculation - } - }; - - var pipingFailureMechanism = new PipingFailureMechanism(); - var assessmentSectionMock = mocks.StrictMock(); - var nodeData = new PipingCalculationGroupContext(group, - Enumerable.Empty(), - Enumerable.Empty(), - pipingFailureMechanism, - assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - var gui = mocks.StrictMock(); - gui.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex].PerformClick(); - - // Assert - Assert.IsEmpty(group.Children); - } - } - } - - [Test] public void GivenPipingCalculationsViewGenerateScenariosButtonClicked_WhenSurfaceLineSelectedAndDialogClosed_ThenUpdateSectionResultScenarios() { // Given Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -r44837ec463259677b2bc84d05e020de9fb5b782c -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 44837ec463259677b2bc84d05e020de9fb5b782c) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -357,7 +357,7 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -re92866220b9db723bb193729dc1928015e02f200 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision e92866220b9db723bb193729dc1928015e02f200) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -238,7 +238,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSectionMock, treeViewControl)) { // Assert - Assert.AreEqual(6, menu.Items.Count); + Assert.AreEqual(10, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateIndex, RingtoetsCommonFormsResources.Validate, Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r59f4e7527823f1ae08a78e8f937c454e56f1c5df -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 59f4e7527823f1ae08a78e8f937c454e56f1c5df) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -51,7 +51,6 @@ { private const int contextMenuAddCalculationGroupIndexRootGroup = 2; private const int contextMenuAddCalculationIndexRootGroup = 3; - private const int contextMenuRemoveAllChildrenRootGroupIndex = 5; private const int contextMenuValidateAllIndexRootGroup = 7; private const int contextMenuCalculateAllIndexRootGroup = 8; private const int contextMenuClearAllIndexRootGroup = 9; @@ -178,7 +177,7 @@ menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); - menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); + menuBuilderMock.Expect(mb => mb.AddDeleteChildrenItem()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddSeparator()).Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); menuBuilderMock.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilderMock); @@ -227,7 +226,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) { // Assert - Assert.AreEqual(12, menu.Items.Count); + Assert.AreEqual(14, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup_Tooltip, @@ -236,11 +235,6 @@ RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation_Tooltip, RingtoetsCommonFormsResources.FailureMechanismIcon); - TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenRootGroupIndex, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove, - RingtoetsCommonFormsResources.RemoveAllIcon, - false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, RingtoetsCommonFormsResources.Validate_all, RingtoetsCommonFormsResources.ValidateAll_No_calculations_to_validate, @@ -707,7 +701,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, parentGroupContext, treeViewControl)) { // Assert - Assert.AreEqual(9, menu.Items.Count); + Assert.AreEqual(13, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexNestedGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, @@ -830,55 +824,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroup_RemovesAllChildren() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var calculation = mocks.Stub(); - var group = new CalculationGroup - { - Children = - { - calculation - } - }; - - var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var assessmentSectionMock = mocks.Stub(); - var nodeData = new StabilityPointStructuresCalculationGroupContext(group, - failureMechanism, - assessmentSectionMock); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - guiMock.Expect(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - guiMock.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = guiMock; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllChildrenRootGroupIndex].PerformClick(); - - // Assert - Assert.IsEmpty(group.Children); - } - } - } - - [Test] public void OnNodeRemoved_NestedCalculationGroup_RemoveGroupAndNotifyObservers() { // Setup Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -rc3a5f6f1b7c5a89cf8d81b52b48eea471b3a4ffe -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision c3a5f6f1b7c5a89cf8d81b52b48eea471b3a4ffe) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs (.../StabilityPointStructuresFailureMechanismContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -274,7 +274,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(7, menu.Items.Count); + Assert.AreEqual(9, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenRelevant, RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant, @@ -333,7 +333,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, assessmentSectionMock, treeView)) { // Assert - Assert.AreEqual(2, menu.Items.Count); + Assert.AreEqual(3, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenNotRelevant, RingtoetsCommonFormsResources.FailureMechanismContextMenuStrip_Is_relevant, Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -r98929f84fbf311bd19d8e61cc8499cdb40b22ea0 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 98929f84fbf311bd19d8e61cc8499cdb40b22ea0) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -311,7 +311,7 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -68,19 +68,14 @@ private const int contextMenuCollapseAllIndexRootGroup = 13; private const int contextMenuPropertiesIndexRootGroup = 15; + private const int customOnlyContextMenuAddGenerateCalculationsIndex = 0; private const int contextMenuAddCalculationGroupIndexNestedGroup = 2; private const int contextMenuAddCalculationIndexNestedGroup = 3; private const int contextMenuValidateAllIndexNestedGroup = 5; private const int contextMenuCalculateAllIndexNestedGroup = 6; private const int contextMenuClearOutputNestedGroupIndex = 7; - private const int customOnlyContextMenuAddGenerateCalculationsIndex = 0; - private const int contextMenuValidateAllIndexNestedGroupNoCalculations = 4; - private const int contextMenuCalculateAllIndexNestedGroupNoCalculations = 5; - private const int contextMenuRemoveAllInGroup = 5; - - private const int customOnlyContextMenuRemoveAllChildrenIndex = 5; private MockRepository mocks; private StabilityStoneCoverPlugin plugin; private TreeNodeInfo info; @@ -369,11 +364,13 @@ RingtoetsCommonFormsResources.CalculationGroup_Add_Calculation, "Voeg een nieuwe berekening toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.FailureMechanismIcon); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, + CoreCommonGuiResources.DeleteChildren, + CoreCommonGuiResources.DeleteChildren_ToolTip, + CoreCommonGuiResources.DeleteChildrenIcon, false); + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, RingtoetsCommonFormsResources.Validate_all, "Er zijn geen berekeningen om te valideren.", @@ -476,9 +473,9 @@ RingtoetsCommonFormsResources.FailureMechanismIcon); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all, - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, + CoreCommonGuiResources.DeleteChildren, + CoreCommonGuiResources.DeleteChildren_ToolTip, + CoreCommonGuiResources.DeleteChildrenIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, @@ -526,7 +523,7 @@ } [Test] - public void ContextMenuStrip_NestedCalculationGroupWithNoCalculations_ValidateAndCalculateAllDisabled() + public void ContextMenuStrip_NestedCalculationGroupWith_ValidateAndCalculateAllDisabled() { // Setup using (var treeViewControl = new TreeViewControl()) @@ -555,8 +552,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanism_CreateCalculateAllItem_No_calculations_to_run, calculateItem.ToolTipText); @@ -596,8 +593,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported, calculateItem.ToolTipText); @@ -641,8 +638,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); var message = "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': Bestandspad mag niet leeg of ongedefinieerd zijn."; @@ -727,7 +724,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - Action test = () => contextMenu.Items[4].PerformClick(); + Action test = () => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); // Assert TestHelper.AssertLogMessages(test, m => @@ -803,7 +800,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - Action test = () => contextMenu.Items[5].PerformClick(); + Action test = () => contextMenu.Items[contextMenuCalculateAllIndexNestedGroup].PerformClick(); // Assert TestHelper.AssertLogMessages(test, m => @@ -925,7 +922,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[6]; + var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputNestedGroupIndex]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -1013,7 +1010,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - contextMenu.Items[6].PerformClick(); + contextMenu.Items[contextMenuClearOutputNestedGroupIndex].PerformClick(); // Assert if (confirm) @@ -1026,74 +1023,6 @@ } [Test] - public void ContextMenuStrip_WithoutParentNodeWithNoChildren_RemoveAllChildrenDisabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - - var failureMechanism = new StabilityStoneCoverFailureMechanism(); - var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemDisabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsFalse(removeAllItemDisabled.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_No_Calculation_or_Group_to_remove, removeAllItemDisabled.ToolTipText); - } - } - } - - [Test] - public void ContextMenuStrip_WithoutParentNodeWithChildren_RemoveAllChildrenEnabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(mocks.Stub()); - var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemEnabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsTrue(removeAllItemEnabled.Enabled); - Assert.AreEqual(RingtoetsCommonFormsResources.CalculationGroup_RemoveAllChildrenFromGroup_Remove_all_Tooltip, removeAllItemEnabled.ToolTipText); - } - } - } - - [Test] public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup @@ -1137,7 +1066,7 @@ Assert.AreEqual(1, group.Children.Count); // Call - contextMenu.Items[1].PerformClick(); + contextMenu.Items[contextMenuAddCalculationGroupIndexNestedGroup].PerformClick(); // Assert Assert.AreEqual(2, group.Children.Count); @@ -1150,98 +1079,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroupAndConfirm_RemovesAllChildren() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var calculation = mocks.Stub(); - var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - failureMechanism.WaveConditionsCalculationGroup.Attach(observer); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - - // Assert - Assert.IsEmpty(failureMechanism.WaveConditionsCalculationGroup.Children); - } - } - } - - [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroupAndCancel_ChildrenNotRemoved() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var calculation = mocks.Stub(); - var failureMechanism = new StabilityStoneCoverFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickCancel(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - - // Assert - Assert.AreEqual(new[] - { - calculation - }, failureMechanism.WaveConditionsCalculationGroup.Children); - } - } - } - - [Test] public void GivenDialogGenerateCalculationButtonClicked_WhenCalculationSelectedAndDialogClosed_ThenUpdateCalculationGroup() { // Given Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r98929f84fbf311bd19d8e61cc8499cdb40b22ea0 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 98929f84fbf311bd19d8e61cc8499cdb40b22ea0) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -317,7 +317,7 @@ if (!isNestedGroup) { builder.AddSeparator() - .AddRemoveAllChildrenItem(group, Gui.ViewCommands); + .AddRemoveAllChildrenItem(); } builder.AddSeparator() Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -rb6f4e414fc874653cc6ad84b80f330b28e69b823 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/TreeNodeInfos/WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision b6f4e414fc874653cc6ad84b80f330b28e69b823) @@ -68,19 +68,13 @@ private const int contextMenuCollapseAllIndexRootGroup = 13; private const int contextMenuPropertiesIndexRootGroup = 15; + private const int contextMenuAddGenerateCalculationsIndex = 0; private const int contextMenuAddCalculationGroupIndexNestedGroup = 2; private const int contextMenuAddCalculationIndexNestedGroup = 3; private const int contextMenuValidateAllIndexNestedGroup = 5; private const int contextMenuCalculateAllIndexNestedGroup = 6; private const int contextMenuClearOutputNestedGroupIndex = 7; - private const int customOnlyContextMenuAddGenerateCalculationsIndex = 0; - private const int contextMenuValidateAllIndexNestedGroupNoCalculations = 4; - private const int contextMenuCalculateAllIndexNestedGroupNoCalculations = 5; - - private const int contextMenuRemoveAllInGroup = 5; - - private const int customOnlyContextMenuRemoveAllChildrenIndex = 5; private MockRepository mocks; private WaveImpactAsphaltCoverPlugin plugin; private TreeNodeInfo info; @@ -357,7 +351,7 @@ { // Assert Assert.AreEqual(16, menu.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, "Genereer &berekeningen...", "Er is geen hydraulische randvoorwaardendatabase beschikbaar om de randvoorwaardenberekeningen te genereren.", RingtoetsCommonFormsResources.GenerateScenariosIcon, false); @@ -370,9 +364,9 @@ "Voeg een nieuwe berekening toe aan deze berekeningsmap.", RingtoetsCommonFormsResources.FailureMechanismIcon); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - "Map &leegmaken...", - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, + CoreCommonGuiResources.DeleteChildren, + CoreCommonGuiResources.DeleteChildren_ToolTip, + CoreCommonGuiResources.DeleteChildrenIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, "Alles &valideren", @@ -462,7 +456,7 @@ { // Assert Assert.AreEqual(16, menu.Items.Count); - TestHelper.AssertContextMenuStripContainsItem(menu, customOnlyContextMenuAddGenerateCalculationsIndex, + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddGenerateCalculationsIndex, "Genereer &berekeningen...", "Genereer randvoorwaardenberekeningen.", RingtoetsCommonFormsResources.GenerateScenariosIcon); @@ -476,9 +470,9 @@ RingtoetsCommonFormsResources.FailureMechanismIcon); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRemoveAllChildrenIndexRootGroup, - "Map &leegmaken...", - "Er zijn geen berekeningen of mappen om te verwijderen.", - RingtoetsCommonFormsResources.RemoveAllIcon, + CoreCommonGuiResources.DeleteChildren, + CoreCommonGuiResources.DeleteChildren_ToolTip, + CoreCommonGuiResources.DeleteChildrenIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, @@ -526,7 +520,7 @@ } [Test] - public void ContextMenuStrip_NestedCalculationGroupWithNoCalculations_ValidateAndCalculateAllDisabled() + public void ContextMenuStrip_NestedCalculationGroupWith_ValidateAndCalculateAllDisabled() { // Setup using (var treeViewControl = new TreeViewControl()) @@ -555,8 +549,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); Assert.AreEqual("Er zijn geen berekeningen om uit te voeren.", calculateItem.ToolTipText); @@ -596,8 +590,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); Assert.AreEqual(RingtoetsCommonFormsResources.Plugin_AllDataAvailable_No_hydraulic_boundary_database_imported, calculateItem.ToolTipText); @@ -641,8 +635,8 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Assert - ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroupNoCalculations]; - ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroupNoCalculations]; + ToolStripItem validateItem = contextMenu.Items[contextMenuValidateAllIndexNestedGroup]; + ToolStripItem calculateItem = contextMenu.Items[contextMenuCalculateAllIndexNestedGroup]; Assert.IsFalse(validateItem.Enabled); Assert.IsFalse(calculateItem.Enabled); var message = "Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt. Fout bij het lezen van bestand '': Bestandspad mag niet leeg of ongedefinieerd zijn."; @@ -727,7 +721,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - Action test = () => contextMenu.Items[4].PerformClick(); + Action test = () => contextMenu.Items[contextMenuValidateAllIndexNestedGroup].PerformClick(); // Assert TestHelper.AssertLogMessages(test, m => @@ -803,7 +797,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - Action test = () => contextMenu.Items[5].PerformClick(); + Action test = () => contextMenu.Items[contextMenuCalculateAllIndexNestedGroup].PerformClick(); // Assert TestHelper.AssertLogMessages(test, m => @@ -923,7 +917,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - var clearAllOutputItem = contextMenu.Items[6]; + var clearAllOutputItem = contextMenu.Items[contextMenuClearOutputNestedGroupIndex]; // Assert Assert.IsFalse(clearAllOutputItem.Enabled); @@ -1006,7 +1000,7 @@ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // Call - contextMenu.Items[6].PerformClick(); + contextMenu.Items[contextMenuClearOutputNestedGroupIndex].PerformClick(); // Assert if (confirm) @@ -1019,74 +1013,6 @@ } [Test] - public void ContextMenuStrip_WithoutParentNodeWithNoChildren_RemoveAllChildrenDisabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemDisabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsFalse(removeAllItemDisabled.Enabled); - Assert.AreEqual("Er zijn geen berekeningen of mappen om te verwijderen.", removeAllItemDisabled.ToolTipText); - } - } - } - - [Test] - public void ContextMenuStrip_WithoutParentNodeWithChildren_RemoveAllChildrenEnabled() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(mocks.Stub()); - var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - // Call - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Assert - ToolStripItem removeAllItemEnabled = contextMenu.Items[customOnlyContextMenuRemoveAllChildrenIndex]; - Assert.IsTrue(removeAllItemEnabled.Enabled); - Assert.AreEqual("Verwijder alle berekeningen en mappen binnen deze map.", removeAllItemEnabled.ToolTipText); - } - } - } - - [Test] public void ContextMenuStrip_ClickOnAddGroupItem_AddGroupToCalculationGroupAndNotifyObservers() { // Setup @@ -1130,7 +1056,7 @@ Assert.AreEqual(1, group.Children.Count); // Call - contextMenu.Items[1].PerformClick(); + contextMenu.Items[contextMenuAddCalculationGroupIndexNestedGroup].PerformClick(); // Assert Assert.AreEqual(2, group.Children.Count); @@ -1143,98 +1069,6 @@ } [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroupAndConfirm_RemovesAllChildren() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var calculation = mocks.Stub(); - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - viewCommandsMock.Expect(vc => vc.RemoveAllViewsForItem(calculation)); - - var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - failureMechanism.WaveConditionsCalculationGroup.Attach(observer); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickOk(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - - // Assert - Assert.IsEmpty(failureMechanism.WaveConditionsCalculationGroup.Children); - } - } - } - - [Test] - public void ContextMenuStrip_ClickOnRemoveAllInGroupAndCancel_ChildrenNotRemoved() - { - // Setup - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - var calculation = mocks.Stub(); - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); - failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation); - var nodeData = new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(failureMechanism.WaveConditionsCalculationGroup, - failureMechanism, - assessmentSection); - - var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var viewCommandsMock = mocks.StrictMock(); - - var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); - gui.Stub(cmp => cmp.ViewCommands).Return(viewCommandsMock); - - mocks.ReplayAll(); - - plugin.Gui = gui; - - DialogBoxHandler = (name, wnd) => - { - var dialog = new MessageBoxTester(wnd); - dialog.ClickCancel(); - }; - - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) - { - // Call - contextMenu.Items[contextMenuRemoveAllInGroup].PerformClick(); - - // Assert - Assert.AreEqual(new[] - { - calculation - }, failureMechanism.WaveConditionsCalculationGroup.Children); - } - } - } - - [Test] public void GivenDialogGenerateCalculationButtonClicked_WhenCalculationSelectedAndDialogClosed_ThenUpdateCalculationGroup() { // Given @@ -1286,7 +1120,7 @@ // When using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - contextMenu.Items[customOnlyContextMenuAddGenerateCalculationsIndex].PerformClick(); + contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); } // Then @@ -1345,7 +1179,7 @@ // When using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { - contextMenu.Items[customOnlyContextMenuAddGenerateCalculationsIndex].PerformClick(); + contextMenu.Items[contextMenuAddGenerateCalculationsIndex].PerformClick(); } // Then