Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsDesignWaterLevelLocationsContext.cs
===================================================================
diff -u -r75ac52f6f7e203e77dd212e6c32d68e7e58c28b2 -r3923884225f5ae288c5b78738ebd37f935c97095
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsDesignWaterLevelLocationsContext.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContext.cs) (revision 75ac52f6f7e203e77dd212e6c32d68e7e58c28b2)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PresentationObjects/GrassCoverErosionOutwardsDesignWaterLevelLocationsContext.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContext.cs) (revision 3923884225f5ae288c5b78738ebd37f935c97095)
@@ -31,29 +31,29 @@
/// Presentation object for all data required to configure an enumeration of
/// for water level at intersection probability calculations.
///
- public class GrassCoverErosionOutwardsDesignWaterLevelLocationsContext : ObservableWrappedObjectContextBase
+ public class GrassCoverErosionOutwardsDesignWaterLevelLocationsContext : ObservableWrappedObjectContextBase>
{
///
/// Creates a new instance of .
///
- /// The which the
+ /// The which the
/// belongs to.
/// The grass cover erosion outwards hydraulic boundary locations for this context.
/// Thrown when any input parameter is null.
- public GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(IAssessmentSection wrappedAssessmentSection,
+ public GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(IAssessmentSection assessmentSection,
ObservableList grassCoverErosionOutwardsHydraulicBoundaryLocations)
- : base(wrappedAssessmentSection)
+ : base(grassCoverErosionOutwardsHydraulicBoundaryLocations)
{
- if (grassCoverErosionOutwardsHydraulicBoundaryLocations == null)
+ if (assessmentSection == null)
{
- throw new ArgumentNullException("grassCoverErosionOutwardsHydraulicBoundaryLocations");
+ throw new ArgumentNullException("assessmentSection");
}
- Locations = grassCoverErosionOutwardsHydraulicBoundaryLocations;
+ AssessmentSection = assessmentSection;
}
///
- /// Gets the grass cover erosion outwards hydraulic boundary locations.
+ /// Gets the assessment section.
///
- public ObservableList Locations { get; private set; }
+ public IAssessmentSection AssessmentSection { get; private set; }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs
===================================================================
diff -u -r75ac52f6f7e203e77dd212e6c32d68e7e58c28b2 -r3923884225f5ae288c5b78738ebd37f935c97095
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 75ac52f6f7e203e77dd212e6c32d68e7e58c28b2)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 3923884225f5ae288c5b78738ebd37f935c97095)
@@ -59,7 +59,7 @@
};
yield return new PropertyInfo
{
- GetObjectPropertiesData = context => context.Locations
+ GetObjectPropertiesData = context => context.WrappedData
};
yield return new PropertyInfo
{
@@ -116,7 +116,7 @@
{
Text = context => Resources.GrassCoverErosionOutwardsWaterLevelLocationsContext_DisplayName,
Image = context => RingtoetsCommonFormsResources.GenericInputOutputIcon,
- ForeColor = context => context.WrappedData.HydraulicBoundaryDatabase == null ?
+ ForeColor = context => context.AssessmentSection.HydraulicBoundaryDatabase == null ?
Color.FromKnownColor(KnownColor.GrayText) :
Color.FromKnownColor(KnownColor.ControlText),
ContextMenuStrip = GrassCoverErosionOutwardsWaterLevelLocationsContextMenuStrip
@@ -269,21 +269,26 @@
return;
}
- IAssessmentSection assessmentSection = nodeData.WrappedData;
- GrassCoverErosionOutwardsFailureMechanism failureMechanism = assessmentSection.GetFailureMechanisms().OfType().First();
+ IAssessmentSection assessmentSection = nodeData.AssessmentSection;
+ GrassCoverErosionOutwardsFailureMechanism failureMechanism = assessmentSection.GetFailureMechanisms().OfType().FirstOrDefault();
+ if (failureMechanism == null)
+ {
+ return;
+ }
+
var correctedNormFactor = assessmentSection.FailureMechanismContribution.Norm*
(failureMechanism.Contribution/100)/
failureMechanism.GeneralInput.N;
hydraulicBoundaryLocationCalculationGuiService.CalculateDesignWaterLevels(
assessmentSection.HydraulicBoundaryDatabase.FilePath,
- failureMechanism.GrassCoverErosionOutwardsHydraulicBoundaryLocations,
- failureMechanism.GrassCoverErosionOutwardsHydraulicBoundaryLocations,
+ nodeData.WrappedData,
+ nodeData.WrappedData,
assessmentSection.Id,
correctedNormFactor);
});
- if (nodeData.WrappedData.HydraulicBoundaryDatabase == null)
+ if (nodeData.AssessmentSection.HydraulicBoundaryDatabase == null)
{
designWaterLevelItem.Enabled = false;
designWaterLevelItem.ToolTipText = Resources.GrassCoverErosionOutwardsWaterLevelLocation_No_HRD_To_Calculate;
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTest.cs
===================================================================
diff -u -r75ac52f6f7e203e77dd212e6c32d68e7e58c28b2 -r3923884225f5ae288c5b78738ebd37f935c97095
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTest.cs) (revision 75ac52f6f7e203e77dd212e6c32d68e7e58c28b2)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PresentationObjects/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTest.cs) (revision 3923884225f5ae288c5b78738ebd37f935c97095)
@@ -46,14 +46,14 @@
var presentationObject = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(assessmentSectionMock, locations);
// Assert
- Assert.IsInstanceOf>(presentationObject);
- Assert.AreSame(assessmentSectionMock, presentationObject.WrappedData);
- Assert.AreSame(locations, presentationObject.Locations);
+ Assert.IsInstanceOf>>(presentationObject);
+ Assert.AreSame(assessmentSectionMock, presentationObject.AssessmentSection);
+ Assert.AreSame(locations, presentationObject.WrappedData);
mockRepository.VerifyAll();
}
[Test]
- public void Constructor_GrassCoverErosionOutwardsHydraulicBoundaryLocationsIsNull_ThrowsArgumentNullException()
+ public void Constructor_AssessmentSectionIsNull_ThrowsArgumentNullException()
{
// Setup
var mocks = new MockRepository();
@@ -65,7 +65,7 @@
// Assert
var paramName = Assert.Throws(call).ParamName;
- Assert.AreEqual("grassCoverErosionOutwardsHydraulicBoundaryLocations", paramName);
+ Assert.AreEqual("assessmentSection", paramName);
}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs
===================================================================
diff -u -r75ac52f6f7e203e77dd212e6c32d68e7e58c28b2 -r3923884225f5ae288c5b78738ebd37f935c97095
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 75ac52f6f7e203e77dd212e6c32d68e7e58c28b2)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest.cs) (revision 3923884225f5ae288c5b78738ebd37f935c97095)
@@ -19,18 +19,25 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Core.Common.Base;
+using Core.Common.Base.Data;
using Core.Common.Controls.TreeView;
using Core.Common.Gui;
using Core.Common.Gui.Commands;
using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.TestUtil.ContextMenu;
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
using Ringtoets.GrassCoverErosionOutwards.Data;
using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects;
using Ringtoets.GrassCoverErosionOutwards.Forms.Properties;
@@ -44,46 +51,39 @@
[TestFixture]
public class GrassCoverErosionOutwardsDesignWaterLevelLocationsContextTreeNodeInfoTest
{
+ private const int contextMenuRunDesignWaterLevelCalculationsIndex = 0;
private MockRepository mockRepository;
- private GrassCoverErosionOutwardsPlugin plugin;
- private TreeNodeInfo info;
[SetUp]
public void SetUp()
{
mockRepository = new MockRepository();
- plugin = new GrassCoverErosionOutwardsPlugin();
- info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionOutwardsDesignWaterLevelLocationsContext));
}
- [TearDown]
- public void TearDown()
- {
- plugin.Dispose();
- mockRepository.VerifyAll();
- }
-
[Test]
public void Initialized_Always_ExpectedPropertiesSet()
{
// Setup
- mockRepository.ReplayAll();
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- // Assert
- Assert.AreEqual(typeof(GrassCoverErosionOutwardsDesignWaterLevelLocationsContext), info.TagType);
+ // Assert
+ Assert.AreEqual(typeof(GrassCoverErosionOutwardsDesignWaterLevelLocationsContext), info.TagType);
- Assert.IsNull(info.EnsureVisibleOnCreate);
- Assert.IsNull(info.CanRename);
- Assert.IsNull(info.OnNodeRenamed);
- Assert.IsNull(info.CanRemove);
- Assert.IsNull(info.OnNodeRemoved);
- Assert.IsNull(info.CanCheck);
- Assert.IsNull(info.IsChecked);
- Assert.IsNull(info.OnNodeChecked);
- Assert.IsNull(info.CanDrag);
- Assert.IsNull(info.CanDrop);
- Assert.IsNull(info.CanInsert);
- Assert.IsNull(info.OnDrop);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
}
[Test]
@@ -96,11 +96,17 @@
assessmentSectionMock,
new ObservableList());
- // Call
- string nodeText = info.Text(context);
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- // Assert
- Assert.AreEqual("Waterstand bij doorsnede-eis", nodeText);
+ // Call
+ string nodeText = info.Text(context);
+
+ // Assert
+ Assert.AreEqual("Waterstand bij doorsnede-eis", nodeText);
+ }
+ mockRepository.VerifyAll();
}
[Test]
@@ -112,12 +118,17 @@
var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
assessmentSectionMock,
new ObservableList());
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- // Call
- Image icon = info.Image(context);
+ // Call
+ Image icon = info.Image(context);
- // Assert
- TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, icon);
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, icon);
+ }
+ mockRepository.VerifyAll();
}
[Test]
@@ -128,29 +139,34 @@
using (var treeViewControl = new TreeViewControl())
{
- var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
- assessmentSectionMock,
- new ObservableList());
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- var menuBuilder = mockRepository.StrictMock();
- menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
- menuBuilder.Expect(mb => mb.Build()).Return(null);
+ var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
+ assessmentSectionMock,
+ new ObservableList());
- var gui = mockRepository.StrictMock();
- gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
+ var menuBuilder = mockRepository.StrictMock();
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
- mockRepository.ReplayAll();
+ var gui = mockRepository.StrictMock();
+ gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
- plugin.Gui = gui;
+ mockRepository.ReplayAll();
- // Call
- info.ContextMenuStrip(context, null, treeViewControl);
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(context, null, treeViewControl);
+ }
}
// Assert
- // Part of TearDown
+ mockRepository.VerifyAll();
}
[Test]
@@ -166,40 +182,46 @@
using (var treeViewControl = new TreeViewControl())
{
- var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
- assessmentSectionMock,
- new ObservableList());
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
- importCommandHandler,
- exportCommandHandler,
- viewCommandsHandler,
- context,
- treeViewControl);
+ var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
+ assessmentSectionMock,
+ new ObservableList());
- var gui = mockRepository.StrictMock();
- gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
+ importCommandHandler,
+ exportCommandHandler,
+ viewCommandsHandler,
+ context,
+ treeViewControl);
- mockRepository.ReplayAll();
+ var gui = mockRepository.StrictMock();
+ gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
- plugin.Gui = gui;
+ mockRepository.ReplayAll();
- // Call
- ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl);
+ plugin.Gui = gui;
- // Assert
- Assert.AreEqual(3, menu.Items.Count);
+ // Call
+ ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl);
- TestHelper.AssertContextMenuStripContainsItem(menu, 0, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All,
- Resources.GrassCoverErosionOutwardsWaterLevelLocation_No_HRD_To_Calculate, RingtoetsCommonFormsResources.CalculateAllIcon, false);
- TestHelper.AssertContextMenuStripContainsItem(menu, 2, CoreCommonGuiResources.Properties,
- CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesHS, false);
+ // Assert
+ Assert.AreEqual(3, menu.Items.Count);
- CollectionAssert.AllItemsAreInstancesOfType(new[]
- {
- menu.Items[1],
- }, typeof(ToolStripSeparator));
+ TestHelper.AssertContextMenuStripContainsItem(menu, 0, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All,
+ Resources.GrassCoverErosionOutwardsWaterLevelLocation_No_HRD_To_Calculate, RingtoetsCommonFormsResources.CalculateAllIcon, false);
+ TestHelper.AssertContextMenuStripContainsItem(menu, 2, CoreCommonGuiResources.Properties,
+ CoreCommonGuiResources.Properties_ToolTip, CoreCommonGuiResources.PropertiesHS, false);
+
+ CollectionAssert.AllItemsAreInstancesOfType(new[]
+ {
+ menu.Items[1],
+ }, typeof(ToolStripSeparator));
+ }
}
+ mockRepository.VerifyAll();
}
[Test]
@@ -216,38 +238,44 @@
using (var treeViewControl = new TreeViewControl())
{
- var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
- assessmentSectionMock,
- new ObservableList());
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
- importCommandHandler,
- exportCommandHandler,
- viewCommandsHandler,
- context,
- treeViewControl);
+ var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(
+ assessmentSectionMock,
+ new ObservableList());
- var gui = mockRepository.StrictMock();
- gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
+ importCommandHandler,
+ exportCommandHandler,
+ viewCommandsHandler,
+ context,
+ treeViewControl);
- mockRepository.ReplayAll();
+ var gui = mockRepository.StrictMock();
+ gui.Expect(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
- plugin.Gui = gui;
+ mockRepository.ReplayAll();
- // Call
- ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl);
+ plugin.Gui = gui;
- // Assert
- Assert.AreEqual(3, menu.Items.Count);
+ // Call
+ ContextMenuStrip menu = info.ContextMenuStrip(context, null, treeViewControl);
- TestHelper.AssertContextMenuStripContainsItem(menu, 0, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All,
- Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All_ToolTip, RingtoetsCommonFormsResources.CalculateAllIcon);
+ // Assert
+ Assert.AreEqual(3, menu.Items.Count);
- CollectionAssert.AllItemsAreInstancesOfType(new[]
- {
- menu.Items[1],
- }, typeof(ToolStripSeparator));
+ TestHelper.AssertContextMenuStripContainsItem(menu, 0, Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All,
+ Resources.GrassCoverErosionOutwardsWaterLevelLocation_Calculate_All_ToolTip, RingtoetsCommonFormsResources.CalculateAllIcon);
+
+ CollectionAssert.AllItemsAreInstancesOfType(new[]
+ {
+ menu.Items[1],
+ }, typeof(ToolStripSeparator));
+ }
}
+ mockRepository.VerifyAll();
}
[Test]
@@ -270,12 +298,17 @@
new GrassCoverErosionOutwardsHydraulicBoundaryLocation(hydraulicBoundaryLocation)
};
var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(assessmentSectionMock, locations);
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- // Call
- Color color = info.ForeColor(context);
+ // Call
+ Color color = info.ForeColor(context);
- // Assert
- Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), color);
+ }
+ mockRepository.VerifyAll();
}
[Test]
@@ -285,12 +318,99 @@
var assessmentSectionMock = mockRepository.Stub();
mockRepository.ReplayAll();
var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(assessmentSectionMock, new ObservableList());
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
- // Call
- Color color = info.ForeColor(context);
+ // Call
+ Color color = info.ForeColor(context);
- // Assert
- Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ // Assert
+ Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), color);
+ }
+ mockRepository.VerifyAll();
}
+
+ [Test]
+ [RequiresSTA]
+ public void GivenHydraulicBoundaryDatabaseWithNonExistingFilePath_WhenCalculatingDesignWaterLevelFromContextMenu_ThenLogMessagesAddedPreviousOutputNotAffected()
+ {
+ // Given
+ var guiMock = mockRepository.DynamicMock();
+ RoundedDouble designWaterLevel = (RoundedDouble) 4.2;
+
+ var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(100001, "", 1.1, 2.2);
+ var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(100002, "", 3.3, 4.4);
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ hydraulicBoundaryLocation1,
+ hydraulicBoundaryLocation2
+ },
+ FilePath = "D:/nonExistingDirectory/nonExistingFile"
+ };
+
+ var assessmentSectionMock = mockRepository.Stub();
+ assessmentSectionMock.Expect(a => a.Id).Return("Id");
+ assessmentSectionMock.Expect(a => a.GetFailureMechanisms()).Return(new[]
+ {
+ new GrassCoverErosionOutwardsFailureMechanism
+ {
+ Contribution = 1
+ }
+ });
+ assessmentSectionMock.Expect(a => a.FailureMechanismContribution).Return(new FailureMechanismContribution(Enumerable.Empty(), 1, 5));
+ assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase;
+ var grassCoverErosionOutwardsHydraulicBoundaryLocation1 = new GrassCoverErosionOutwardsHydraulicBoundaryLocation(hydraulicBoundaryLocation1);
+ var grassCoverErosionOutwardsHydraulicBoundaryLocation2 = new GrassCoverErosionOutwardsHydraulicBoundaryLocation(hydraulicBoundaryLocation2)
+ {
+ DesignWaterLevel = designWaterLevel
+ };
+
+ var grassCoverErosionOutwardsHydraulicBoundaryLocations = new ObservableList
+ {
+ grassCoverErosionOutwardsHydraulicBoundaryLocation1,
+ grassCoverErosionOutwardsHydraulicBoundaryLocation2
+ };
+ var context = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContext(assessmentSectionMock, grassCoverErosionOutwardsHydraulicBoundaryLocations);
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ guiMock.Expect(g => g.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
+ guiMock.Expect(g => g.MainWindow).Return(mockRepository.Stub());
+ mockRepository.ReplayAll();
+
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ TreeNodeInfo info = GetInfo(plugin);
+ plugin.Gui = guiMock;
+ plugin.Activate();
+
+ using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
+ {
+ // When
+ Action action = () => { contextMenuAdapter.Items[contextMenuRunDesignWaterLevelCalculationsIndex].PerformClick(); };
+
+ // Then
+ string message = string.Format("Berekeningen konden niet worden gestart. Fout bij het lezen van bestand '{0}': Het bestand bestaat niet.",
+ hydraulicBoundaryDatabase.FilePath);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(action, new Tuple(message, LogLevelConstant.Error));
+
+ Assert.IsNaN(grassCoverErosionOutwardsHydraulicBoundaryLocation1.DesignWaterLevel); // No result set
+
+ // Previous result not cleared
+ Assert.AreEqual(designWaterLevel, grassCoverErosionOutwardsHydraulicBoundaryLocation2.DesignWaterLevel,
+ grassCoverErosionOutwardsHydraulicBoundaryLocation2.DesignWaterLevel.GetAccuracy());
+ }
+ }
+ }
+ mockRepository.VerifyAll();
+ }
+
+ private static TreeNodeInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin)
+ {
+ return plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionOutwardsDesignWaterLevelLocationsContext));
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs
===================================================================
diff -u -r75ac52f6f7e203e77dd212e6c32d68e7e58c28b2 -r3923884225f5ae288c5b78738ebd37f935c97095
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs (.../HydraulicBoundariesGroupContextTreeNodeInfoTest.cs) (revision 75ac52f6f7e203e77dd212e6c32d68e7e58c28b2)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/TreeNodeInfos/HydraulicBoundariesGroupContextTreeNodeInfoTest.cs (.../HydraulicBoundariesGroupContextTreeNodeInfoTest.cs) (revision 3923884225f5ae288c5b78738ebd37f935c97095)
@@ -159,8 +159,8 @@
// Assert
Assert.AreEqual(2, children.Length);
var waterLevelHydraulicBoundaryLocationsContext = (GrassCoverErosionOutwardsDesignWaterLevelLocationsContext) children[0];
- Assert.AreSame(assessmentSectionMock, waterLevelHydraulicBoundaryLocationsContext.WrappedData);
- Assert.AreSame(failureMechanism.GrassCoverErosionOutwardsHydraulicBoundaryLocations, waterLevelHydraulicBoundaryLocationsContext.Locations);
+ Assert.AreSame(failureMechanism.GrassCoverErosionOutwardsHydraulicBoundaryLocations, waterLevelHydraulicBoundaryLocationsContext.WrappedData);
+ Assert.AreSame(assessmentSectionMock, waterLevelHydraulicBoundaryLocationsContext.AssessmentSection);
var waveHeightHydraulicBoundaryLocationsContext = (GrassCoverErosionOutwardsWaveHeightLocationsContext)children[1];
Assert.AreSame(assessmentSectionMock, waveHeightHydraulicBoundaryLocationsContext.WrappedData);