Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/RingtoetsPipingSurfaceLineChangeHandler.cs
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/RingtoetsPipingSurfaceLineChangeHandler.cs (.../RingtoetsPipingSurfaceLineChangeHandler.cs) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/ChangeHandlers/RingtoetsPipingSurfaceLineChangeHandler.cs (.../RingtoetsPipingSurfaceLineChangeHandler.cs) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -25,7 +25,6 @@
using Core.Common.Gui;
using Ringtoets.Common.IO;
using Ringtoets.Piping.Data;
-using Ringtoets.Piping.Plugin.Properties;
namespace Ringtoets.Piping.Plugin.ChangeHandlers
{
@@ -37,24 +36,32 @@
{
private readonly IInquiryHelper inquiryHandler;
private readonly PipingFailureMechanism failureMechanism;
+ private readonly string query;
///
/// Creates a new instance of .
///
/// Failure mechanism for which to handle changes in stochastic soil models.
+ /// 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 RingtoetsPipingSurfaceLineChangeHandler(PipingFailureMechanism failureMechanism, IInquiryHelper inquiryHandler)
+ public RingtoetsPipingSurfaceLineChangeHandler(PipingFailureMechanism failureMechanism,
+ string query,
+ IInquiryHelper inquiryHandler)
{
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
+ if (query == null)
+ {
+ throw new ArgumentNullException(nameof(query));
+ }
if (inquiryHandler == null)
{
throw new ArgumentNullException(nameof(inquiryHandler));
}
-
+ this.query = query;
this.failureMechanism = failureMechanism;
this.inquiryHandler = inquiryHandler;
}
@@ -68,8 +75,7 @@
public bool InquireConfirmation()
{
- return inquiryHandler.InquireContinuation(
- Resources.RingtoetsPipingSurfaceLineChangeHandler_InquireConfirmation_When_updating_RingtoetsSurfaceLines_definitions_assigned_to_calculations_output_will_be_cleared_confirm);
+ return inquiryHandler.InquireContinuation(query);
}
private static bool HasOutput(PipingCalculation calculation)
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs
===================================================================
diff -u -r0e920a944ff542813705a2f3a42c82d8782c1d07 -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 0e920a944ff542813705a2f3a42c82d8782c1d07)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -106,7 +106,7 @@
FileFilterGenerator = RingtoetsPipingSurfaceLineFileFilter,
IsEnabled = IsSurfaceLineImporterEnabled,
CreateFileImporter = (context, filePath) => PipingSurfaceLinesCsvImporter(context, filePath, new RingtoetsPipingSurfaceLineReplaceDataStrategy(context.FailureMechanism)),
- VerifyUpdates = VerifyPipingSurfaceLineUpdates
+ VerifyUpdates = context => VerifyPipingSurfaceLineUpdates(context, Resources.PipingPlugin_VerifyRingtoetsPipingSurfaceLineImport_When_importing_surfacelines_calculation_output_will_be_cleared_confirm)
};
yield return new ImportInfo
@@ -155,7 +155,7 @@
IsEnabled = IsSurfaceLineImporterEnabled,
CurrentPath = context => context.WrappedData.SourcePath,
CreateFileImporter = (context, filePath) => PipingSurfaceLinesCsvImporter(context, filePath, new RingtoetsPipingSurfaceLineUpdateDataStrategy(context.FailureMechanism)),
- VerifyUpdates = VerifyPipingSurfaceLineUpdates
+ VerifyUpdates = context => VerifyPipingSurfaceLineUpdates(context, Resources.PipingPlugin_VerifyRingtoetsPipingSurfaceLineUpdates_When_updating_surfacelines_definitions_assigned_to_calculation_output_will_be_cleared_confirm)
};
yield return new UpdateInfo
@@ -1122,9 +1122,9 @@
}
}
- private bool VerifyPipingSurfaceLineUpdates(RingtoetsPipingSurfaceLinesContext context)
+ private bool VerifyPipingSurfaceLineUpdates(RingtoetsPipingSurfaceLinesContext context, string query)
{
- var changeHandler = new RingtoetsPipingSurfaceLineChangeHandler(context.FailureMechanism,
+ var changeHandler = new RingtoetsPipingSurfaceLineChangeHandler(context.FailureMechanism, query,
new DialogBasedInquiryHelper(Gui.MainWindow));
return !changeHandler.RequireConfirmation() || changeHandler.InquireConfirmation();
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -rcd2a8d4da88b91f4c947e820b2f19a3892a25b77 -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision cd2a8d4da88b91f4c947e820b2f19a3892a25b77)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -246,6 +246,30 @@
}
///
+ /// Looks up a localized string similar to Als u profielschematisaties importeert, dan worden alle rekenresultaten van dit toetsspoor verwijderd.
+ ///
+ ///Weet u zeker dat u wilt doorgaan?.
+ ///
+ public static string PipingPlugin_VerifyRingtoetsPipingSurfaceLineImport_When_importing_surfacelines_calculation_output_will_be_cleared_confirm {
+ get {
+ return ResourceManager.GetString("PipingPlugin_VerifyRingtoetsPipingSurfaceLineImport_When_importing_surfacelines_c" +
+ "alculation_output_will_be_cleared_confirm", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Als profielschematisaties wijzigen door het bijwerken, dan worden de resultaten van berekeningen die deze profielschematisaties gebruiken verwijderd.
+ ///
+ ///Weet u zeker dat u wilt doorgaan?.
+ ///
+ public static string PipingPlugin_VerifyRingtoetsPipingSurfaceLineUpdates_When_updating_surfacelines_definitions_assigned_to_calculation_output_will_be_cleared_confirm {
+ get {
+ return ResourceManager.GetString("PipingPlugin_VerifyRingtoetsPipingSurfaceLineUpdates_When_updating_surfacelines_d" +
+ "efinitions_assigned_to_calculation_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_ {
@@ -473,19 +497,6 @@
}
///
- /// Looks up a localized string similar to Wanneer profielschematisaties 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 RingtoetsPipingSurfaceLineChangeHandler_InquireConfirmation_When_updating_RingtoetsSurfaceLines_definitions_assigned_to_calculations_output_will_be_cleared_confirm {
- get {
- return ResourceManager.GetString("RingtoetsPipingSurfaceLineChangeHandler_InquireConfirmation_When_updating_Ringtoe" +
- "tsSurfaceLines_definitions_assigned_to_calculations_output_will_be_cleared_confi" +
- "rm", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Het bijwerken van de profielschematisaties is mislukt..
///
public static string RingtoetsPipingSurfaceLineUpdateDataStrategy_UpdateSurfaceLinesWithImportedData_Update_of_RingtoetsPipingSurfaceLine_has_failed {
Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx
===================================================================
diff -u -rcd2a8d4da88b91f4c947e820b2f19a3892a25b77 -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision cd2a8d4da88b91f4c947e820b2f19a3892a25b77)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -233,8 +233,8 @@
Ringtoets berekeningenconfiguratie
-
- Wanneer profielschematisaties wijzigen als gevolg van het bijwerken, zullen de resultaten van berekeningen die deze profielschematisaties gebruiken, worden verwijderd.
+
+ Als profielschematisaties wijzigen door het bijwerken, dan worden de resultaten van berekeningen die deze profielschematisaties gebruiken verwijderd.
Weet u zeker dat u wilt doorgaan?
@@ -269,4 +269,9 @@
Weet u zeker dat u wilt doorgaan?
+
+ Als u profielschematisaties importeert, dan worden alle rekenresultaten van dit toetsspoor verwijderd.
+
+Weet u zeker dat u wilt doorgaan?
+
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/RingtoetsPipingSurfaceLineChangeHandlerTest.cs
===================================================================
diff -u -r03fae882dff9db344c9380368a85ecdf3ab46f2a -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/RingtoetsPipingSurfaceLineChangeHandlerTest.cs (.../RingtoetsPipingSurfaceLineChangeHandlerTest.cs) (revision 03fae882dff9db344c9380368a85ecdf3ab46f2a)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/RingtoetsPipingSurfaceLineChangeHandlerTest.cs (.../RingtoetsPipingSurfaceLineChangeHandlerTest.cs) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -42,7 +42,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => new RingtoetsPipingSurfaceLineChangeHandler(null, inquiryHandler);
+ TestDelegate test = () => new RingtoetsPipingSurfaceLineChangeHandler(null, string.Empty, inquiryHandler);
// Assert
string paramName = Assert.Throws(test).ParamName;
@@ -51,10 +51,27 @@
}
[Test]
+ public void Constructor_WithoutQuery_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var inquiryHandler = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), null, inquiryHandler);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("query", paramName);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void Constructor_WithoutInquiryHandler_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), null);
+ TestDelegate test = () => new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), string.Empty, null);
// Assert
string paramName = Assert.Throws(test).ParamName;
@@ -70,7 +87,7 @@
mockRepository.ReplayAll();
// Call
- var handler = new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), inquiryHandler);
+ var handler = new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), string.Empty, inquiryHandler);
// Assert
Assert.IsInstanceOf(handler);
@@ -88,7 +105,7 @@
var failureMechanism = new PipingFailureMechanism();
failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(new GeneralPipingInput()));
- var handler = new RingtoetsPipingSurfaceLineChangeHandler(failureMechanism, inquiryHandler);
+ var handler = new RingtoetsPipingSurfaceLineChangeHandler(failureMechanism, string.Empty, inquiryHandler);
// Call
bool requireConfirmation = handler.RequireConfirmation();
@@ -112,7 +129,7 @@
Output = new TestPipingOutput()
});
- var handler = new RingtoetsPipingSurfaceLineChangeHandler(failureMechanism, inquiryHandler);
+ var handler = new RingtoetsPipingSurfaceLineChangeHandler(failureMechanism, string.Empty, inquiryHandler);
// Call
bool requireConfirmation = handler.RequireConfirmation();
@@ -123,21 +140,21 @@
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void InquireConfirmation_Always_ShowsConfirmationDialogReturnResultOfInquiry(bool expectedResult)
+ [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
- string message = "Wanneer profielschematisaties wijzigen als gevolg van het bijwerken, " +
- "zullen de resultaten van berekeningen die deze profielschematisaties gebruiken, worden " +
- $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
-
var mockRepository = new MockRepository();
var inquiryHandler = mockRepository.StrictMock();
inquiryHandler.Expect(ih => ih.InquireContinuation(message)).Return(expectedResult);
mockRepository.ReplayAll();
- var handler = new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), inquiryHandler);
+ var handler = new RingtoetsPipingSurfaceLineChangeHandler(new PipingFailureMechanism(), message, inquiryHandler);
// Call
bool result = handler.InquireConfirmation();
Fisheye: Tag 7271c497cf19130a691b0b07abe99621957fda2e refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateCharacteristicPointsOfCalculationsChangeHandlerTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateEntryAndExitPointsOfCalculationsChangeHandlerTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateEntryAndExitPointsOfCalculationsChangeHandlerTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ChangeHandlers/UpdateEntryAndExitPointsOfCalculationsChangeHandlerTest.cs (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -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 UpdateEntryAndExitPointsOfCalculationsChangeHandlerTest
+ {
+ [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/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs
===================================================================
diff -u -rda6c157314d3df1c278d58cc444c7754a79dc656 -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextImportInfoTest.cs) (revision da6c157314d3df1c278d58cc444c7754a79dc656)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextImportInfoTest.cs) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -19,25 +19,28 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Drawing;
using System.Linq;
using Core.Common.Base.IO;
using Core.Common.Gui;
using Core.Common.Gui.Forms.MainWindow;
using Core.Common.Gui.Plugin;
using Core.Common.TestUtil;
+using NUnit.Extensions.Forms;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
using Ringtoets.Piping.Plugin.FileImporter;
using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources;
namespace Ringtoets.Piping.Plugin.Test.ImportInfos
{
[TestFixture]
- public class RingtoetsPipingSurfaceLinesContextImportInfoTest
+ public class RingtoetsPipingSurfaceLinesContextImportInfoTest : NUnitFormTest
{
private ImportInfo importInfo;
private PipingPlugin plugin;
@@ -50,7 +53,7 @@
}
[TearDown]
- public void TearDown()
+ public override void TearDown()
{
plugin.Dispose();
}
@@ -169,6 +172,61 @@
}
[Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+
+ var mainWindow = mocks.Stub();
+ var gui = mocks.Stub();
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ var failureMechanism = new PipingFailureMechanism();
+ var calculationWithOutput = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Output = new TestPipingOutput()
+ };
+ failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput);
+
+ var surfaceLines = new RingtoetsPipingSurfaceLineCollection();
+ var context = new RingtoetsPipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);
+
+ string textBoxMessage = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ textBoxMessage = helper.Text;
+
+ if (isActionConfirmed)
+ {
+ helper.ClickOk();
+ }
+ else
+ {
+ helper.ClickCancel();
+ }
+ };
+
+ // Call
+ bool requiresUpdateConfirmation = importInfo.VerifyUpdates(context);
+
+ // Assert
+ string expectedInquiryMessage = "Als u profielschematisaties importeert, " +
+ "dan worden alle rekenresultaten van dit toetsspoor verwijderd." +
+ $"{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
+ Assert.AreEqual(expectedInquiryMessage, textBoxMessage);
+ Assert.AreEqual(isActionConfirmed, requiresUpdateConfirmation);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void CreateFileImporter_ValidInput_ReturnFileImporter()
{
// Setup
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj
===================================================================
diff -u -r497eff2ae81726e546751a3423f5b7b5b93d1e3e -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 497eff2ae81726e546751a3423f5b7b5b93d1e3e)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -72,7 +72,7 @@
Properties\GlobalAssembly.cs
-
+
Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs
===================================================================
diff -u -r583456a0f5395189a54a8cedf4e4a7b40945d990 -r7271c497cf19130a691b0b07abe99621957fda2e
--- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs) (revision 583456a0f5395189a54a8cedf4e4a7b40945d990)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextUpdateInfoTest.cs) (revision 7271c497cf19130a691b0b07abe99621957fda2e)
@@ -19,26 +19,29 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Drawing;
using System.Linq;
using Core.Common.Base.IO;
using Core.Common.Gui;
using Core.Common.Gui.Forms.MainWindow;
using Core.Common.Gui.Plugin;
using Core.Common.TestUtil;
+using NUnit.Extensions.Forms;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
using Ringtoets.Piping.Plugin.FileImporter;
using Ringtoets.Piping.Primitives;
using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources;
namespace Ringtoets.Piping.Plugin.Test.UpdateInfos
{
[TestFixture]
- public class RingtoetsPipingSurfaceLinesContextUpdateInfoTest
+ public class RingtoetsPipingSurfaceLinesContextUpdateInfoTest : NUnitFormTest
{
private UpdateInfo updateInfo;
private PipingPlugin plugin;
@@ -51,7 +54,7 @@
}
[TearDown]
- public void TearDown()
+ public override void TearDown()
{
plugin.Dispose();
}
@@ -170,6 +173,61 @@
}
[Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void VerifyUpdates_CalculationWithOutputs_AlwaysReturnsExpectedInquiryMessage(bool isActionConfirmed)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+
+ var mainWindow = mocks.Stub();
+ var gui = mocks.Stub();
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ var failureMechanism = new PipingFailureMechanism();
+ var calculationWithOutput = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Output = new TestPipingOutput()
+ };
+ failureMechanism.CalculationsGroup.Children.Add(calculationWithOutput);
+
+ var surfaceLines = new RingtoetsPipingSurfaceLineCollection();
+ var context = new RingtoetsPipingSurfaceLinesContext(surfaceLines, failureMechanism, assessmentSection);
+
+ string textBoxMessage = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var helper = new MessageBoxTester(wnd);
+ textBoxMessage = helper.Text;
+
+ if (isActionConfirmed)
+ {
+ helper.ClickOk();
+ }
+ else
+ {
+ helper.ClickCancel();
+ }
+ };
+
+ // Call
+ bool requiresUpdateConfirmation = updateInfo.VerifyUpdates(context);
+
+ // Assert
+ string expectedInquiryMessage = "Als profielschematisaties wijzigen door het bijwerken, " +
+ "dan worden de resultaten van berekeningen die deze profielschematisaties gebruiken " +
+ $"verwijderd.{Environment.NewLine}{Environment.NewLine}Weet u zeker dat u wilt doorgaan?";
+ Assert.AreEqual(expectedInquiryMessage, textBoxMessage);
+ Assert.AreEqual(isActionConfirmed, requiresUpdateConfirmation);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void CurrentPath_SurfaceLineCollectionHasPathSet_ReturnsExpectedPath()
{
// Setup