Fisheye: Tag 497eff2ae81726e546751a3423f5b7b5b93d1e3e refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/UpdateEntryAndExitPointsCalculationGroupChangeHandler.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/UpdateEntryAndExitPointsOfCalculationsChangeHandler.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/UpdateEntryAndExitPointsOfCalculationsChangeHandler.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/UpdateEntryAndExitPointsOfCalculationsChangeHandler.cs (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -0,0 +1,80 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Gui;
+using Ringtoets.Common.IO;
+using Ringtoets.Piping.Data;
+
+namespace Ringtoets.Piping.Plugin.ChangeHandlers
+{
+ ///
+ /// Class which can, if required, inquire the user for a confirmation when a change to the
+ /// entry and exit points requires calculation results to be altered.
+ ///
+ public class UpdateEntryAndExitPointsOfCalculationsChangeHandler : IConfirmDataChangeHandler
+ {
+ private readonly IEnumerable calculations;
+ private readonly IInquiryHelper inquiryHandler;
+ private readonly string query;
+
+ ///
+ /// Instantiates a .
+ ///
+ /// The calculations for which to handle the changes in the entry and exit points.
+ /// The query which should be displayed when inquiring for a confirmation.
+ /// Object responsible for inquiring required data.
+ /// Thrown when any input parameter is null.
+ public UpdateEntryAndExitPointsOfCalculationsChangeHandler(IEnumerable calculations,
+ string query,
+ IInquiryHelper inquiryHandler)
+ {
+ if (calculations == null)
+ {
+ throw new ArgumentNullException(nameof(calculations));
+ }
+ if (query == null)
+ {
+ throw new ArgumentNullException(nameof(query));
+ }
+ if (inquiryHandler == null)
+ {
+ throw new ArgumentNullException(nameof(inquiryHandler));
+ }
+
+ this.calculations = calculations;
+ this.query = query;
+ this.inquiryHandler = inquiryHandler;
+ }
+
+ public bool RequireConfirmation()
+ {
+ return calculations.Any(calc => calc.HasOutput);
+ }
+
+ public bool InquireConfirmation()
+ {
+ return inquiryHandler.InquireContinuation(query);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -811,7 +811,7 @@
context.FailureMechanism.Contribution));
}
- private static StrictContextMenuItem CreateUpdateEntryAndExitPointItem(PipingCalculationScenarioContext context)
+ private StrictContextMenuItem CreateUpdateEntryAndExitPointItem(PipingCalculationScenarioContext context)
{
bool hasSurfaceLine = context.WrappedData.InputParameters.SurfaceLine != null;
@@ -823,12 +823,25 @@
Resources.PipingPlugin_CreateUpdateEntryAndExitPointItem_Update_entry_and_exit_point,
toolTipMessage,
RingtoetsCommonFormsResources.UpdateItemIcon,
- (o, args) => { UpdateSurfaceLineDependentData(context.WrappedData); })
+ (o, args) => { UpdatedSurfaceLineDependentDataOfCalculation(context.WrappedData); })
{
Enabled = hasSurfaceLine
};
}
+ private void UpdatedSurfaceLineDependentDataOfCalculation(PipingCalculation scenario)
+ {
+ string message =
+ Resources.PipingPlugin_VerifyEntryAndExitPointUpdates_When_updating_entry_and_exit_points_definitions_assigned_to_calculation_output_will_be_cleared_confirm;
+ if (VerifyEntryAndExitPointUpdates(new[]
+ {
+ scenario
+ }, message))
+ {
+ UpdateSurfaceLineDependentData(scenario);
+ }
+ }
+
private static void UpdateSurfaceLineDependentData(PipingCalculation scenario)
{
PipingInput inputParameters = scenario.InputParameters;
@@ -1064,7 +1077,9 @@
{
PipingCalculationScenario[] calculations = nodeData.WrappedData.GetCalculations().OfType().ToArray();
- if (VerifyEntryAndExitPointUpdates(calculations))
+ string message =
+ Resources.PipingPlugin_VerifyEntryAndExitPointUpdates_When_updating_entry_and_exit_points_definitions_assigned_to_calculations_output_will_be_cleared_confirm;
+ if (VerifyEntryAndExitPointUpdates(calculations, message))
{
foreach (PipingCalculationScenario calculation in calculations)
{
@@ -1073,10 +1088,10 @@
}
}
- private bool VerifyEntryAndExitPointUpdates(IEnumerable calculations)
+ private bool VerifyEntryAndExitPointUpdates(IEnumerable calculations, string query)
{
- var changeHandler = new UpdateEntryAndExitPointsCalculationGroupChangeHandler(calculations,
- new DialogBasedInquiryHelper(Gui.MainWindow));
+ var changeHandler = new UpdateEntryAndExitPointsOfCalculationsChangeHandler(calculations, query,
+ new DialogBasedInquiryHelper(Gui.MainWindow));
return !changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation();
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -222,6 +222,30 @@
}
///
+ /// Looks up a localized string similar to Wanneer de intrede- en/of uittredepunten wijzigen als gevolg van het bijwerken, zal het resultaat van de berekening die deze profielschematisaties gebruikt, worden verwijderd.
+ ///
+ ///Weet u zeker dat u wilt doorgaan?.
+ ///
+ public static string PipingPlugin_VerifyEntryAndExitPointUpdates_When_updating_entry_and_exit_points_definitions_assigned_to_calculation_output_will_be_cleared_confirm {
+ get {
+ return ResourceManager.GetString("PipingPlugin_VerifyEntryAndExitPointUpdates_When_updating_entry_and_exit_points_d" +
+ "efinitions_assigned_to_calculation_output_will_be_cleared_confirm", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Wanneer de intrede- en uittrede punten wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze profielschematisaties gebruiken, worden verwijderd.
+ ///
+ ///Weet u zeker dat u wilt doorgaan?.
+ ///
+ public static string PipingPlugin_VerifyEntryAndExitPointUpdates_When_updating_entry_and_exit_points_definitions_assigned_to_calculations_output_will_be_cleared_confirm {
+ get {
+ return ResourceManager.GetString("PipingPlugin_VerifyEntryAndExitPointUpdates_When_updating_entry_and_exit_points_d" +
+ "efinitions_assigned_to_calculations_output_will_be_cleared_confirm", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Karakteristieke punten gevonden zonder bijbehorende profielschematisatie voor locatie '{0}'..
///
public static string PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Characteristic_points_found_for_unknown_SurfaceLine_0_ {
@@ -520,18 +544,5 @@
"asticSoilModel_failed", resourceCulture);
}
}
-
- ///
- /// Looks up a localized string similar to Wanneer de intrede- en uittrede punten wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze profielschematisaties gebruiken, worden verwijderd.
- ///
- ///Weet u zeker dat u wilt doorgaan?.
- ///
- public static string UpdateEntryAndExitPointsCalculationGroupChangeHandler_InquireConfirmation_When_updating_entry_and_exit_points_definitions_assigned_to_calculations_output_will_be_cleared_confirm {
- get {
- return ResourceManager.GetString("UpdateEntryAndExitPointsCalculationGroupChangeHandler_InquireConfirmation_When_up" +
- "dating_entry_and_exit_points_definitions_assigned_to_calculations_output_will_be" +
- "_cleared_confirm", resourceCulture);
- }
- }
}
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -259,9 +259,14 @@
Er zijn geen berekeningen met een profielschematisatie.
-
+
Wanneer de intrede- en uittrede punten wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze profielschematisaties gebruiken, worden verwijderd.
Weet u zeker dat u wilt doorgaan?
+
+ Wanneer de intrede- en/of uittredepunten wijzigen als gevolg van het bijwerken, zal het resultaat van de berekening die deze profielschematisaties gebruikt, worden verwijderd.
+
+Weet u zeker dat u wilt doorgaan?
+
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -60,7 +60,7 @@
Properties\GlobalAssembly.cs
-
+
Fisheye: Tag 497eff2ae81726e546751a3423f5b7b5b93d1e3e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateCharacteristicPointsCalculationGroupChangeHandlerTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateCharacteristicPointsOfCalculationsChangeHandlerTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateCharacteristicPointsOfCalculationsChangeHandlerTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateCharacteristicPointsOfCalculationsChangeHandlerTest.cs (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -0,0 +1,173 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Gui;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.IO;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Plugin.ChangeHandlers;
+
+namespace Ringtoets.Piping.Plugin.Test.ChangeHandlers
+{
+ [TestFixture]
+ public class UpdateCharacteristicPointsOfCalculationsChangeHandlerTest
+ {
+ [Test]
+ public void Constructor_WithoutCalculations_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new UpdateEntryAndExitPointsOfCalculationsChangeHandler(null, string.Empty, inquiryHandler);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("calculations", paramName);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_WithoutInquiryHandler_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new UpdateEntryAndExitPointsOfCalculationsChangeHandler(Enumerable.Empty(), string.Empty, null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("inquiryHandler", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithoutQuery_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new UpdateEntryAndExitPointsOfCalculationsChangeHandler(Enumerable.Empty(), null, inquiryHandler);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("query", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithParameters_ImplementsExpectedInterface()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ // Call
+ var handler = new UpdateEntryAndExitPointsOfCalculationsChangeHandler(Enumerable.Empty(), string.Empty, inquiryHandler);
+
+ // Assert
+ Assert.IsInstanceOf(handler);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void RequireConfirmation_WithCalculationWithoutOutput_ReturnFalse()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ IEnumerable calculations = new List
+ {
+ new PipingCalculationScenario(new GeneralPipingInput())
+ };
+
+ var handler = new UpdateEntryAndExitPointsOfCalculationsChangeHandler(calculations, string.Empty, inquiryHandler);
+
+ // Call
+ bool requireConfirmation = handler.RequireConfirmation();
+
+ // Assert
+ Assert.IsFalse(requireConfirmation);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void RequireConfirmation_CalculationsWithoutAndWithOutput_ReturnTrue()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ IEnumerable calculations = new List
+ {
+ new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Output = new TestPipingOutput()
+ },
+ new PipingCalculationScenario(new GeneralPipingInput())
+ };
+
+ var handler = new UpdateEntryAndExitPointsOfCalculationsChangeHandler(calculations, string.Empty, inquiryHandler);
+
+ // Call
+ bool requireConfirmation = handler.RequireConfirmation();
+
+ // Assert
+ Assert.IsTrue(requireConfirmation);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase("I am a query", true)]
+ [TestCase("I am a query", false)]
+ [TestCase("", true)]
+ [TestCase("", false)]
+ [TestCase(" ", true)]
+ [TestCase(" ", false)]
+ public void InquireConfirmation_Always_ShowsConfirmationDialogReturnResultOfInquiry(string message, bool expectedResult)
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ inquiryHandler.Expect(ih => ih.InquireContinuation(message)).Return(expectedResult);
+ mockRepository.ReplayAll();
+
+ var handler = new UpdateEntryAndExitPointsOfCalculationsChangeHandler(Enumerable.Empty(), message, inquiryHandler);
+
+ // Call
+ bool result = handler.InquireConfirmation();
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ mockRepository.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -72,7 +72,7 @@
Properties\GlobalAssembly.cs
-
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationGroupContextTreeNodeInfoTest.cs (.../PipingCalculationGroupContextTreeNodeInfoTest.cs) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -392,7 +392,7 @@
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuUpdateEntryAndExitPointsAllIndexRootGroup,
"&Bijwerken alle intrede- en uittredepunten",
"Er zijn geen berekeningen met een profielschematisatie.",
- RingtoetsCommonFormsResources.UpdateItemIcon,
+ RingtoetsCommonFormsResources.UpdateItemIcon,
false);
TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndexRootGroup,
"Alles &valideren",
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs
===================================================================
diff -u -r5cac0be5a13b25f4e34680f9c3da63ec537a4ef3 -r497eff2ae81726e546751a3423f5b7b5b93d1e3e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 5cac0be5a13b25f4e34680f9c3da63ec537a4ef3)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/TreeNodeInfos/PipingCalculationScenarioContextTreeNodeInfoTest.cs (.../PipingCalculationScenarioContextTreeNodeInfoTest.cs) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
@@ -27,6 +27,7 @@
using Core.Common.Base.Geometry;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
+using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms.MainWindow;
using Core.Common.Gui.TestUtil.ContextMenu;
@@ -469,7 +470,7 @@
}
[Test]
- public void GivenCalculationWithSurfaceLineWithoutOutput_WhenEntryAndExitPointUpdatedAndUpdateEntryAndExitPointClicked_ThenPointsUpdatedAndInputObserverNotified()
+ public void GivenCalculationWithSurfaceLineWithoutOutput_WhenEntryAndExitPointUpdatedAndUpdateEntryAndExitPointClicked_ThenNoInquiryAndPointsUpdatedAndInputObserverNotified()
{
using (var treeViewControl = new TreeViewControl())
{
@@ -505,8 +506,11 @@
var calculationObserver = mocks.StrictMock();
calculation.Attach(calculationObserver);
+ 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.ViewCommands).Return(mocks.Stub());
mocks.ReplayAll();
plugin.Gui = gui;
@@ -533,14 +537,15 @@
Assert.AreSame(surfaceLine, inputParameters.SurfaceLine);
Assert.AreEqual(new RoundedDouble(2, 2), inputParameters.EntryPointL);
Assert.AreEqual(new RoundedDouble(3, 3), inputParameters.ExitPointL);
+ Assert.IsFalse(calculation.HasOutput);
// Note: observer assertions are verified in Teardown
}
}
}
[Test]
- public void GivenCalculationWithSurfaceLineAndOutput_WhenEntryAndExitPointsUpdatedAndUpdateEntryAndExitPointClicked_ThenPointsUpdatedOutputsRemovedAndObserversNotified()
+ public void GivenCalculationWithSurfaceLineAndOutput_WhenEntryAndExitPointsUpdatedAndUpdateEntryAndExitPointClickedAndContinued_ThenPointsUpdatedOutputsRemovedAndObserversNotified()
{
using (var treeViewControl = new TreeViewControl())
{
@@ -578,12 +583,23 @@
calculationObserver.Expect(obs => obs.UpdateObserver());
calculation.Attach(calculationObserver);
+ 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.ViewCommands).Return(mocks.Stub());
mocks.ReplayAll();
plugin.Gui = gui;
+ string textBoxMessage = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ textBoxMessage = helper.Text;
+ helper.ClickOk();
+ };
+
using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl))
{
// When
@@ -608,13 +624,18 @@
Assert.AreEqual(new RoundedDouble(3, 3), inputParameters.ExitPointL);
Assert.IsFalse(calculation.HasOutput);
+ string expectedMessage = "Wanneer de intrede- en/of uittredepunten wijzigen als gevolg van het bijwerken, " +
+ "zal het resultaat van de berekening die deze profielschematisaties gebruikt, worden " +
+ $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
+ Assert.AreEqual(expectedMessage, textBoxMessage);
+
// Note: observer assertions are verified in Teardown
}
}
}
[Test]
- public void GivenCalculationWithSurfaceLineAndOutput_WhenUpdatedEntryAndExitPointsHasNoChangeAndUpdateEntryAndExitPointClicked_ThenOutputNotRemovedAndObserversNotNotified()
+ public void GivenCalculationWithSurfaceLineAndOutput_WhenUpdatedEntryAndExitPointsHasNoChangeAndUpdateEntryAndExitPointClickedAndContinued_ThenOutputNotRemovedAndObserversNotNotified()
{
using (var treeViewControl = new TreeViewControl())
{
@@ -650,12 +671,23 @@
var calculationObserver = mocks.StrictMock();
calculation.Attach(calculationObserver);
+ 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.ViewCommands).Return(mocks.Stub());
mocks.ReplayAll();
plugin.Gui = gui;
+ string textBoxMessage = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ textBoxMessage = helper.Text;
+ helper.ClickOk();
+ };
+
using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl))
{
// When
@@ -680,12 +712,105 @@
Assert.AreEqual(new RoundedDouble(3, 3), inputParameters.ExitPointL);
Assert.IsTrue(calculation.HasOutput);
+ string expectedMessage = "Wanneer de intrede- en/of uittredepunten wijzigen als gevolg van het bijwerken, " +
+ "zal het resultaat van de berekening die deze profielschematisaties gebruikt, worden " +
+ $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
+ Assert.AreEqual(expectedMessage, textBoxMessage);
+
// Note: observer assertions are verified in Teardown
}
}
}
[Test]
+ public void GivenCalculationWithSurfaceLineAndOutput_WhenEntryAndExitPointsUpdatedAndUpdateEntryAndExitPointClickedAndDiscontinued_ThenCalculationNotUpdatedAndObserversNotUpdated()
+ {
+ using (var treeViewControl = new TreeViewControl())
+ {
+ // Given
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(1, 2, 3),
+ new Point3D(4, 5, 6)
+ });
+ var calculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ InputParameters =
+ {
+ SurfaceLine = surfaceLine,
+ EntryPointL = (RoundedDouble) 0,
+ ExitPointL = (RoundedDouble) 1
+ },
+ Output = new TestPipingOutput()
+ };
+
+ var pipingFailureMechanism = new TestPipingFailureMechanism();
+ var assessmentSection = mocks.Stub();
+ var nodeData = new PipingCalculationScenarioContext(calculation,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ pipingFailureMechanism,
+ assessmentSection);
+
+ var inputObserver = mocks.StrictMock();
+ calculation.InputParameters.Attach(inputObserver);
+
+ var calculationObserver = mocks.StrictMock();
+ calculation.Attach(calculationObserver);
+
+ 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.ViewCommands).Return(mocks.Stub());
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ string textBoxMessage = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ textBoxMessage = helper.Text;
+ helper.ClickCancel();
+ };
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl))
+ {
+ // When
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(0, 0, 0),
+ new Point3D(1, 0, 2),
+ new Point3D(2, 0, 3),
+ new Point3D(3, 0, 0),
+ new Point3D(4, 0, 2),
+ new Point3D(5, 0, 3)
+ });
+ surfaceLine.SetDikeToeAtRiverAt(new Point3D(2, 0, 3));
+ surfaceLine.SetDikeToeAtPolderAt(new Point3D(3, 0, 0));
+
+ contextMenuStrip.Items[contextMenuUpdateEntryAndExitPointIndex].PerformClick();
+
+ // Then
+ PipingInput inputParameters = calculation.InputParameters;
+ Assert.AreSame(surfaceLine, inputParameters.SurfaceLine);
+ Assert.AreEqual(new RoundedDouble(2, 0), inputParameters.EntryPointL);
+ Assert.AreEqual(new RoundedDouble(3, 1), inputParameters.ExitPointL);
+ Assert.IsTrue(calculation.HasOutput);
+
+ string expectedMessage = "Wanneer de intrede- en/of uittredepunten wijzigen als gevolg van het bijwerken, " +
+ "zal het resultaat van de berekening die deze profielschematisaties gebruikt, worden " +
+ $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
+ Assert.AreEqual(expectedMessage, textBoxMessage);
+
+ // Note: observer assertions are verified in Teardown
+ }
+ }
+ }
+
+ [Test]
[TestCase(true)]
[TestCase(false)]
public void OnNodeRemoved_ParentIsPipingCalculationGroupContext_RemoveCalculationFromGroup(bool groupNameEditable)