Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r5bf6a765222c80d0d2b52cad46f0699dede3f2c2
--- Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/TreeNodeInfos/RingtoetsContextMenuBuilder.cs (.../RingtoetsContextMenuBuilder.cs) (revision 5bf6a765222c80d0d2b52cad46f0699dede3f2c2)
@@ -21,8 +21,10 @@
using System;
using System.Windows.Forms;
+using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Forms.PresentationObjects;
@@ -247,6 +249,29 @@
return this;
}
+ ///
+ /// Adds an item to the , which is bound to the action
+ /// when updating the of a .
+ ///
+ /// The type of calculation input that has can have
+ /// a foreshore profile.
+ /// The calculation to update.
+ /// Object responsible for inquiring the required data.
+ /// The action to perform when the foreshore profile is updated.
+ /// The itself.
+ public RingtoetsContextMenuBuilder AddUpdateForeshoreProfileOfCalculationItem(
+ ICalculation calculation,
+ IInquiryHelper inquiryHelper,
+ Action> updateAction)
+ where TCalculationInput : ICalculationInput, IHasForeshoreProfile
+ {
+ contextMenuBuilder.AddCustomItem(RingtoetsContextMenuItemFactory.CreateUpdateForshoreProfileOfCalculationItem(
+ calculation,
+ inquiryHelper,
+ updateAction));
+ return this;
+ }
+
#region Decorated members
///
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r5bf6a765222c80d0d2b52cad46f0699dede3f2c2
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuBuilderTest.cs (.../RingtoetsContextMenuBuilderTest.cs) (revision 5bf6a765222c80d0d2b52cad46f0699dede3f2c2)
@@ -25,6 +25,7 @@
using System.Windows.Forms;
using Core.Common.Base;
using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
using Core.Common.TestUtil;
@@ -33,6 +34,7 @@
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Forms.PresentationObjects;
@@ -112,7 +114,7 @@
var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
// Call
- ContextMenuStrip result = ringtoetsContextMenuBuilder.AddCreateCalculationItem(calculationGroupContext, context => { }).Build();
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddCreateCalculationItem(calculationGroupContext, context => {}).Build();
// Assert
Assert.IsInstanceOf(result);
@@ -1625,6 +1627,105 @@
#endregion
+ #region AddUpdateForeshoreProfileOfCalculationItem
+
+ [Test]
+ public void AddUpdateForeshoreProfileOfCalculationItem_CalculationWithForeshoreProfile_ItemAddedToContextMenuEnabled()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var importHandlerMock = mocks.StrictMock();
+ var exportHandlerMock = mocks.StrictMock();
+ var updateHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
+ var inquiryHelperMock = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock,
+ importHandlerMock,
+ exportHandlerMock,
+ updateHandlerMock,
+ viewCommandsMock,
+ calculationMock,
+ treeViewControl);
+
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationItem(
+ calculationMock,
+ inquiryHelperMock,
+ c => {}).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ "&Bijwerken voorlandprofiel...",
+ "Berekening bijwerken waar een voorlandprofiel geselecteerd is.",
+ RingtoetsFormsResources.UpdateItemIcon);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void AddUpdateForeshoreProfileOfCalculationItem_CalculationWithoutForeshoreProfile_ItemAddedToContextMenuDisabled()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var applicationFeatureCommandsMock = mocks.StrictMock();
+ var importHandlerMock = mocks.StrictMock();
+ var exportHandlerMock = mocks.StrictMock();
+ var updateHandlerMock = mocks.StrictMock();
+ var viewCommandsMock = mocks.StrictMock();
+
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(null);
+ var inquiryHelperMock = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var contextMenuBuilder = new ContextMenuBuilder(applicationFeatureCommandsMock,
+ importHandlerMock,
+ exportHandlerMock,
+ updateHandlerMock,
+ viewCommandsMock,
+ calculationMock,
+ treeViewControl);
+
+ var ringtoetsContextMenuBuilder = new RingtoetsContextMenuBuilder(contextMenuBuilder);
+
+ // Call
+ ContextMenuStrip result = ringtoetsContextMenuBuilder.AddUpdateForeshoreProfileOfCalculationItem(
+ calculationMock,
+ inquiryHelperMock,
+ c => {}).Build();
+
+ // Assert
+ Assert.IsInstanceOf(result);
+ Assert.AreEqual(1, result.Items.Count);
+ TestHelper.AssertContextMenuStripContainsItem(result, 0,
+ "&Bijwerken voorlandprofiel...",
+ "Er moet een voorlandprofiel geselecteerd zijn.",
+ RingtoetsFormsResources.UpdateItemIcon,
+ false);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ public interface ICalculationInputWithForeshoreProfile : ICalculationInput, IHasForeshoreProfile {}
+
+ #endregion
+
#region Nested types
private class TestFailureMechanismContext : FailureMechanismContext
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs
===================================================================
diff -u -r49cf783c59b933669fb20686fd9fdf23c51428e4 -r5bf6a765222c80d0d2b52cad46f0699dede3f2c2
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 49cf783c59b933669fb20686fd9fdf23c51428e4)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 5bf6a765222c80d0d2b52cad46f0699dede3f2c2)
@@ -603,15 +603,15 @@
{
// Setup
var mocks = new MockRepository();
- var calculation = mocks.StrictMock>();
- calculation.Expect(c => c.InputParameters.ForeshoreProfile).Return(null);
- var inquiryHelper = mocks.StrictMock();
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(null);
+ var inquiryHelperMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForshoreProfileOfCalculationItem(
- calculation,
- inquiryHelper, c => {});
+ calculationMock,
+ inquiryHelperMock, c => {});
// Assert
Assert.AreEqual("&Bijwerken voorlandprofiel...", toolStripItem.Text);
@@ -626,15 +626,15 @@
{
// Setup
var mocks = new MockRepository();
- var calculation = mocks.StrictMock>();
- calculation.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
- var inquiryHelper = mocks.StrictMock();
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
+ var inquiryHelperMock = mocks.StrictMock();
mocks.ReplayAll();
// Call
StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForshoreProfileOfCalculationItem(
- calculation,
- inquiryHelper, c => {});
+ calculationMock,
+ inquiryHelperMock, c => {});
// Assert
Assert.AreEqual("&Bijwerken voorlandprofiel...", toolStripItem.Text);
@@ -649,23 +649,23 @@
{
// Setup
var mocks = new MockRepository();
- var calculation = mocks.StrictMock>();
- calculation.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
- calculation.Expect(c => c.HasOutput).Return(false);
- var inquiryHelper = mocks.StrictMock();
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
+ calculationMock.Expect(c => c.HasOutput).Return(false);
+ var inquiryHelperMock = mocks.StrictMock();
mocks.ReplayAll();
ICalculation actionCalculation = null;
StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForshoreProfileOfCalculationItem(
- calculation,
- inquiryHelper,
+ calculationMock,
+ inquiryHelperMock,
c => { actionCalculation = c; });
// Call
toolStripItem.PerformClick();
// Assert
- Assert.AreSame(calculation, actionCalculation);
+ Assert.AreSame(calculationMock, actionCalculation);
mocks.VerifyAll();
}
@@ -679,17 +679,17 @@
"Weet u zeker dat u wilt doorgaan?";
var mocks = new MockRepository();
- var calculation = mocks.StrictMock>();
- calculation.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
- calculation.Expect(c => c.HasOutput).Return(true);
- var inquiryHelper = mocks.StrictMock();
- inquiryHelper.Expect(i => i.InquireContinuation(inquireContinuationMessage)).Return(false);
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
+ calculationMock.Expect(c => c.HasOutput).Return(true);
+ var inquiryHelperMock = mocks.StrictMock();
+ inquiryHelperMock.Expect(i => i.InquireContinuation(inquireContinuationMessage)).Return(false);
mocks.ReplayAll();
var actionPerformed = false;
StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForshoreProfileOfCalculationItem(
- calculation,
- inquiryHelper,
+ calculationMock,
+ inquiryHelperMock,
c => { actionPerformed = true; });
// Call
@@ -710,17 +710,17 @@
"Weet u zeker dat u wilt doorgaan?";
var mocks = new MockRepository();
- var calculation = mocks.StrictMock>();
- calculation.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
- calculation.Expect(c => c.HasOutput).Return(true);
- var inquiryHelper = mocks.StrictMock();
- inquiryHelper.Expect(i => i.InquireContinuation(inquireContinuationMessage)).Return(true);
+ var calculationMock = mocks.StrictMock>();
+ calculationMock.Expect(c => c.InputParameters.ForeshoreProfile).Return(new TestForeshoreProfile());
+ calculationMock.Expect(c => c.HasOutput).Return(true);
+ var inquiryHelperMock = mocks.StrictMock();
+ inquiryHelperMock.Expect(i => i.InquireContinuation(inquireContinuationMessage)).Return(true);
mocks.ReplayAll();
var actionPerformed = false;
StrictContextMenuItem toolStripItem = RingtoetsContextMenuItemFactory.CreateUpdateForshoreProfileOfCalculationItem(
- calculation,
- inquiryHelper,
+ calculationMock,
+ inquiryHelperMock,
c => { actionPerformed = true; });
// Call