Index: Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfCalculationChangeHandlerBase.cs
===================================================================
diff -u -rddad7117cf82255493a1a9f80b2c6562dc88bfd2 -rac1f2783374452894d0c337a594152174ff099de
--- Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfCalculationChangeHandlerBase.cs (.../ClearIllustrationPointsOfCalculationChangeHandlerBase.cs) (revision ddad7117cf82255493a1a9f80b2c6562dc88bfd2)
+++ Riskeer/Common/src/Riskeer.Common.Forms/ChangeHandlers/ClearIllustrationPointsOfCalculationChangeHandlerBase.cs (.../ClearIllustrationPointsOfCalculationChangeHandlerBase.cs) (revision ac1f2783374452894d0c337a594152174ff099de)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using Core.Common.Gui.Commands;
using Core.Common.Gui.Helpers;
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Forms.Properties;
@@ -34,29 +35,35 @@
where TCalculation : ICalculation
{
private readonly IInquiryHelper inquiryHelper;
- protected TCalculation Calculation;
///
/// Creates a new instance of .
///
/// The calculation to clear the illustration points for.
/// Object responsible for inquiring confirmation.
+ /// The view commands used to close views for the illustration points.
/// Thrown when any argument is null.
protected ClearIllustrationPointsOfCalculationChangeHandlerBase(
- TCalculation calculation, IInquiryHelper inquiryHelper)
+ TCalculation calculation, IInquiryHelper inquiryHelper, IViewCommands viewCommands)
{
if (inquiryHelper == null)
{
throw new ArgumentNullException(nameof(inquiryHelper));
}
+ if (viewCommands == null)
+ {
+ throw new ArgumentNullException(nameof(viewCommands));
+ }
+
if (calculation == null)
{
throw new ArgumentNullException(nameof(calculation));
}
this.inquiryHelper = inquiryHelper;
Calculation = calculation;
+ ViewCommands = viewCommands;
}
public bool InquireConfirmation()
@@ -70,5 +77,15 @@
{
Calculation.NotifyObservers();
}
+
+ ///
+ /// Gets the .
+ ///
+ protected TCalculation Calculation { get; }
+
+ ///
+ /// Gets the .
+ ///
+ protected IViewCommands ViewCommands { get; }
}
}
\ No newline at end of file
Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsOfCalculationChangeHandlerBaseTest.cs
===================================================================
diff -u -rddad7117cf82255493a1a9f80b2c6562dc88bfd2 -rac1f2783374452894d0c337a594152174ff099de
--- Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsOfCalculationChangeHandlerBaseTest.cs (.../ClearIllustrationPointsOfCalculationChangeHandlerBaseTest.cs) (revision ddad7117cf82255493a1a9f80b2c6562dc88bfd2)
+++ Riskeer/Common/test/Riskeer.Common.Forms.Test/ChangeHandlers/ClearIllustrationPointsOfCalculationChangeHandlerBaseTest.cs (.../ClearIllustrationPointsOfCalculationChangeHandlerBaseTest.cs) (revision ac1f2783374452894d0c337a594152174ff099de)
@@ -21,6 +21,7 @@
using System;
using Core.Common.Base;
+using Core.Common.Gui.Commands;
using Core.Common.Gui.Helpers;
using NUnit.Framework;
using Rhino.Mocks;
@@ -38,10 +39,11 @@
// Setup
var mocks = new MockRepository();
var inquiryHelper = mocks.Stub();
+ var viewCommands = mocks.Stub();
mocks.ReplayAll();
// Call
- void Call() => new TestClearIllustrationPointsOfCalculationChangeHandler(null, inquiryHelper);
+ void Call() => new TestClearIllustrationPointsOfCalculationChangeHandler(null, inquiryHelper, viewCommands);
// Assert
var exception = Assert.Throws(Call);
@@ -52,24 +54,48 @@
[Test]
public void Constructor_InquiryHelperNull_ThrowsArgumentNullException()
{
+ // Setup
+ var mocks = new MockRepository();
+ var viewCommands = mocks.Stub();
+ mocks.ReplayAll();
+
// Call
- void Call() => new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), null);
+ void Call() => new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), null, viewCommands);
// Assert
var exception = Assert.Throws(Call);
Assert.AreEqual("inquiryHelper", exception.ParamName);
+ mocks.VerifyAll();
}
[Test]
+ public void Constructor_ViewCommandsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var inquiryHelper = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), inquiryHelper, null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("viewCommands", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Constructor_WithArguments_ExpectedValues()
{
// Setup
var mocks = new MockRepository();
var inquiryHelper = mocks.Stub();
+ var viewCommands = mocks.Stub();
mocks.ReplayAll();
// Call
- var handler = new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), inquiryHelper);
+ var handler = new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), inquiryHelper, viewCommands);
// Assert
Assert.IsInstanceOf(handler);
@@ -87,9 +113,10 @@
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
inquiryHelper.Expect(h => h.InquireContinuation(expectedInquiry)).Return(expectedConfirmation);
+ var viewCommands = mocks.Stub();
mocks.ReplayAll();
- var handler = new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), inquiryHelper);
+ var handler = new TestClearIllustrationPointsOfCalculationChangeHandler(new TestCalculation(), inquiryHelper, viewCommands);
// Call
bool confirmation = handler.InquireConfirmation();
@@ -105,14 +132,15 @@
// Setup
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
+ var viewCommands = mocks.Stub();
var observer = mocks.StrictMock();
observer.Expect(o => o.UpdateObserver());
mocks.ReplayAll();
var calculation = new TestCalculation();
calculation.Attach(observer);
- var handler = new TestClearIllustrationPointsOfCalculationChangeHandler(calculation, inquiryHelper);
+ var handler = new TestClearIllustrationPointsOfCalculationChangeHandler(calculation, inquiryHelper, viewCommands);
// Call
handler.DoPostUpdateActions();
@@ -123,8 +151,8 @@
private class TestClearIllustrationPointsOfCalculationChangeHandler : ClearIllustrationPointsOfCalculationChangeHandlerBase
{
- public TestClearIllustrationPointsOfCalculationChangeHandler(TestCalculation calculation, IInquiryHelper inquiryHelper)
- : base(calculation, inquiryHelper) {}
+ public TestClearIllustrationPointsOfCalculationChangeHandler(TestCalculation calculation, IInquiryHelper inquiryHelper, IViewCommands viewCommands)
+ : base(calculation, inquiryHelper, viewCommands) {}
public override bool ClearIllustrationPoints()
{