Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r8a482f64da54bd72583411ba20668c58b2ae0184 -r2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c) @@ -611,37 +611,31 @@ private StrictContextMenuItem CreateUpdateDikeProfileItem(GrassCoverErosionInwardsCalculationGroupContext nodeData) { - IEnumerable calculations = nodeData.WrappedData - .GetCalculations() - .OfType(); + var contextMenuEnabled = true; + string toolTipMessage = Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_all_calculations_with_DikeProfile_Tooltip; + IList calculationsToUpdate = nodeData.WrappedData.GetCalculations() + .OfType() + .Where(c => c.InputParameters.DikeProfile != null && !c.InputParameters.IsDikeProfileInputSynchronized) + .ToList(); - var isContextMenuItemEnabled = true; - string toolTipText = - Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_all_calculations_with_DikeProfile_Tooltip; - if (!calculations.Any()) + if (!calculationsToUpdate.Any()) { - toolTipText = RingtoetsCommonFormsResources.CreateUpdateContextMenuItem_No_calculations_to_update_ToolTip; - isContextMenuItemEnabled = false; + contextMenuEnabled = false; + toolTipMessage = RingtoetsCommonFormsResources.CreateUpdateContextMenuItem_No_calculations_to_update_ToolTip; } - else if (calculations.All(calc => calc.InputParameters.DikeProfile == null)) - { - toolTipText = Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_No_calculations_with_DikeProfile_ToolTip; - isContextMenuItemEnabled = false; - } return new StrictContextMenuItem(Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_all_DikeProfiles, - toolTipText, + toolTipMessage, RingtoetsCommonFormsResources.UpdateItemIcon, - (o, args) => UpdateDikeProfileDependentDataOfAllCalculations(calculations)) + (o, args) => UpdateDikeProfileDependentDataOfAllCalculations(calculationsToUpdate)) { - Enabled = isContextMenuItemEnabled + Enabled = contextMenuEnabled }; } - private void UpdateDikeProfileDependentDataOfAllCalculations(IEnumerable calculations) + private void UpdateDikeProfileDependentDataOfAllCalculations(IList calculations) { - string message = - Resources.GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_Confirm_calculation_outputs_cleared_when_updating_DikeProfile_dependent_data; + string message = RingtoetsCommonFormsResources.VerifyUpdate_Confirm_calculation_outputs_cleared; if (DikeProfileDependentDataShouldUpdate(calculations, message)) { foreach (GrassCoverErosionInwardsCalculation calculation in calculations) Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r8a482f64da54bd72583411ba20668c58b2ae0184 -r2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c) @@ -101,18 +101,8 @@ } /// - /// Looks up a localized string similar to Er zijn geen berekeningen met een dijkprofiel.. + /// Looks up a localized string similar to Alle berekeningen met een dijkprofiel bijwerken.. /// - internal static string GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_No_calculations_with_DikeProfile_ToolTip { - get { - return ResourceManager.GetString("GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_No_calculations_with_D" + - "ikeProfile_ToolTip", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Alle berekeningen bijwerken met het dijkprofiel.. - /// internal static string GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_all_calculations_with_DikeProfile_Tooltip { get { return ResourceManager.GetString("GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_all_calculation" + @@ -173,18 +163,6 @@ } /// - /// Looks up a localized string similar to Wanneer de dijkprofielen wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze dijkprofielen gebruiken, worden verwijderd. - /// - ///Weet u zeker dat u wilt doorgaan?. - /// - internal static string GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_Confirm_calculation_outputs_cleared_when_updating_DikeProfile_dependent_data { - get { - return ResourceManager.GetString("GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_Confirm_calculation_output" + - "s_cleared_when_updating_DikeProfile_dependent_data", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Als dijkprofielen wijzigen door het bijwerken, dan worden de resultaten van berekeningen die deze dijkprofielen gebruiken verwijderd. /// ///Weet u zeker dat u wilt doorgaan?. Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.resx =================================================================== diff -u -r8a482f64da54bd72583411ba20668c58b2ae0184 -r2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c) @@ -143,17 +143,9 @@ Er moet een dijkprofiel geselecteerd zijn. - Alle berekeningen bijwerken met het dijkprofiel. + Alle berekeningen met een dijkprofiel bijwerken. - - Er zijn geen berekeningen met een dijkprofiel. - &Bijwerken dijkprofielen... - - Wanneer de dijkprofielen wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze dijkprofielen gebruiken, worden verwijderd. - -Weet u zeker dat u wilt doorgaan? - \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r8a482f64da54bd72583411ba20668c58b2ae0184 -r2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c) @@ -25,7 +25,6 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Controls.DataGrid; using Core.Common.Controls.TreeView; @@ -485,9 +484,40 @@ } [Test] - public void ContextMenuStrip_FailureMechanismWithCalculationsWithoutDikeProfile_ContextMenuItemUpdateDikeProfileAllDisabledAndToolTipSet() + public void ContextMenuStrip_CalculationGroupWithoutCalculations_ContextMenuItemUpdateDikeProfilesDisabledAndToolTipSet() { // Setup + var group = new CalculationGroup(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var assessmentSection = mocks.Stub(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuUpdateDikeProfileAllIndexRootGroup, + "&Bijwerken dijkprofielen...", + "Er zijn geen berekeningen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_CalculationGroupWithCalculationWithoutDikeProfile_ContextMenuItemUpdateDikeProfilesDisabledAndToolTipSet() + { + // Setup var group = new CalculationGroup { Children = @@ -515,15 +545,15 @@ // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuUpdateDikeProfileAllIndexRootGroup, "&Bijwerken dijkprofielen...", - "Er zijn geen berekeningen met een dijkprofiel.", + "Er zijn geen berekeningen om bij te werken.", RingtoetsCommonFormsResources.UpdateItemIcon, false); } } } [Test] - public void ContextMenuStrip_FailureMechanismWithCalculationWithDikeProfile_ContextMenuItemUpdateDikeProfileAllEnabledAndToolTipSet() + public void ContextMenuStrip_CalculationGroupWithCalculationWithDikeProfileAndInputInSync_ContextMenuItemUpdateDikeProfilesDisabledAndToolTipSet() { // Setup var group = new CalculationGroup @@ -559,14 +589,61 @@ // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuUpdateDikeProfileAllIndexRootGroup, "&Bijwerken dijkprofielen...", - "Alle berekeningen bijwerken met het dijkprofiel.", + "Er zijn geen berekeningen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_CalculationGroupWithCalculationWithDikeProfileAndInputOutOfSync_ContextMenuItemUpdateDikeProfilesEnabledAndToolTipSet() + { + // Setup + var testDikeProfile = new TestDikeProfile(); + var group = new CalculationGroup + { + Children = + { + new GrassCoverErosionInwardsCalculation + { + InputParameters = + { + DikeProfile = testDikeProfile + } + } + } + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var assessmentSection = mocks.Stub(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + mocks.ReplayAll(); + + plugin.Gui = gui; + + ChangeDikeProfile(testDikeProfile); + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuUpdateDikeProfileAllIndexRootGroup, + "&Bijwerken dijkprofielen...", + "Alle berekeningen met een dijkprofiel bijwerken.", RingtoetsCommonFormsResources.UpdateItemIcon); } } } [Test] - public void GivenCalculationsWithDikeProfileWithoutOutput_WhenDikeProfileUpdatedAndUpdateClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateDikeProfilesClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given var calculation1InputObserver = mocks.StrictMock(); @@ -622,40 +699,26 @@ plugin.Gui = gui; + ChangeDikeProfile(dikeProfile); + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then Assert.IsFalse(calculation1.HasOutput); - GrassCoverErosionInwardsInput inputParameters1 = calculation1.InputParameters; - Assert.AreSame(dikeProfile, inputParameters1.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters1.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters1.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters1.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters1.BreakWater); - bool expectedUseForeshore1 = dikeProfile.ForeshoreGeometry.Count() > 1; - Assert.AreEqual(expectedUseForeshore1, inputParameters1.UseForeshore); - + Assert.IsTrue(calculation1.InputParameters.IsDikeProfileInputSynchronized); Assert.IsFalse(calculation2.HasOutput); - GrassCoverErosionInwardsInput inputParameters2 = calculation2.InputParameters; - Assert.AreSame(dikeProfile, inputParameters2.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters2.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters2.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters2.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters2.BreakWater); - bool expectedUseForeshore2 = dikeProfile.ForeshoreGeometry.Count() > 1; - Assert.AreEqual(expectedUseForeshore2, inputParameters2.UseForeshore); + Assert.IsTrue(calculation2.InputParameters.IsDikeProfileInputSynchronized); // Note: observer assertions are verified in the TearDown() } } } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenProfileHasChangesAndUpdateCancelled_ThenInquiresAndCalculationsNotUpdatedAndObserversNotNotified() + public void GivenCalculationWithOutputAndInputInSync_WhenUpdateDikeProfilesClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given var calculation1InputObserver = mocks.StrictMock(); @@ -675,12 +738,6 @@ }; calculation1.Attach(calculation1Observer); calculation1.InputParameters.Attach(calculation1InputObserver); - GrassCoverErosionInwardsInput calculationInput1 = calculation1.InputParameters; - RoundedDouble expectedOrientation1 = calculationInput1.Orientation; - RoundedDouble expectedDikeHeight1 = calculationInput1.DikeHeight; - bool expectedUseBreakWater1 = calculationInput1.UseBreakWater; - BreakWater expectedBreakWater1 = calculationInput1.BreakWater; - bool expectedUseForeshore1 = calculationInput1.UseForeshore; var calculation2 = new GrassCoverErosionInwardsCalculation { @@ -692,12 +749,6 @@ }; calculation2.Attach(calculation2Observer); calculation2.InputParameters.Attach(calculation2InputObserver); - GrassCoverErosionInwardsInput calculationInput2 = calculation2.InputParameters; - RoundedDouble expectedOrientation2 = calculationInput2.Orientation; - RoundedDouble expectedDikeHeight2 = calculationInput2.DikeHeight; - bool expectedUseBreakWater2 = calculationInput2.UseBreakWater; - BreakWater expectedBreakWater2 = calculationInput2.BreakWater; - bool expectedUseForeshore2 = calculationInput2.UseForeshore; var childGroup = new CalculationGroup(); childGroup.Children.Add(calculation1); @@ -714,14 +765,6 @@ failureMechanism, assessmentSection); - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickCancel(); - }; - using (var treeViewControl = new TreeViewControl()) { var mainWindow = mocks.Stub(); @@ -734,51 +777,28 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then Assert.IsTrue(calculation1.HasOutput); - GrassCoverErosionInwardsInput inputParameters1 = calculation1.InputParameters; - Assert.AreSame(dikeProfile, inputParameters1.DikeProfile); - Assert.AreEqual(expectedOrientation1, inputParameters1.Orientation); - Assert.AreEqual(expectedDikeHeight1, inputParameters1.DikeHeight); - Assert.AreEqual(expectedUseBreakWater1, inputParameters1.UseBreakWater); - Assert.AreEqual(expectedBreakWater1, inputParameters1.BreakWater); - Assert.AreEqual(expectedUseForeshore1, inputParameters1.UseForeshore); - + Assert.IsTrue(calculation1.InputParameters.IsDikeProfileInputSynchronized); Assert.IsTrue(calculation2.HasOutput); - GrassCoverErosionInwardsInput inputParameters2 = calculation2.InputParameters; - Assert.AreSame(dikeProfile, inputParameters2.DikeProfile); - Assert.AreEqual(expectedOrientation2, inputParameters2.Orientation); - Assert.AreEqual(expectedDikeHeight2, inputParameters2.DikeHeight); - Assert.AreEqual(expectedUseBreakWater2, inputParameters2.UseBreakWater); - Assert.AreEqual(expectedBreakWater2, inputParameters2.BreakWater); - Assert.AreEqual(expectedUseForeshore2, inputParameters2.UseForeshore); + Assert.IsTrue(calculation2.InputParameters.IsDikeProfileInputSynchronized); - string expectedMessage = "Wanneer de dijkprofielen wijzigen als gevolg van het bijwerken, " + - "zullen de resultaten van berekeningen die deze dijkprofielen gebruiken, worden " + - $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; - Assert.AreEqual(expectedMessage, textBoxMessage); - // Note: observer assertions are verified in the TearDown() } } } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenProfileHasChangesAndUpdateContinued_ThenInquiresAndCalculationsUpdatedAndObserversNotified() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateDikeProfilesClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given var calculation1InputObserver = mocks.StrictMock(); - calculation1InputObserver.Expect(obs => obs.UpdateObserver()); var calculation2InputObserver = mocks.StrictMock(); - calculation2InputObserver.Expect(obs => obs.UpdateObserver()); var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(obs => obs.UpdateObserver()); var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(obs => obs.UpdateObserver()); var dikeProfile = new TestDikeProfile(); var calculation1 = new GrassCoverErosionInwardsCalculation @@ -817,12 +837,13 @@ var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, failureMechanism, assessmentSection); + string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { var helper = new MessageBoxTester(wnd); textBoxMessage = helper.Text; - helper.ClickOk(); + helper.ClickCancel(); }; using (var treeViewControl = new TreeViewControl()) @@ -834,35 +855,20 @@ plugin.Gui = gui; + ChangeDikeProfile(dikeProfile); + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then - Assert.IsFalse(calculation1.HasOutput); - GrassCoverErosionInwardsInput inputParameters1 = calculation1.InputParameters; - Assert.AreSame(dikeProfile, inputParameters1.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters1.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters1.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters1.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters1.BreakWater); - bool expectedUseForeshore1 = dikeProfile.ForeshoreGeometry.Count() > 1; - Assert.AreEqual(expectedUseForeshore1, inputParameters1.UseForeshore); + Assert.IsTrue(calculation1.HasOutput); + Assert.IsFalse(calculation1.InputParameters.IsDikeProfileInputSynchronized); + Assert.IsTrue(calculation2.HasOutput); + Assert.IsFalse(calculation2.InputParameters.IsDikeProfileInputSynchronized); - Assert.IsFalse(calculation2.HasOutput); - GrassCoverErosionInwardsInput inputParameters2 = calculation2.InputParameters; - Assert.AreSame(dikeProfile, inputParameters2.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters2.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters2.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters2.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters2.BreakWater); - bool expectedUseForeshore2 = dikeProfile.ForeshoreGeometry.Count() > 1; - Assert.AreEqual(expectedUseForeshore2, inputParameters2.UseForeshore); - - string expectedMessage = "Wanneer de dijkprofielen wijzigen als gevolg van het bijwerken, " + - "zullen de resultaten van berekeningen die deze dijkprofielen gebruiken, worden " + + string expectedMessage = "Als u kiest voor bijwerken, dan wordt het resultaat van alle bij te werken berekeningen " + $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedMessage, textBoxMessage); @@ -872,7 +878,7 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasPartialChangesAndUpdateDikeProfileClicked_ThenInquiresAndCalculationsUpdatedAndObserversNotified() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateDikeProfilesClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() { // Given var calculation1InputObserver = mocks.StrictMock(); @@ -886,17 +892,11 @@ calculation2Observer.Expect(obs => obs.UpdateObserver()); var dikeProfile = new TestDikeProfile(); - const double orientation = 10; - const bool useForeshore = true; var calculation1 = new GrassCoverErosionInwardsCalculation { InputParameters = { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) 30, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = false + DikeProfile = dikeProfile }, Output = new TestGrassCoverErosionInwardsOutput() }; @@ -907,11 +907,7 @@ { InputParameters = { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) 30, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = false + DikeProfile = dikeProfile }, Output = new TestGrassCoverErosionInwardsOutput() }; @@ -923,8 +919,6 @@ var emptyChildGroup = new CalculationGroup(); var group = new CalculationGroup(); - var parentGroup = new CalculationGroup(); - group.Children.Add(childGroup); group.Children.Add(emptyChildGroup); group.Children.Add(calculation2); @@ -934,10 +928,6 @@ var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, failureMechanism, assessmentSection); - var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, - failureMechanism, - assessmentSection); - string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { @@ -951,40 +941,24 @@ var mainWindow = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); - gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); mocks.ReplayAll(); plugin.Gui = gui; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) + ChangeDikeProfile(dikeProfile); + + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - ChangeDikeProfile(dikeProfile); - menu.Items[contextMenuUpdateDikeProfileAllIndexNestedGroup].PerformClick(); + menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then Assert.IsFalse(calculation1.HasOutput); - GrassCoverErosionInwardsInput inputParameters1 = calculation1.InputParameters; - Assert.AreSame(dikeProfile, inputParameters1.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters1.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters1.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters1.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters1.BreakWater); - bool expectedUseForeshore1 = dikeProfile.ForeshoreGeometry.Count() > 1; - Assert.AreEqual(expectedUseForeshore1, inputParameters1.UseForeshore); - + Assert.IsTrue(calculation1.InputParameters.IsDikeProfileInputSynchronized); Assert.IsFalse(calculation2.HasOutput); - GrassCoverErosionInwardsInput inputParameters2 = calculation2.InputParameters; - Assert.AreSame(dikeProfile, inputParameters2.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters2.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters2.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters2.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters2.BreakWater); - bool expectedUseForeshore2 = dikeProfile.ForeshoreGeometry.Count() > 1; - Assert.AreEqual(expectedUseForeshore2, inputParameters2.UseForeshore); + Assert.IsTrue(calculation2.InputParameters.IsDikeProfileInputSynchronized); - string expectedMessage = "Wanneer de dijkprofielen wijzigen als gevolg van het bijwerken, " + - "zullen de resultaten van berekeningen die deze dijkprofielen gebruiken, worden " + + string expectedMessage = "Als u kiest voor bijwerken, dan wordt het resultaat van alle bij te werken berekeningen " + $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedMessage, textBoxMessage); @@ -1958,22 +1932,20 @@ private static void ChangeDikeProfile(DikeProfile dikeProfile) { - var dikeProfileToUpdateFrom = new DikeProfile(dikeProfile.WorldReferencePoint, - dikeProfile.DikeGeometry, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = dikeProfile.Id, - DikeHeight = 10, - Orientation = 10 - }); - - dikeProfile.CopyProperties(dikeProfileToUpdateFrom); + dikeProfile.CopyProperties(new DikeProfile(dikeProfile.WorldReferencePoint, + dikeProfile.DikeGeometry, + new[] + { + new Point2D(1.1, 2.2), + new Point2D(3.3, 4.4) + }, + new BreakWater(BreakWaterType.Caisson, 10), + new DikeProfile.ConstructionProperties + { + Id = dikeProfile.Id, + DikeHeight = 10, + Orientation = 10 + })); } public override void TearDown() Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r3f9fb75bb98fcc5a336f6df2870b611c41239b89 -r2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 3f9fb75bb98fcc5a336f6df2870b611c41239b89) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 2c7c991c5f2f2ef73d6683daad93d07ddb73ad6c) @@ -829,21 +829,18 @@ private static void UpdateSurfaceLineDependentData(PipingCalculation scenario) { - if (!scenario.InputParameters.IsEntryAndExitPointInputSynchronized) + scenario.InputParameters.SynchronizeEntryAndExitPointInput(); + + var affectedObjects = new List { - scenario.InputParameters.SynchronizeEntryAndExitPointInput(); + scenario.InputParameters + }; - var affectedObjects = new List - { - scenario.InputParameters - }; + affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(scenario)); - affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(scenario)); - - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } + foreach (IObservable affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); } }