Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rb2306061789f5e34a6f0994552b4431d01d220f0 -r7164a642dc83ca7a1fd78513cbff9da53c052602 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision b2306061789f5e34a6f0994552b4431d01d220f0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/TreeNodeInfos/HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs (.../HeightStructuresCalculationGroupContextTreeNodeInfoTest.cs) (revision 7164a642dc83ca7a1fd78513cbff9da53c052602) @@ -40,6 +40,7 @@ using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; using Ringtoets.HeightStructures.Plugin; +using Ringtoets.HeightStructures.Plugin.Properties; using Ringtoets.HydraRing.Data; using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -50,12 +51,13 @@ [TestFixture] public class HeightStructuresCalculationGroupContextTreeNodeInfoTest : NUnitFormTest { - 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; + 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; private const int contextMenuAddCalculationGroupIndexNestedGroup = 0; private const int contextMenuAddCalculationIndexNestedGroup = 1; @@ -178,7 +180,9 @@ var menuBuilderMock = mocks.StrictMock(); 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.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.AddSeparator()).Return(menuBuilderMock); @@ -229,8 +233,13 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) { // Assert - Assert.AreEqual(10, menu.Items.Count); + Assert.AreEqual(12, menu.Items.Count); + TestHelper.AssertContextMenuStripContainsItem(menu, contextGenerateCalculationsIndexRootGroup, + RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations, + Resources.HeightStructuresPlugin_No_structures_to_generate_for, + RingtoetsCommonFormsResources.GenerateScenariosIcon, + false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddCalculationGroupIndexRootGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup, RingtoetsCommonFormsResources.CalculationGroup_Add_CalculationGroup_Tooltip, @@ -265,6 +274,41 @@ } [Test] + public void ContextMenuStrip_WithoutParentNodeWithStructuresImported_GenerateItemEnabledWithTooltip() + { + // Setup + var group = new CalculationGroup(); + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.HeightStructures.Add(new TestHeightStructure()); + var assessmentSectionMock = mocks.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + var groupContext = new HeightStructuresCalculationGroupContext(group, + failureMechanism, + assessmentSectionMock); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + guiMock.Expect(g => g.Get(groupContext, treeViewControl)).Return(menuBuilder); + guiMock.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); + + mocks.ReplayAll(); + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(groupContext, null, treeViewControl)) + { + // Assert + Assert.AreEqual(12, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextGenerateCalculationsIndexRootGroup, + RingtoetsCommonFormsResources.CalculationsGroup_Generate_calculations, + Resources.HeightStructuresPlugin_Generate_calculations_for_selected_strutures, + RingtoetsCommonFormsResources.GenerateScenariosIcon); + } + } + } + + [Test] public void ContextMenuStrip_NestedCalculationGroup_CallsContextMenuBuilderMethods() { // Setup @@ -1118,6 +1162,14 @@ CollectionAssert.DoesNotContain(parentGroup.Children, group); } + private class TestHeightStructure : HeightStructure + { + public TestHeightStructure() + : base("Test", "Id", new Point2D(0, 0), 0.12345, 234.567, 0.23456, + 345.678, 0.34567, 456.789, 0.45678, 567.890, 0.56789, + 0.67890, 112.223, 0.11222, 225.336, 0.22533) {} + } + public override void TearDown() { plugin.Dispose();