Index: Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -rf50b2f7eb389f5d2274e37b9eb61f4ef165640c2 -rb88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e --- Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision f50b2f7eb389f5d2274e37b9eb61f4ef165640c2) +++ Riskeer/ClosingStructures/src/Riskeer.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e) @@ -865,12 +865,12 @@ #region Helpers - private ClearStructureCalculationsIllustrationPointsChangeHandler CreateChangeHandler( + private ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler CreateChangeHandler( IInquiryHelper inquiryHelper, string inquiry, IEnumerable> calculations) { - return new ClearStructureCalculationsIllustrationPointsChangeHandler(inquiryHelper, inquiry, calculations); + return new ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler(inquiryHelper, inquiry, calculations); } private static bool HasIllustrationPoints(IEnumerable calculations) Index: Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler.cs =================================================================== diff -u --- Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler.cs (revision 0) +++ Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler.cs (revision b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e) @@ -0,0 +1,69 @@ +// 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.Base; +using Core.Common.Gui; +using Riskeer.Common.Data; +using Riskeer.Common.Data.Structures; +using Riskeer.Common.Service; + +namespace Riskeer.Common.Forms.ChangeHandlers +{ + /// + /// Class for handling a collection of structure calculations when its illustration points need to be cleared. + /// + /// Object type of the structure calculation input. + /// Object type of the structure property of . + public class ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler + : ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase + where TStructureInput : StructuresInputBase, new() + where TStructure : StructureBase + { + private readonly IEnumerable> calculations; + + /// + /// Creates a new instance of . + /// + /// Object responsible for inquiring the required data. + /// The inquiry that is displayed when asking for confirmation to clear the illustration point results. + /// The calculations for which the illustration points should be cleared for. + /// Thrown when any parameter is null. + public ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler(IInquiryHelper inquiryHelper, + string inquiry, + IEnumerable> calculations) + : base(inquiryHelper, inquiry) + { + if (calculations == null) + { + throw new ArgumentNullException(nameof(calculations)); + } + + this.calculations = calculations; + } + + public override IEnumerable ClearIllustrationPoints() + { + return RiskeerCommonDataSynchronizationService.ClearStructuresCalculationIllustrationPoints(calculations); + } + } +} \ No newline at end of file Fisheye: Tag b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e refers to a dead (removed) revision in file `Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearStructureCalculationsIllustrationPointsChangeHandler.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Common/src/Riskeer.Common.Forms/Riskeer.Common.Forms.csproj =================================================================== diff -u -r32e70d7a1e20d6b63a5d3d7fb2593ed77c25800a -rb88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e --- Riskeer/Common/src/Riskeer.Common.Forms/Riskeer.Common.Forms.csproj (.../Riskeer.Common.Forms.csproj) (revision 32e70d7a1e20d6b63a5d3d7fb2593ed77c25800a) +++ Riskeer/Common/src/Riskeer.Common.Forms/Riskeer.Common.Forms.csproj (.../Riskeer.Common.Forms.csproj) (revision b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e) @@ -24,7 +24,7 @@ - + Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsOfStructureCalculationCollectionChangeHandlerTest.cs =================================================================== diff -u --- Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsOfStructureCalculationCollectionChangeHandlerTest.cs (revision 0) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsOfStructureCalculationCollectionChangeHandlerTest.cs (revision b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e) @@ -0,0 +1,150 @@ +// 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 System.Linq; +using Core.Common.Base; +using Core.Common.Gui; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Data.TestUtil.IllustrationPoints; +using Riskeer.Common.Forms.ChangeHandlers; + +namespace Riskeer.Common.Forms.Test.ChangeHandlers +{ + [TestFixture] + public class ClearIllustrationPointsOfStructureCalculationCollectionChangeHandlerTest + { + [Test] + public void Constructor_CalculationsNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var inquiryHelper = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => new ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler( + inquiryHelper, string.Empty, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculations", exception.ParamName); + } + + [Test] + public void Constructor_WithArguments_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var inquiryHelper = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var handler = new ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler( + inquiryHelper, string.Empty, Enumerable.Empty()); + + // Assert + Assert.IsInstanceOf(handler); + } + + [Test] + public void InquireConfirmation_Always_ReturnsInquiry() + { + // Setup + const string inquiry = "An inquiry"; + + var random = new Random(21); + bool expectedConfirmation = random.NextBoolean(); + + var mocks = new MockRepository(); + var inquiryHelper = mocks.StrictMock(); + inquiryHelper.Expect(h => h.InquireContinuation(inquiry)).Return(expectedConfirmation); + mocks.ReplayAll(); + + var handler = new ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler( + inquiryHelper, inquiry, Enumerable.Empty()); + + // Call + bool confirmation = handler.InquireConfirmation(); + + // Assert + Assert.AreEqual(expectedConfirmation, confirmation); + mocks.ReplayAll(); + } + + [Test] + public void ClearIllustrationPoints_Always_ReturnsAffectedCalculations() + { + // Setup + var calculationWithIllustrationPoints = new TestStructuresCalculation + { + Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + }; + + var calculationWithOutput = new TestStructuresCalculation + { + Output = new TestStructuresOutput() + }; + + TestStructuresCalculation[] calculations = + { + new TestStructuresCalculation(), + calculationWithOutput, + calculationWithIllustrationPoints + }; + + var mocks = new MockRepository(); + var inquiryHelper = mocks.StrictMock(); + + var calculationWithIllustrationPointsObserver = mocks.StrictMock(); + calculationWithIllustrationPoints.Attach(calculationWithIllustrationPointsObserver); + + var calculationWithoutIllustrationPointsObserver = mocks.StrictMock(); + calculationWithOutput.Attach(calculationWithoutIllustrationPointsObserver); + mocks.ReplayAll(); + + var handler = new ClearIllustrationPointsOfStructureCalculationCollectionChangeHandler(inquiryHelper, string.Empty, calculations); + + // Call + IEnumerable affectedObjects = handler.ClearIllustrationPoints(); + + // Assert + CollectionAssert.AreEqual(new[] + { + calculationWithIllustrationPoints + }, affectedObjects); + + TestStructuresCalculation[] calculationsWithOutput = + { + calculationWithOutput, + calculationWithIllustrationPoints + }; + Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput)); + Assert.IsTrue(calculationsWithOutput.All(calc => !calc.Output.HasGeneralResult)); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e refers to a dead (removed) revision in file `Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearStructureCalculationsIllustrationPointsChangeHandlerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/Riskeer.Common.Forms.Test.csproj =================================================================== diff -u -r32e70d7a1e20d6b63a5d3d7fb2593ed77c25800a -rb88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e --- Riskeer/Common/test/Riskeer.Common.Forms.Test/Riskeer.Common.Forms.Test.csproj (.../Riskeer.Common.Forms.Test.csproj) (revision 32e70d7a1e20d6b63a5d3d7fb2593ed77c25800a) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/Riskeer.Common.Forms.Test.csproj (.../Riskeer.Common.Forms.Test.csproj) (revision b88dd52963c6e20cbfa0d44bcc3c9d0eaad8cf1e) @@ -46,7 +46,7 @@ - +