Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -ra92d855b6fc9909bd631abaa16682e715a1d47c0 -r59f4e7527823f1ae08a78e8f937c454e56f1c5df --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision a92d855b6fc9909bd631abaa16682e715a1d47c0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/TreeNodeInfos/StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityPointStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 59f4e7527823f1ae08a78e8f937c454e56f1c5df) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.IO; using System.Linq; using System.Windows.Forms; using Core.Common.Base; @@ -60,6 +61,7 @@ private const int contextMenuValidateAllIndexNestedGroup = 3; private const int contextMenuCalculateAllIndexNestedGroup = 4; private const int contextMenuClearAllIndexNestedGroup = 5; + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "HydraulicBoundaryLocationReader"); private IGui guiMock; private TreeNodeInfo info; @@ -394,6 +396,61 @@ } [Test] + public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var group = new CalculationGroup + { + Children = + { + new StabilityPointStructuresCalculation() + } + }; + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + failureMechanism.CalculationsGroup.Children.Add(new StabilityPointStructuresCalculation()); + + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var nodeData = new StabilityPointStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndexRootGroup, + RingtoetsCommonFormsResources.Calculate_all, + RingtoetsCommonFormsResources.CalculationGroup_CalculateAll_ToolTip, + RingtoetsCommonFormsResources.CalculateAllIcon); + } + } + } + + [Test] public void ContextMenuStrip_NoFailureMechanismSections_ContextMenuItemValidateAllDisabledAndTooltipSet() { // Setup @@ -528,6 +585,61 @@ } [Test] + public void ContextMenuStrip_FailureMechanismSectionsAndHydraulicDatabaseSet_ContextMenuItemValidateAllEnabled() + { + // Setup + var group = new CalculationGroup + { + Children = + { + new StabilityPointStructuresCalculation() + } + }; + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + failureMechanism.AddSection(new FailureMechanismSection("test", new[] + { + new Point2D(0, 0) + })); + failureMechanism.CalculationsGroup.Children.Add(new StabilityPointStructuresCalculation()); + + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; + + var nodeData = new StabilityPointStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup, + RingtoetsCommonFormsResources.Validate_all, + RingtoetsCommonFormsResources.CalculationGroup_Validate_all_ToolTip, + RingtoetsCommonFormsResources.ValidateAllIcon); + } + } + } + + [Test] public void ContextMenuStrip_NestedCalculationGroup_CallsContextMenuBuilderMethods() { // Setup