Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r6c7fbd4def41c722f172d3e11329a9635d2f7ba1 -r8a482f64da54bd72583411ba20668c58b2ae0184 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 6c7fbd4def41c722f172d3e11329a9635d2f7ba1) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) @@ -25,7 +25,6 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Controls.TreeView; using Core.Common.Gui; using Core.Common.Gui.ContextMenu; @@ -358,7 +357,7 @@ #endregion - #region GrassCoverErosionInwardsInputView ViewInfo + #region GrassCoverErosionInwardsInputView ViewInfo private static bool CloseInputViewForData(GrassCoverErosionInwardsInputView view, object o) { @@ -831,27 +830,32 @@ private StrictContextMenuItem CreateUpdateDikeProfileItem(GrassCoverErosionInwardsCalculationContext context) { - GrassCoverErosionInwardsInput inputParameters = context.WrappedData.InputParameters; - bool hasDikeProfile = inputParameters.DikeProfile != null; + var contextMenuEnabled = true; + string toolTipMessage = Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_calculation_with_DikeProfile_ToolTip; + if (context.WrappedData.InputParameters.DikeProfile == null) + { + contextMenuEnabled = false; + toolTipMessage = Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_calculation_no_DikeProfile_ToolTip; + } + else if (context.WrappedData.InputParameters.IsDikeProfileInputSynchronized) + { + contextMenuEnabled = false; + toolTipMessage = RingtoetsCommonFormsResources.CalculationItem_No_changes_to_update_ToolTip; + } - string toolTipMessage = hasDikeProfile - ? Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_calculation_with_DikeProfile_ToolTip - : Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_calculation_no_DikeProfile_ToolTip; - return new StrictContextMenuItem( Resources.GrassCoverErosionInwardsPlugin_CreateUpdateDikeProfileItem_Update_DikeProfile_data, toolTipMessage, RingtoetsCommonFormsResources.UpdateItemIcon, (o, args) => UpdateDikeProfileDependentDataOfCalculation(context.WrappedData)) { - Enabled = hasDikeProfile + Enabled = contextMenuEnabled }; } private void UpdateDikeProfileDependentDataOfCalculation(GrassCoverErosionInwardsCalculation calculation) { - string message = - Resources.GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_Confirm_calculation_output_cleared_when_updating_DikeProfile_dependent_data; + string message = RingtoetsCommonFormsResources.VerifyUpdate_Confirm_calculation_output_cleared; if (DikeProfileDependentDataShouldUpdate(new[] { calculation @@ -872,21 +876,18 @@ private static void UpdateDikeProfileDerivedCalculationInput(GrassCoverErosionInwardsCalculation calculation) { - if (!calculation.InputParameters.IsDikeProfileInputSynchronized) + calculation.InputParameters.SynchronizeDikeProfileInput(); + + var affectedObjects = new List { - calculation.InputParameters.SynchronizeDikeProfileInput(); + calculation.InputParameters + }; - var affectedObjects = new List - { - calculation.InputParameters - }; + affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculation)); - affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculation)); - - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } + foreach (IObservable affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -rf8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3 -r8a482f64da54bd72583411ba20668c58b2ae0184 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) @@ -173,18 +173,6 @@ } /// - /// Looks up a localized string similar to Wanneer het dijkprofiel wijzigt als gevolg van het bijwerken, zal het resultaat van deze berekening worden verwijderd. - /// - ///Weet u zeker dat u wilt doorgaan?. - /// - internal static string GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_Confirm_calculation_output_cleared_when_updating_DikeProfile_dependent_data { - get { - return ResourceManager.GetString("GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_Confirm_calculation_output" + - "_cleared_when_updating_DikeProfile_dependent_data", resourceCulture); - } - } - - /// /// 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?. Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.resx =================================================================== diff -u -rf8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3 -r8a482f64da54bd72583411ba20668c58b2ae0184 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.resx (.../Resources.resx) (revision f8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) @@ -142,11 +142,6 @@ Er moet een dijkprofiel geselecteerd zijn. - - Wanneer het dijkprofiel wijzigt als gevolg van het bijwerken, zal het resultaat van deze berekening worden verwijderd. - -Weet u zeker dat u wilt doorgaan? - Alle berekeningen bijwerken met het dijkprofiel. Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -rf8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3 -r8a482f64da54bd72583411ba20668c58b2ae0184 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision f8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) @@ -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.TreeView; using Core.Common.Gui; @@ -276,7 +275,7 @@ } [Test] - public void ContextMenuStrip_CalculationWithoutDikeProfile_ContextMenuItemUpdateDikeProfileDisabled() + public void ContextMenuStrip_CalculationWithoutDikeProfile_ContextMenuItemUpdateDikeProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); @@ -309,7 +308,7 @@ } [Test] - public void ContextMenuStrip_CalculationWithDikeProfile_ContextMenuItemUpdateDikeProfileEnabled() + public void ContextMenuStrip_CalculationWithDikeProfileAndInputInSync_ContextMenuItemUpdateDikeProfileDisabledAndToolTipSet() { // Setup var assessmentSection = mocks.Stub(); @@ -340,62 +339,56 @@ TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuUpdateDikeProfileIndex, "&Bijwerken dijkprofiel...", - "Berekening bijwerken met het dijkprofiel.", - RingtoetsCommonFormsResources.UpdateItemIcon); + "Er zijn geen wijzigingen om bij te werken.", + RingtoetsCommonFormsResources.UpdateItemIcon, + false); } } } [Test] - public void GivenCalculationWithDikeProfileWithoutOutput_WhenDikeProfileAndInputOutOfSyncAndUpdateClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + public void ContextMenuStrip_CalculationWithDikeProfileAndInputOutOfSync_ContextMenuItemUpdateDikeProfileEnabledAndToolTipSet() { - // Given + // Setup var assessmentSection = mocks.Stub(); - var dikeProfile = new TestDikeProfile(); + + var testDikeProfile = new TestDikeProfile(); var calculation = new GrassCoverErosionInwardsCalculation { InputParameters = { - DikeProfile = dikeProfile + DikeProfile = testDikeProfile } }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); - var inputObserver = mocks.StrictMock(); - inputObserver.Expect(obs => obs.UpdateObserver()); - calculation.InputParameters.Attach(inputObserver); - - var calculationObserver = mocks.StrictMock(); - calculation.Attach(calculationObserver); - using (var treeViewControl = new TreeViewControl()) { - var mainWindow = mocks.Stub(); var gui = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); - gui.Stub(g => g.MainWindow).Return(mainWindow); + gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); plugin.Gui = gui; + ChangeDikeProfile(testDikeProfile); + + // Call using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { - // When - UpdateDikeProfile(dikeProfile); - menu.Items[contextMenuUpdateDikeProfileIndex].PerformClick(); - - // Then - Assert.IsFalse(calculation.HasOutput); - AssertGrassCoverErosionInwardsInput(dikeProfile, calculation.InputParameters); - - // Note: observer assertions are verified in the TearDown() + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, + contextMenuUpdateDikeProfileIndex, + "&Bijwerken dijkprofiel...", + "Berekening bijwerken met het dijkprofiel.", + RingtoetsCommonFormsResources.UpdateItemIcon); } } } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileAndInputOutOfSyncAndUpdateClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + public void GivenCalculationWithoutOutputAndWithInputOutOfSync_WhenUpdateDikeProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { // Given var assessmentSection = mocks.Stub(); @@ -405,34 +398,18 @@ InputParameters = { DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() + } }; - - GrassCoverErosionInwardsInput calculationInput = calculation.InputParameters; - RoundedDouble expectedOrientation = calculationInput.Orientation; - RoundedDouble expectedDikeHeight = calculationInput.DikeHeight; - bool expectedUseBreakWater = calculationInput.UseBreakWater; - BreakWater expectedBreakWater = calculationInput.BreakWater; - bool expectedUseForeshore = calculationInput.UseForeshore; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); var inputObserver = mocks.StrictMock(); - calculationInput.Attach(inputObserver); + inputObserver.Expect(obs => obs.UpdateObserver()); + calculation.InputParameters.Attach(inputObserver); var calculationObserver = mocks.StrictMock(); calculation.Attach(calculationObserver); - 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(); @@ -442,38 +419,28 @@ mocks.ReplayAll(); plugin.Gui = gui; + + ChangeDikeProfile(dikeProfile); + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileIndex].PerformClick(); // Then - Assert.IsTrue(calculation.HasOutput); + Assert.IsFalse(calculation.HasOutput); + Assert.IsTrue(calculation.InputParameters.IsDikeProfileInputSynchronized); - Assert.AreSame(dikeProfile, calculationInput.DikeProfile); - Assert.AreEqual(expectedOrientation, calculationInput.Orientation); - Assert.AreEqual(expectedDikeHeight, calculationInput.DikeHeight); - Assert.AreEqual(expectedUseBreakWater, calculationInput.UseBreakWater); - Assert.AreEqual(expectedBreakWater, calculationInput.BreakWater); - Assert.AreEqual(expectedUseForeshore, calculationInput.UseForeshore); - - string expectedMessage = "Wanneer het dijkprofiel wijzigt als gevolg van het bijwerken, " + - "zal het resultaat van deze berekening 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_WhenDikeProfileAndInputOutOfSyncAndUpdateClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() + public void GivenCalculationWithOutputAndInputInSync_WhenUpdateDikeProfileClicked_ThenNoInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given var assessmentSection = mocks.Stub(); - var dikeProfile = new TestDikeProfile(); var calculation = new GrassCoverErosionInwardsCalculation { @@ -483,25 +450,16 @@ }, Output = new TestGrassCoverErosionInwardsOutput() }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); var inputObserver = mocks.StrictMock(); - inputObserver.Expect(obs => obs.UpdateObserver()); calculation.InputParameters.Attach(inputObserver); var calculationObserver = mocks.StrictMock(); - calculationObserver.Expect(obs => obs.UpdateObserver()); calculation.Attach(calculationObserver); - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (var treeViewControl = new TreeViewControl()) { var mainWindow = mocks.Stub(); @@ -515,77 +473,47 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileIndex].PerformClick(); // Then - Assert.IsFalse(calculation.HasOutput); - AssertGrassCoverErosionInwardsInput(dikeProfile, calculation.InputParameters); + Assert.IsTrue(calculation.HasOutput); + Assert.IsTrue(calculation.InputParameters.IsDikeProfileInputSynchronized); - string expectedMessage = "Wanneer het dijkprofiel wijzigt als gevolg van het bijwerken, " + - "zal het resultaat van deze berekening 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_WhenDikeProfileAndInputInSyncAndUpdateClickedAndContinued_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateDikeProfileClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { // Given var assessmentSection = mocks.Stub(); - - var dikeProfile = new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 3), - new RoughnessPoint(new Point2D(3.3, 4.4), 5) - }, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = "ID" - }); - const double orientation = 10; - const double dikeHeight = 10; - const bool useBreakWater = true; - const bool useForeshore = true; + var dikeProfile = new TestDikeProfile(); var calculation = new GrassCoverErosionInwardsCalculation { InputParameters = { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) dikeHeight, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = useBreakWater + DikeProfile = dikeProfile }, Output = new TestGrassCoverErosionInwardsOutput() }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + var inputObserver = mocks.StrictMock(); calculation.InputParameters.Attach(inputObserver); var calculationObserver = mocks.StrictMock(); calculation.Attach(calculationObserver); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, 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()) @@ -598,18 +526,18 @@ plugin.Gui = gui; + ChangeDikeProfile(dikeProfile); + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileIndex].PerformClick(); // Then Assert.IsTrue(calculation.HasOutput); - AssertGrassCoverErosionInwardsInput(dikeProfile, calculation.InputParameters); + Assert.IsFalse(calculation.InputParameters.IsDikeProfileInputSynchronized); - string expectedMessage = "Wanneer het dijkprofiel wijzigt als gevolg van het bijwerken, " + - "zal het resultaat van deze berekening worden " + + string expectedMessage = "Als u kiest voor bijwerken, dan wordt het resultaat van deze berekening " + $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedMessage, textBoxMessage); @@ -619,14 +547,12 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileAndInputPartiallyOutOfSyncAndUpdateClicked_ThenInquiryAndUpdatesCalculationAndNotifiesObserver() + public void GivenCalculationWithOutputAndInputOutOfSync_WhenUpdateDikeProfileClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() { // Given var assessmentSection = mocks.Stub(); var dikeProfile = new TestDikeProfile(); - UpdateDikeProfile(dikeProfile); - var calculation = new GrassCoverErosionInwardsCalculation { InputParameters = @@ -635,6 +561,8 @@ }, Output = new TestGrassCoverErosionInwardsOutput() }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); var inputObserver = mocks.StrictMock(); inputObserver.Expect(obs => obs.UpdateObserver()); @@ -644,9 +572,6 @@ calculationObserver.Expect(obs => obs.UpdateObserver()); calculation.Attach(calculationObserver); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); - string textBoxMessage = null; DialogBoxHandler = (name, wnd) => { @@ -665,19 +590,18 @@ plugin.Gui = gui; + ChangeDikeProfile(dikeProfile); + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When - GrassCoverErosionInwardsInput inputParameters = calculation.InputParameters; - inputParameters.Orientation = (RoundedDouble) 11.0; menu.Items[contextMenuUpdateDikeProfileIndex].PerformClick(); // Then Assert.IsFalse(calculation.HasOutput); - AssertGrassCoverErosionInwardsInput(dikeProfile, calculation.InputParameters); + Assert.IsTrue(calculation.InputParameters.IsDikeProfileInputSynchronized); - string expectedMessage = "Wanneer het dijkprofiel wijzigt als gevolg van het bijwerken, " + - "zal het resultaat van deze berekening worden " + + string expectedMessage = "Als u kiest voor bijwerken, dan wordt het resultaat van deze berekening " + $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?"; Assert.AreEqual(expectedMessage, textBoxMessage); @@ -1032,12 +956,12 @@ { string[] msgs = messages.ToArray(); Assert.AreEqual(6, msgs.Length); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' gestart om: ", msgs[0]); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' beëindigd om: ", msgs[1]); + StringAssert.StartsWith($"Berekening van '{calculation.Name}' gestart om: ", msgs[2]); StringAssert.StartsWith("De overloop en overslag berekening is uitgevoerd op de tijdelijke locatie", msgs[3]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[4]); - StringAssert.StartsWith(string.Format("Uitvoeren van '{0}' is gelukt.", calculation.Name), msgs[5]); + StringAssert.StartsWith($"Berekening van '{calculation.Name}' beëindigd om: ", msgs[4]); + StringAssert.StartsWith($"Uitvoeren van '{calculation.Name}' is gelukt.", msgs[5]); }); Assert.AreNotSame(initialOutput, calculation.Output); @@ -1098,8 +1022,8 @@ TestHelper.AssertLogMessages(action, messages => { string[] msgs = messages.ToArray(); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' gestart om: ", msgs[0]); + StringAssert.StartsWith($"Validatie van '{calculation.Name}' beëindigd om: ", msgs[1]); }); } } @@ -1230,36 +1154,24 @@ Assert.IsNull(result.Calculation); } - private static void UpdateDikeProfile(DikeProfile dikeProfile) + 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 + })); } - private static void AssertGrassCoverErosionInwardsInput(DikeProfile dikeProfile, GrassCoverErosionInwardsInput inputParameters) - { - Assert.AreSame(dikeProfile, inputParameters.DikeProfile); - Assert.AreEqual(dikeProfile.Orientation, inputParameters.Orientation); - Assert.AreEqual(dikeProfile.DikeHeight, inputParameters.DikeHeight); - Assert.AreEqual(dikeProfile.HasBreakWater, inputParameters.UseBreakWater); - Assert.AreEqual(dikeProfile.BreakWater, inputParameters.BreakWater); - Assert.AreEqual(dikeProfile.ForeshoreGeometry.Count() > 1, inputParameters.UseForeshore); - } - public override void TearDown() { plugin.Dispose(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rf8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3 -r8a482f64da54bd72583411ba20668c58b2ae0184 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision f8732f8bbec8b197d9bc91e91d27e0c9d20b4ed3) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 8a482f64da54bd72583411ba20668c58b2ae0184) @@ -625,7 +625,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); + ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then @@ -734,7 +734,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); + ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then @@ -837,7 +837,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); + ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexRootGroup].PerformClick(); // Then @@ -872,141 +872,6 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasNoChangeAndUpdateClicked_ThenInquiresAndCalculationsNotUpdatedAndObserversNotNotified() - { - // Given - var calculation1InputObserver = mocks.StrictMock(); - var calculation2InputObserver = mocks.StrictMock(); - - var calculation1Observer = mocks.StrictMock(); - var calculation2Observer = mocks.StrictMock(); - - var dikeProfile = new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 3), - new RoughnessPoint(new Point2D(3.3, 4.4), 5) - }, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = "ID" - }); - const double orientation = 10; - const double dikeHeight = 10; - const bool useBreakWater = true; - const bool useForeshore = true; - var calculation1 = new GrassCoverErosionInwardsCalculation - { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) dikeHeight, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = useBreakWater - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); - - var calculation2 = new GrassCoverErosionInwardsCalculation - { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) dikeHeight, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = useBreakWater - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); - - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); - - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - var parentGroup = new CalculationGroup(); - - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); - - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); - var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, - failureMechanism, - assessmentSection); - - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - - using (var treeViewControl = new TreeViewControl()) - { - 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)) - { - // When - UpdateDikeProfile(dikeProfile); - menu.Items[contextMenuUpdateDikeProfileAllIndexNestedGroup].PerformClick(); - - // Then - Assert.IsTrue(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(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 " + - $"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_WhenDikeProfileHasPartialChangesAndUpdateDikeProfileClicked_ThenInquiresAndCalculationsUpdatedAndObserversNotified() { // Given @@ -1094,7 +959,7 @@ using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // When - UpdateDikeProfile(dikeProfile); + ChangeDikeProfile(dikeProfile); menu.Items[contextMenuUpdateDikeProfileAllIndexNestedGroup].PerformClick(); // Then @@ -2091,7 +1956,7 @@ Assert.IsNull(result.Calculation); } - private static void UpdateDikeProfile(DikeProfile dikeProfile) + private static void ChangeDikeProfile(DikeProfile dikeProfile) { var dikeProfileToUpdateFrom = new DikeProfile(dikeProfile.WorldReferencePoint, dikeProfile.DikeGeometry,