Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/HydraulicBoundaryLocationCalculationCommandHandler.cs
===================================================================
diff -u -r9312943e6ef9894811d9b0b87239af47f79205ec -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/HydraulicBoundaryLocationCalculationCommandHandler.cs (.../HydraulicBoundaryLocationCalculationCommandHandler.cs) (revision 9312943e6ef9894811d9b0b87239af47f79205ec)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/HydraulicBoundaryLocationCalculationCommandHandler.cs (.../HydraulicBoundaryLocationCalculationCommandHandler.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -42,40 +42,52 @@
{
private static readonly ILog log = LogManager.GetLogger(typeof(HydraulicBoundaryLocationCalculationCommandHandler));
private readonly IWin32Window viewParent;
- private readonly IAssessmentSection assessmentSection;
///
/// Initializes a new instance of the class.
///
/// The parent of the view.
- /// The assessment section.
- public HydraulicBoundaryLocationCalculationCommandHandler(IWin32Window viewParent, IAssessmentSection assessmentSection)
+ public HydraulicBoundaryLocationCalculationCommandHandler(IWin32Window viewParent)
{
if (viewParent == null)
{
throw new ArgumentNullException("viewParent");
}
- if (assessmentSection == null)
- {
- throw new ArgumentNullException("assessmentSection");
- }
this.viewParent = viewParent;
- this.assessmentSection = assessmentSection;
}
- public void CalculateDesignWaterLevels(IEnumerable locations)
+ public void CalculateDesignWaterLevels(IAssessmentSection assessmentSection,
+ IEnumerable locations)
{
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException("assessmentSection");
+ }
+ if (locations == null)
+ {
+ throw new ArgumentNullException("locations");
+ }
var activities = locations.Select(hbl => new DesignWaterLevelCalculationActivity(assessmentSection, hbl)).ToArray();
- RunActivities(activities);
+ RunActivities(assessmentSection, activities);
}
- public void CalculateWaveHeights(IEnumerable locations)
+ public void CalculateWaveHeights(IAssessmentSection assessmentSection,
+ IEnumerable locations)
{
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException("assessmentSection");
+ }
+ if (locations == null)
+ {
+ throw new ArgumentNullException("locations");
+ }
var activities = locations.Select(hbl => new WaveHeightCalculationActivity(assessmentSection, hbl)).ToArray();
- RunActivities(activities);
+ RunActivities(assessmentSection, activities);
}
- private void RunActivities(IList activities) where TActivity : Activity
+ private void RunActivities(IAssessmentSection assessmentSection,
+ IList activities) where TActivity : Activity
{
var hrdFile = assessmentSection.HydraulicBoundaryDatabase.FilePath;
var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(hrdFile);
@@ -87,7 +99,8 @@
}
else
{
- log.ErrorFormat(Resources.CalculateHydraulicBoundaryLocation_ContextMenuStrip_Start_calculation_failed_0_, validationProblem);
+ log.ErrorFormat(Resources.CalculateHydraulicBoundaryLocation_ContextMenuStrip_Start_calculation_failed_0_,
+ validationProblem);
}
}
}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/IHydraulicBoundaryLocationCalculationCommandHandler.cs
===================================================================
diff -u -r9312943e6ef9894811d9b0b87239af47f79205ec -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/IHydraulicBoundaryLocationCalculationCommandHandler.cs (.../IHydraulicBoundaryLocationCalculationCommandHandler.cs) (revision 9312943e6ef9894811d9b0b87239af47f79205ec)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/IHydraulicBoundaryLocationCalculationCommandHandler.cs (.../IHydraulicBoundaryLocationCalculationCommandHandler.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -19,7 +19,9 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
+using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.HydraRing.Data;
namespace Ringtoets.Integration.Forms.Commands
@@ -33,15 +35,19 @@
///
/// Performs the calculation for all .
///
+ /// The assessment section.
/// The objects to calculate
/// the for.
- void CalculateDesignWaterLevels(IEnumerable locations);
+ /// Thrown when any input argument is null.
+ void CalculateDesignWaterLevels(IAssessmentSection assessmentSection, IEnumerable locations);
///
/// Performs the calculation for all .
///
+ /// The assessment section.
/// The objects to calculate
/// the for.
- void CalculateWaveHeights(IEnumerable locations);
+ /// Thrown when any input argument is null.
+ void CalculateWaveHeights(IAssessmentSection assessmentSection, IEnumerable locations);
}
}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs
===================================================================
diff -u -r6617058bc433d519ff1050ac5fb580b5f06da7ed -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 6617058bc433d519ff1050ac5fb580b5f06da7ed)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/DesignWaterLevelLocationsView.cs (.../DesignWaterLevelLocationsView.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -67,7 +67,7 @@
protected override void HandleCalculateSelectedLocations(IEnumerable locations)
{
- CalculationCommandHandler.CalculateDesignWaterLevels(locations);
+ CalculationCommandHandler.CalculateDesignWaterLevels(AssessmentSection, locations);
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs
===================================================================
diff -u -r6617058bc433d519ff1050ac5fb580b5f06da7ed -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs (.../WaveHeightLocationsView.cs) (revision 6617058bc433d519ff1050ac5fb580b5f06da7ed)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/WaveHeightLocationsView.cs (.../WaveHeightLocationsView.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -67,7 +67,7 @@
protected override void HandleCalculateSelectedLocations(IEnumerable locations)
{
- CalculationCommandHandler.CalculateWaveHeights(locations);
+ CalculationCommandHandler.CalculateWaveHeights(AssessmentSection, locations);
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -r6617058bc433d519ff1050ac5fb580b5f06da7ed -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 6617058bc433d519ff1050ac5fb580b5f06da7ed)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -204,6 +204,7 @@
private RingtoetsRibbon ribbonCommandHandler;
private IAssessmentSectionFromFileCommandHandler assessmentSectionFromFileCommandHandler;
+ private IHydraulicBoundaryLocationCalculationCommandHandler hydraulicBoundaryLocationCalculationCommandHandler;
public override IRibbonCommandHandler RibbonCommandHandler
{
@@ -236,6 +237,7 @@
throw new InvalidOperationException("Gui cannot be null");
}
assessmentSectionFromFileCommandHandler = new AssessmentSectionFromFileCommandHandler(Gui.MainWindow, Gui, Gui.DocumentViewController);
+ hydraulicBoundaryLocationCalculationCommandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(Gui.MainWindow);
ribbonCommandHandler = new RingtoetsRibbon
{
@@ -293,7 +295,7 @@
AfterCreate = (view, context) =>
{
view.ApplicationSelection = Gui;
- view.CalculationCommandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(Gui.MainWindow, context.WrappedData);
+ view.CalculationCommandHandler = hydraulicBoundaryLocationCalculationCommandHandler;
}
};
@@ -305,7 +307,7 @@
AfterCreate = (view, context) =>
{
view.ApplicationSelection = Gui;
- view.CalculationCommandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(Gui.MainWindow, context.WrappedData);
+ view.CalculationCommandHandler = hydraulicBoundaryLocationCalculationCommandHandler;
}
};
@@ -1046,8 +1048,13 @@
RingtoetsCommonFormsResources.CalculateAllIcon,
(sender, args) =>
{
- var command = new HydraulicBoundaryLocationCalculationCommandHandler(Gui.MainWindow, nodeData.WrappedData);
- command.CalculateDesignWaterLevels(nodeData.WrappedData.HydraulicBoundaryDatabase.Locations);
+ if (hydraulicBoundaryLocationCalculationCommandHandler == null || nodeData.WrappedData.HydraulicBoundaryDatabase == null)
+ {
+ return;
+ }
+ hydraulicBoundaryLocationCalculationCommandHandler.CalculateDesignWaterLevels(
+ nodeData.WrappedData,
+ nodeData.WrappedData.HydraulicBoundaryDatabase.Locations);
});
if (nodeData.WrappedData.HydraulicBoundaryDatabase == null)
@@ -1073,8 +1080,13 @@
RingtoetsCommonFormsResources.CalculateAllIcon,
(sender, args) =>
{
- var command = new HydraulicBoundaryLocationCalculationCommandHandler(Gui.MainWindow, nodeData.WrappedData);
- command.CalculateWaveHeights(nodeData.WrappedData.HydraulicBoundaryDatabase.Locations);
+ if (hydraulicBoundaryLocationCalculationCommandHandler == null || nodeData.WrappedData.HydraulicBoundaryDatabase == null)
+ {
+ return;
+ }
+ hydraulicBoundaryLocationCalculationCommandHandler.CalculateWaveHeights(
+ nodeData.WrappedData,
+ nodeData.WrappedData.HydraulicBoundaryDatabase.Locations);
});
if (nodeData.WrappedData.HydraulicBoundaryDatabase == null)
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/HydraulicBoundaryLocationCommandHandlerTest.cs
===================================================================
diff -u -r9312943e6ef9894811d9b0b87239af47f79205ec -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/HydraulicBoundaryLocationCommandHandlerTest.cs (.../HydraulicBoundaryLocationCommandHandlerTest.cs) (revision 9312943e6ef9894811d9b0b87239af47f79205ec)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/HydraulicBoundaryLocationCommandHandlerTest.cs (.../HydraulicBoundaryLocationCommandHandlerTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -52,44 +52,55 @@
[Test]
public void Constructor_NullMainWindow_ThrowsArgumentNullException()
{
- // Setup
- var assessmentSectionMock = mockRepository.StrictMock();
- mockRepository.ReplayAll();
+ // Setup & Call
+ TestDelegate test = () => new HydraulicBoundaryLocationCalculationCommandHandler(null);
- // Call
- TestDelegate test = () => new HydraulicBoundaryLocationCalculationCommandHandler(null, assessmentSectionMock);
-
// Assert
string paramName = Assert.Throws(test).ParamName;
const string expectedParamName = "viewParent";
Assert.AreEqual(expectedParamName, paramName);
- mockRepository.VerifyAll();
}
[Test]
- public void Constructor_NullIAssessmentSection_ThrowsArgumentNullException()
+ public void DefaultConstructor_DefaultValues()
{
// Setup & Call
- TestDelegate test = () => new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), null);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
// Assert
+ Assert.IsInstanceOf(commandHandler);
+ }
+
+ [Test]
+ public void CalculateDesignWaterLevels_NullIAssessmentSection_ThrowsArgumentNullException()
+ {
+ // Setup
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
+ var locations = Enumerable.Empty();
+
+ TestDelegate test = () => commandHandler.CalculateDesignWaterLevels(null, locations);
+
+ // Assert
string paramName = Assert.Throws(test).ParamName;
const string expectedParamName = "assessmentSection";
Assert.AreEqual(expectedParamName, paramName);
}
[Test]
- public void DefaultConstructor_DefaultValues()
+ public void CalculateDesignWaterLevels_NullLocations_ThrowsArgumentNullException()
{
// Setup
var assessmentSectionMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
- // Call
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
+ TestDelegate test = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, null);
+
// Assert
- Assert.IsInstanceOf(commandHandler);
+ string paramName = Assert.Throws(test).ParamName;
+ const string expectedParamName = "locations";
+ Assert.AreEqual(expectedParamName, paramName);
mockRepository.VerifyAll();
}
@@ -107,13 +118,13 @@
var observerMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
var locations = Enumerable.Empty();
hydraulicBoundaryDatabase.Attach(observerMock);
// Call
- Action call = () => commandHandler.CalculateDesignWaterLevels(locations);
+ Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations);
// Assert
TestHelper.AssertLogMessages(call, messages =>
@@ -141,7 +152,7 @@
observerMock.Expect(o => o.UpdateObserver());
mockRepository.ReplayAll();
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
var locations = Enumerable.Empty();
hydraulicBoundaryDatabase.Attach(observerMock);
@@ -152,7 +163,7 @@
};
// Call
- Action call = () => commandHandler.CalculateDesignWaterLevels(locations);
+ Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations);
// Assert
TestHelper.AssertLogMessagesCount(call, 0);
@@ -193,10 +204,10 @@
// Expect an activity dialog which is automatically closed
};
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
// Call
- Action call = () => commandHandler.CalculateDesignWaterLevels(locations);
+ Action call = () => commandHandler.CalculateDesignWaterLevels(assessmentSectionMock, locations);
// Assert
TestHelper.AssertLogMessages(call, messages =>
@@ -214,10 +225,43 @@
}
[Test]
- public void CalculateWaveHeight_HydraulicDatabaseDoesNotExist_LogsErrorAndDoesNotNotifyObservers()
+ public void CalculateWaveHeights_NullIAssessmentSection_ThrowsArgumentNullException()
{
// Setup
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
+ var locations = Enumerable.Empty();
+
+ TestDelegate test = () => commandHandler.CalculateWaveHeights(null, locations);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ const string expectedParamName = "assessmentSection";
+ Assert.AreEqual(expectedParamName, paramName);
+ }
+
+ [Test]
+ public void CalculateWaveHeights_NullLocations_ThrowsArgumentNullException()
+ {
+ // Setup
var assessmentSectionMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
+
+ TestDelegate test = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ const string expectedParamName = "locations";
+ Assert.AreEqual(expectedParamName, paramName);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void CalculateWaveHeights_HydraulicDatabaseDoesNotExist_LogsErrorAndDoesNotNotifyObservers()
+ {
+ // Setup
+ var assessmentSectionMock = mockRepository.StrictMock();
var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
{
FilePath = "Does not exist"
@@ -227,13 +271,13 @@
var observerMock = mockRepository.StrictMock();
mockRepository.ReplayAll();
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
var locations = Enumerable.Empty();
hydraulicBoundaryDatabase.Attach(observerMock);
// Call
- Action call = () => commandHandler.CalculateWaveHeights(locations);
+ Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations);
// Assert
TestHelper.AssertLogMessages(call, messages =>
@@ -261,7 +305,7 @@
observerMock.Expect(o => o.UpdateObserver());
mockRepository.ReplayAll();
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
var locations = Enumerable.Empty();
hydraulicBoundaryDatabase.Attach(observerMock);
@@ -272,7 +316,7 @@
};
// Call
- Action call = () => commandHandler.CalculateWaveHeights(locations);
+ Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations);
// Assert
TestHelper.AssertLogMessagesCount(call, 0);
@@ -313,10 +357,10 @@
// Expect an activity dialog which is automatically closed
};
- var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form(), assessmentSectionMock);
+ var commandHandler = new HydraulicBoundaryLocationCalculationCommandHandler(new Form());
// Call
- Action call = () => commandHandler.CalculateWaveHeights(locations);
+ Action call = () => commandHandler.CalculateWaveHeights(assessmentSectionMock, locations);
// Assert
TestHelper.AssertLogMessages(call, messages =>
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs
===================================================================
diff -u -r35040098e742ca7a772fc7504167fb2e5773fabf -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 35040098e742ca7a772fc7504167fb2e5773fabf)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/DesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../DesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -28,6 +28,7 @@
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.TestUtil.ContextMenu;
using Core.Common.TestUtil;
using NUnit.Extensions.Forms;
@@ -228,6 +229,7 @@
}
[Test]
+ [RequiresSTA]
public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingAssessmentLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected()
{
// Given
@@ -261,13 +263,15 @@
{
guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub());
+ guiMock.Expect(g => g.DocumentViewController).Return(mockRepository.Stub());
mockRepository.ReplayAll();
using (var plugin = new RingtoetsPlugin())
{
TreeNodeInfo info = GetInfo(plugin);
plugin.Gui = guiMock;
+ plugin.Activate();
ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl);
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs
===================================================================
diff -u -r35040098e742ca7a772fc7504167fb2e5773fabf -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 35040098e742ca7a772fc7504167fb2e5773fabf)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/TreeNodeInfos/WaveHeightLocationsContextTreeNodeInfoTest.cs (.../WaveHeightLocationsContextTreeNodeInfoTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -28,6 +28,7 @@
using Core.Common.Gui;
using Core.Common.Gui.ContextMenu;
using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.TestUtil.ContextMenu;
using Core.Common.TestUtil;
using NUnit.Extensions.Forms;
@@ -278,6 +279,7 @@
}
[Test]
+ [RequiresSTA]
public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingWaveHeightFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected()
{
// Given
@@ -311,13 +313,15 @@
{
guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub());
+ guiMock.Expect(g => g.DocumentViewController).Return(mockRepository.Stub());
mockRepository.ReplayAll();
using (var plugin = new RingtoetsPlugin())
{
TreeNodeInfo info = GetInfo(plugin);
plugin.Gui = guiMock;
+ plugin.Activate();
ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl);
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs
===================================================================
diff -u -r6617058bc433d519ff1050ac5fb580b5f06da7ed -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 6617058bc433d519ff1050ac5fb580b5f06da7ed)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/DesignWaterLevelLocationsViewTest.cs (.../DesignWaterLevelLocationsViewTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -380,7 +380,7 @@
{
// Setup
DesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView();
-
+ IAssessmentSection assessmentSection = (IAssessmentSection) view.Data;
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
var rows = dataGridView.Rows;
rows[0].Cells[locationCalculateColumnIndex].Value = true;
@@ -389,8 +389,8 @@
var commandHandlerMock = mockRepository.StrictMock();
IEnumerable locations = null;
- commandHandlerMock.Expect(ch => ch.CalculateDesignWaterLevels(null)).IgnoreArguments().WhenCalled(
- invocation => { locations = (IEnumerable) invocation.Arguments[0]; });
+ commandHandlerMock.Expect(ch => ch.CalculateDesignWaterLevels(assessmentSection, null)).IgnoreArguments().WhenCalled(
+ invocation => { locations = (IEnumerable) invocation.Arguments[1]; });
mockRepository.ReplayAll();
view.CalculationCommandHandler = commandHandlerMock;
@@ -402,7 +402,7 @@
// Assert
var hydraulicBoundaryLocations = locations.ToArray();
Assert.AreEqual(1, hydraulicBoundaryLocations.Length);
- HydraulicBoundaryLocation expectedLocation = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase.Locations.First();
+ HydraulicBoundaryLocation expectedLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First();
Assert.AreEqual(expectedLocation, hydraulicBoundaryLocations.First());
mockRepository.VerifyAll();
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs
===================================================================
diff -u -r6617058bc433d519ff1050ac5fb580b5f06da7ed -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 6617058bc433d519ff1050ac5fb580b5f06da7ed)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/WaveHeightLocationsViewTest.cs (.../WaveHeightLocationsViewTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -376,7 +376,7 @@
{
// Setup
WaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView();
-
+ IAssessmentSection assessmentSection = (IAssessmentSection) view.Data;
var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject;
var rows = dataGridView.Rows;
rows[0].Cells[locationCalculateColumnIndex].Value = true;
@@ -385,8 +385,8 @@
var commandHandlerMock = mockRepository.StrictMock();
IEnumerable locations = null;
- commandHandlerMock.Expect(ch => ch.CalculateWaveHeights(null)).IgnoreArguments().WhenCalled(
- invocation => { locations = (IEnumerable) invocation.Arguments[0]; });
+ commandHandlerMock.Expect(ch => ch.CalculateWaveHeights(assessmentSection, null)).IgnoreArguments().WhenCalled(
+ invocation => { locations = (IEnumerable) invocation.Arguments[1]; });
mockRepository.ReplayAll();
view.CalculationCommandHandler = commandHandlerMock;
@@ -398,7 +398,7 @@
// Assert
var hydraulicBoundaryLocations = locations.ToArray();
Assert.AreEqual(1, hydraulicBoundaryLocations.Length);
- HydraulicBoundaryLocation expectedLocation = ((IAssessmentSection) view.Data).HydraulicBoundaryDatabase.Locations.First();
+ HydraulicBoundaryLocation expectedLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First();
Assert.AreEqual(expectedLocation, hydraulicBoundaryLocations.First());
mockRepository.VerifyAll();
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs
===================================================================
diff -u -r0abf371c5f6f450232d49f3c1a031476063ce04b -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 0abf371c5f6f450232d49f3c1a031476063ce04b)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -544,7 +544,7 @@
var mainWindowMock = mockRepository.StrictMock();
var documentViewControllerMock = mockRepository.StrictMock();
var guiMock = mockRepository.StrictMock();
- guiMock.Expect(g => g.MainWindow).Return(mainWindowMock);
+ guiMock.Expect(g => g.MainWindow).Return(mainWindowMock).Repeat.AtLeastOnce();
guiMock.Expect(g => g.DocumentViewController).Return(documentViewControllerMock);
guiMock.Expect(g => g.ProjectOpened += null).IgnoreArguments();
guiMock.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs
===================================================================
diff -u -r9312943e6ef9894811d9b0b87239af47f79205ec -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 9312943e6ef9894811d9b0b87239af47f79205ec)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/DesignWaterLevelLocationsViewInfoTest.cs (.../DesignWaterLevelLocationsViewInfoTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -23,6 +23,7 @@
using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.Plugin;
using Core.Common.TestUtil;
using NUnit.Framework;
@@ -122,6 +123,7 @@
}
[Test]
+ [RequiresSTA]
public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView()
{
// Setup
@@ -134,6 +136,7 @@
guiStub.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub());
guiStub.Stub(g => g.MainWindow).Return(mocks.Stub());
+ guiStub.Stub(g => g.DocumentViewController).Return(mocks.Stub());
mocks.ReplayAll();
@@ -145,6 +148,7 @@
{
info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(DesignWaterLevelLocationsView));
ringtoetsPlugin.Gui = guiStub;
+ ringtoetsPlugin.Activate();
// Call
info.AfterCreate(view, context);
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs
===================================================================
diff -u -r9312943e6ef9894811d9b0b87239af47f79205ec -r7a61196d689922cf6df102fb0d81c43267c7b22b
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 9312943e6ef9894811d9b0b87239af47f79205ec)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveHeightLocationsViewInfoTest.cs (.../WaveHeightLocationsViewInfoTest.cs) (revision 7a61196d689922cf6df102fb0d81c43267c7b22b)
@@ -23,6 +23,7 @@
using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.Forms.ViewHost;
using Core.Common.Gui.Plugin;
using Core.Common.TestUtil;
using NUnit.Framework;
@@ -122,6 +123,7 @@
}
[Test]
+ [RequiresSTA]
public void AfterCreate_WithGuiSet_SetsSpecificPropertiesToView()
{
// Setup
@@ -134,6 +136,7 @@
guiStub.Stub(g => g.ProjectOpened -= null).IgnoreArguments();
guiStub.Stub(g => g.ViewCommands).Return(mocks.Stub());
guiStub.Stub(g => g.MainWindow).Return(mocks.Stub());
+ guiStub.Stub(g => g.DocumentViewController).Return(mocks.Stub());
mocks.ReplayAll();
@@ -145,6 +148,7 @@
{
info = ringtoetsPlugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveHeightLocationsView));
ringtoetsPlugin.Gui = guiStub;
+ ringtoetsPlugin.Activate();
// Call
info.AfterCreate(view, context);