Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/StochasticSoilModelCollectionContextUpdateInfoTest.cs =================================================================== diff -u -rda6c157314d3df1c278d58cc444c7754a79dc656 -rd3ebf1b56b406bc99fdf54a9920fdfa9f7632ca7 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/StochasticSoilModelCollectionContextUpdateInfoTest.cs (.../StochasticSoilModelCollectionContextUpdateInfoTest.cs) (revision da6c157314d3df1c278d58cc444c7754a79dc656) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/UpdateInfos/StochasticSoilModelCollectionContextUpdateInfoTest.cs (.../StochasticSoilModelCollectionContextUpdateInfoTest.cs) (revision d3ebf1b56b406bc99fdf54a9920fdfa9f7632ca7) @@ -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.Data.TestUtil; 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.UpdateInfos { [TestFixture] - public class StochasticSoilModelCollectionContextUpdateInfoTest + public class StochasticSoilModelCollectionContextUpdateInfoTest : NUnitFormTest { private UpdateInfo updateInfo; private PipingPlugin plugin; @@ -51,7 +54,7 @@ } [TearDown] - public void TearDown() + public override void TearDown() { plugin.Dispose(); } @@ -168,6 +171,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 = updateInfo.VerifyUpdates(context); + + // Assert + string expectedInquiryMessage = "Als ondergrondschematisaties wijzigen door het bijwerken, " + + "dan worden de resultaten van berekeningen die deze ondergrondschematisaties 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_StochasticSoilModelCollectionHasPathSet_ReturnsExpectedPath() { // Setup