Index: Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBase.cs =================================================================== diff -u --- Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBase.cs (revision 0) +++ Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBase.cs (revision 0b438fd8b8d8bee82908046923367b11f10219d7) @@ -0,0 +1,65 @@ +// 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.Commands; +using Core.Common.Gui.Helpers; + +namespace Riskeer.Common.Forms.ChangeHandlers +{ + /// + /// Base class for handling clearing illustration points and closing views from collections of calculations. + /// + public abstract class ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBase : ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase + { + private readonly IViewCommands viewCommands; + + /// + /// Creates a new instance of . + /// + /// Object responsible for inquiring confirmation. + /// The view commands used to close views for the illustration points. + /// Thrown when any parameter is null. + protected ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBase( + IInquiryHelper inquiryHelper, IViewCommands viewCommands) : base(inquiryHelper) + { + if (viewCommands == null) + { + throw new ArgumentNullException(nameof(viewCommands)); + } + + this.viewCommands = viewCommands; + } + + public override IEnumerable ClearIllustrationPoints() + { + CloseView(viewCommands); + + return PerformClearIllustrationPoints(); + } + + protected abstract IEnumerable PerformClearIllustrationPoints(); + + protected abstract void CloseView(IViewCommands viewCommands); + } +} \ No newline at end of file Index: Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase.cs =================================================================== diff -u -re9b8aa3e972b9f07a3201f143c26de0e3f082d49 -r0b438fd8b8d8bee82908046923367b11f10219d7 --- Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase.cs (.../ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase.cs) (revision e9b8aa3e972b9f07a3201f143c26de0e3f082d49) +++ Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase.cs (.../ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase.cs) (revision 0b438fd8b8d8bee82908046923367b11f10219d7) @@ -38,7 +38,7 @@ /// Creates a new instance of . /// /// Object responsible for inquiring confirmation. - /// Thrown when any parameter is null. + /// Thrown when is null. protected ClearIllustrationPointsOfCalculationCollectionChangeHandlerBase(IInquiryHelper inquiryHelper) { if (inquiryHelper == null) Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBaseTest.cs =================================================================== diff -u --- Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBaseTest.cs (revision 0) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBaseTest.cs (revision 0b438fd8b8d8bee82908046923367b11f10219d7) @@ -0,0 +1,93 @@ +// 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.Commands; +using Core.Common.Gui.Helpers; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Forms.ChangeHandlers; + +namespace Riskeer.Common.Forms.Test.ChangeHandlers +{ + [TestFixture] + public class ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBaseTest + { + [Test] + public void Constructor_ViewCommandsNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var inquiryHelper = mocks.Stub(); + mocks.ReplayAll(); + + // Call + void Call() => new TestClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandler(inquiryHelper, null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("viewCommands", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var inquiryHelper = mocks.Stub(); + var viewCommands = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var changeHandler = new TestClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandler( + inquiryHelper, viewCommands); + + // Assert + Assert.IsInstanceOf(changeHandler); + mocks.VerifyAll(); + } + + private class TestClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandler : ClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandlerBase + { + public TestClearIllustrationPointsAndCloseViewOfCalculationCollectionChangeHandler( + IInquiryHelper inquiryHelper, IViewCommands viewCommands) + : base(inquiryHelper, viewCommands) {} + + protected override string GetConfirmationMessage() + { + throw new NotImplementedException(); + } + + protected override IEnumerable PerformClearIllustrationPoints() + { + throw new NotImplementedException(); + } + + protected override void CloseView(IViewCommands viewCommands) + { + throw new NotImplementedException(); + } + } + } +} \ No newline at end of file