Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -rd14cc356c199c64f5f26df966d74206268e8c1fc -r5b29dd531b618b6d3969e7cba9c95d31517290e4 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision d14cc356c199c64f5f26df966d74206268e8c1fc) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 5b29dd531b618b6d3969e7cba9c95d31517290e4) @@ -787,6 +787,8 @@ RingtoetsCommonDataResources.Calculation_DefaultName, c => c.Name) }; + WaveConditionsInputHelper.SetCategoryType(calculation.InputParameters, + nodeData.AssessmentSection.FailureMechanismContribution.NormativeNorm); nodeData.WrappedData.Children.Add(calculation); nodeData.WrappedData.NotifyObservers(); } Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r413127864a46a671ee8361e152d97d9b04daedca -r5b29dd531b618b6d3969e7cba9c95d31517290e4 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 413127864a46a671ee8361e152d97d9b04daedca) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 5b29dd531b618b6d3969e7cba9c95d31517290e4) @@ -39,6 +39,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.Contribution; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; @@ -1519,6 +1520,65 @@ } [Test] + [TestCase(NormType.Signaling)] + [TestCase(NormType.LowerLimit)] + public void ContextMenuStrip_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers( + NormType normType) + { + // Setup + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var assessmentSection = new AssessmentSectionStub + { + FailureMechanismContribution = + { + NormativeNorm = normType + } + }; + var nodeData = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + var calculationItem = new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Name = "Nieuwe berekening" + }; + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.ViewCommands).Return(mocks.Stub()); + gui.Stub(g => g.MainWindow).Return(mocks.Stub()); + mocks.ReplayAll(); + + group.Children.Add(calculationItem); + nodeData.Attach(observer); + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Precondition + Assert.AreEqual(1, group.Children.Count); + + // Call + contextMenu.Items[contextMenuAddCalculationIndexRootGroup].PerformClick(); + + // Assert + Assert.AreEqual(2, group.Children.Count); + ICalculationBase newlyAddedItem = group.Children.Last(); + + var newCalculationItem = newlyAddedItem as GrassCoverErosionOutwardsWaveConditionsCalculation; + Assert.IsNotNull(newCalculationItem); + Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name, + "An item with the same name default name already exists, therefore '(1)' needs to be appended."); + Assert.AreEqual(GetCategoryTypeFromNormType(normType), newCalculationItem.InputParameters.CategoryType); + } + } + } + + [Test] public void ContextMenuStrip_WithForeshoreProfileAndChanges_ContextMenuItemUpdateAllForeshoreProfilesEnabled() { // Setup @@ -1935,5 +1995,18 @@ } }; } + + private static FailureMechanismCategoryType GetCategoryTypeFromNormType(NormType normType) + { + switch (normType) + { + case NormType.LowerLimit: + return FailureMechanismCategoryType.MechanismSpecificLowerLimitNorm; + case NormType.Signaling: + return FailureMechanismCategoryType.MechanismSpecificSignalingNorm; + default: + throw new NotSupportedException(); + } + } } } \ No newline at end of file