Index: Riskeer/Piping/src/Riskeer.Piping.Forms/ChangeHandlers/ClearProbabilisticPipingCalculationOutputChangeHandler.cs
===================================================================
diff -u
--- Riskeer/Piping/src/Riskeer.Piping.Forms/ChangeHandlers/ClearProbabilisticPipingCalculationOutputChangeHandler.cs (revision 0)
+++ Riskeer/Piping/src/Riskeer.Piping.Forms/ChangeHandlers/ClearProbabilisticPipingCalculationOutputChangeHandler.cs (revision a7a9b490e9d6ffd90dbed4a711ed9dd0f2ba7087)
@@ -0,0 +1,54 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Core.Common.Gui.Commands;
+using Core.Common.Gui.Helpers;
+using Core.Common.Util.Extensions;
+using Riskeer.Common.Forms.ChangeHandlers;
+using Riskeer.Piping.Data.Probabilistic;
+
+namespace Riskeer.Piping.Forms.ChangeHandlers
+{
+ ///
+ /// Class for handling clearing the output of .
+ ///
+ public class ClearProbabilisticPipingCalculationOutputChangeHandler : ClearCalculationOutputChangeHandlerBase
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The calculations to clear the output for.
+ /// Object responsible for inquiring confirmation.
+ /// The view commands used to close views for the calculation output.
+ /// Thrown when any parameter is null.
+ public ClearProbabilisticPipingCalculationOutputChangeHandler(
+ IEnumerable calculations,
+ IInquiryHelper inquiryHelper, IViewCommands viewCommands)
+ : base(calculations, inquiryHelper, viewCommands) {}
+
+ protected override void DoPreUpdateActions()
+ {
+ Calculations.ForEachElementDo(calculation => ViewCommands.RemoveAllViewsForItem(calculation.Output));
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/ChangeHandlers/ClearProbabilisticPipingCalculationOutputChangeHandlerTest.cs
===================================================================
diff -u
--- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/ChangeHandlers/ClearProbabilisticPipingCalculationOutputChangeHandlerTest.cs (revision 0)
+++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/ChangeHandlers/ClearProbabilisticPipingCalculationOutputChangeHandlerTest.cs (revision a7a9b490e9d6ffd90dbed4a711ed9dd0f2ba7087)
@@ -0,0 +1,88 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Linq;
+using Core.Common.Gui.Commands;
+using Core.Common.Gui.Helpers;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Forms.ChangeHandlers;
+using Riskeer.Piping.Data.Probabilistic;
+using Riskeer.Piping.Data.TestUtil;
+using Riskeer.Piping.Forms.ChangeHandlers;
+
+namespace Riskeer.Piping.Forms.Test.ChangeHandlers
+{
+ [TestFixture]
+ public class ClearProbabilisticPipingCalculationOutputChangeHandlerTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var inquiryHelper = mocks.Stub();
+ var viewCommands = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ var changeHandler = new ClearProbabilisticPipingCalculationOutputChangeHandler(
+ Enumerable.Empty(), inquiryHelper, viewCommands);
+
+ // Assert
+ Assert.IsInstanceOf>(changeHandler);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GivenChangeHandler_WhenClearingCalculations_ThenViewsClosedForOutputs()
+ {
+ // Given
+ var calculations = new[]
+ {
+ new ProbabilisticPipingCalculationScenario
+ {
+ Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithoutIllustrationPoints()
+ },
+ new ProbabilisticPipingCalculationScenario
+ {
+ Output = PipingTestDataGenerator.GetRandomProbabilisticPipingOutputWithIllustrationPoints()
+ }
+ };
+
+ var mocks = new MockRepository();
+ var inquiryHelper = mocks.Stub();
+ var viewCommands = mocks.StrictMock();
+ viewCommands.Expect(vc => vc.RemoveAllViewsForItem(calculations[0].Output));
+ viewCommands.Expect(vc => vc.RemoveAllViewsForItem(calculations[1].Output));
+ mocks.ReplayAll();
+
+ var changeHandler = new ClearProbabilisticPipingCalculationOutputChangeHandler(
+ calculations, inquiryHelper, viewCommands);
+
+ // When
+ changeHandler.ClearCalculations();
+
+ // Then
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file