Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs =================================================================== diff -u -rda6c157314d3df1c278d58cc444c7754a79dc656 -rd3ebf1b56b406bc99fdf54a9920fdfa9f7632ca7 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs (.../StochasticSoilModelCollectionContextImportInfoTest.cs) (revision da6c157314d3df1c278d58cc444c7754a79dc656) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/StochasticSoilModelCollectionContextImportInfoTest.cs (.../StochasticSoilModelCollectionContextImportInfoTest.cs) (revision d3ebf1b56b406bc99fdf54a9920fdfa9f7632ca7) @@ -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.IO.Importers; +using Ringtoets.Piping.KernelWrapper.TestUtil; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; namespace Ringtoets.Piping.Plugin.Test.ImportInfos { [TestFixture] - public class StochasticSoilModelCollectionContextImportInfoTest + public class StochasticSoilModelCollectionContextImportInfoTest : NUnitFormTest { private ImportInfo importInfo; private PipingPlugin plugin; @@ -50,7 +53,7 @@ } [TearDown] - public void TearDown() + public override void TearDown() { plugin.Dispose(); } @@ -167,6 +170,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 stochasticSoilModelCollection = new StochasticSoilModelCollection(); + var context = new StochasticSoilModelCollectionContext(stochasticSoilModelCollection, 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 stochastische ondergrondmodellen importeert, " + + "dan worden all 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_Always_ReturnFileImporter() { // Setup