Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -rb9bc80f092532ba74f554ee960161a06b4ddaf91 -rf6d370ae60e36ea4f00c94013e0805d91cc7cc6f --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision b9bc80f092532ba74f554ee960161a06b4ddaf91) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision f6d370ae60e36ea4f00c94013e0805d91cc7cc6f) @@ -517,6 +517,9 @@ RingtoetsCommonDataResources.Calculation_DefaultName, c => c.Name) }; + WaveConditionsInputHelper.SetCategoryType(calculation.InputParameters, + nodeData.AssessmentSection.FailureMechanismContribution.NormativeNorm); + nodeData.WrappedData.Children.Add(calculation); nodeData.WrappedData.NotifyObservers(); } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r255eb9c91345a1a5bd18d40143f4f157dfe0bf46 -rf6d370ae60e36ea4f00c94013e0805d91cc7cc6f --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 255eb9c91345a1a5bd18d40143f4f157dfe0bf46) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision f6d370ae60e36ea4f00c94013e0805d91cc7cc6f) @@ -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.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms; @@ -1414,6 +1415,66 @@ } [Test] + [TestCase(NormType.Signaling, AssessmentSectionCategoryType.SignalingNorm)] + [TestCase(NormType.LowerLimit, AssessmentSectionCategoryType.LowerLimitNorm)] + public void ContextMenuStrip_ClickOnAddCalculationItem_AddCalculationToCalculationGroupAndNotifyObservers( + NormType normType, + AssessmentSectionCategoryType expectedAssessmentSectionCategoryType) + { + // Setup + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + var group = new CalculationGroup(); + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var assessmentSection = new AssessmentSectionStub + { + FailureMechanismContribution = + { + NormativeNorm = normType + } + }; + var nodeData = new StabilityStoneCoverWaveConditionsCalculationGroupContext(group, + null, + failureMechanism, + assessmentSection); + var calculationItem = new StabilityStoneCoverWaveConditionsCalculation + { + 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(); + Assert.IsInstanceOf(newlyAddedItem); + Assert.AreEqual("Nieuwe berekening (1)", newlyAddedItem.Name, + "An item with the same name default name already exists, therefore '(1)' needs to be appended."); + + var newCalculationItem = (StabilityStoneCoverWaveConditionsCalculation) newlyAddedItem; + Assert.AreEqual(expectedAssessmentSectionCategoryType, newCalculationItem.InputParameters.CategoryType); + } + } + } + + [Test] public void GivenDialogGenerateCalculationButtonClicked_WhenCalculationSelectedAndDialogClosed_ThenUpdateCalculationGroup() { // Given