Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs
===================================================================
diff -u -r3ea86a3d4d3c20e47943ba4966abf61c7d3d9f4a -ref03fd73ab6ec035d4b01f0efe8a07914262227e
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision 3ea86a3d4d3c20e47943ba4966abf61c7d3d9f4a)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismView.cs (.../ClosingStructuresFailureMechanismView.cs) (revision ef03fd73ab6ec035d4b01f0efe8a07914262227e)
@@ -19,6 +19,7 @@
// 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 System.Windows.Forms;
@@ -72,8 +73,25 @@
///
/// Creates a new instance of .
///
- public ClosingStructuresFailureMechanismView()
+ /// The failure mechanism to show the data for.
+ /// The assessment section to show data for.
+ /// Thrown when any parameter is null.
+ public ClosingStructuresFailureMechanismView(ClosingStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
{
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ FailureMechanism = failureMechanism;
+ AssessmentSection = assessmentSection;
+
InitializeComponent();
failureMechanismObserver = new Observer(UpdateMapData);
@@ -112,6 +130,16 @@
mapDataCollection.Add(calculationsMapData);
}
+ ///
+ /// Gets the failure mechanism.
+ ///
+ public ClosingStructuresFailureMechanism FailureMechanism { get; }
+
+ ///
+ /// Gets the assessment section.
+ ///
+ public IAssessmentSection AssessmentSection { get; }
+
public object Data
{
get
@@ -185,6 +213,7 @@
{
components?.Dispose();
}
+
base.Dispose(disposing);
}
Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs
===================================================================
diff -u -r1b0aa0eb14d10671b03064c659a94475895484d5 -ref03fd73ab6ec035d4b01f0efe8a07914262227e
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision 1b0aa0eb14d10671b03064c659a94475895484d5)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision ef03fd73ab6ec035d4b01f0efe8a07914262227e)
@@ -29,6 +29,7 @@
using Core.Components.Gis.Forms;
using Core.Components.Gis.Geometries;
using NUnit.Framework;
+using Rhino.Mocks;
using Ringtoets.ClosingStructures.Data;
using Ringtoets.ClosingStructures.Data.TestUtil;
using Ringtoets.ClosingStructures.Forms.PresentationObjects;
@@ -56,20 +57,54 @@
private const int calculationsIndex = 7;
[Test]
+ public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new ClosingStructuresFailureMechanismView(null, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
public void Constructor_ExpectedValues()
{
+ // Setup
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
// Call
- using (var view = new ClosingStructuresFailureMechanismView())
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, assessmentSection))
{
// Assert
Assert.IsInstanceOf(view);
Assert.IsInstanceOf(view);
Assert.IsNull(view.Data);
+ Assert.AreSame(failureMechanism, view.FailureMechanism);
+ Assert.AreSame(assessmentSection, view.AssessmentSection);
Assert.AreEqual(1, view.Controls.Count);
Assert.IsInstanceOf(view.Controls[0]);
- Assert.AreSame(view.Map, ((RingtoetsMapControl)view.Controls[0]).MapControl);
- Assert.AreEqual(DockStyle.Fill, ((Control)view.Map).Dock);
+ Assert.AreSame(view.Map, ((RingtoetsMapControl) view.Controls[0]).MapControl);
+ Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock);
AssertEmptyMapData(view.Map.Data);
}
}
@@ -78,10 +113,10 @@
public void Data_ClosingStructuresFailureMechanismContext_DataSet()
{
// Setup
- using (var view = new ClosingStructuresFailureMechanismView())
- {
- var assessmentSection = new ObservableTestAssessmentSectionStub();
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), assessmentSection))
+ {
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(
new ClosingStructuresFailureMechanism(), assessmentSection);
@@ -99,7 +134,7 @@
// Setup
IAssessmentSection assessmentSection = new ObservableTestAssessmentSectionStub();
- using (var view = new ClosingStructuresFailureMechanismView())
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), assessmentSection))
{
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(
new ClosingStructuresFailureMechanism(), assessmentSection);
@@ -116,7 +151,7 @@
public void Data_OtherThanClosingStructuresFailureMechanismContext_DataNull()
{
// Setup
- using (var view = new ClosingStructuresFailureMechanismView())
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), new ObservableTestAssessmentSectionStub()))
{
var data = new object();
@@ -132,7 +167,7 @@
public void Data_SetToNull_MapDataCleared()
{
// Setup
- using (var view = new ClosingStructuresFailureMechanismView())
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), new ObservableTestAssessmentSectionStub()))
{
var assessmentSection = new ObservableTestAssessmentSectionStub();
@@ -160,7 +195,7 @@
public void Data_EmptyClosingStructuresFailureMechanismContext_NoMapDataSet()
{
// Setup
- using (var view = new ClosingStructuresFailureMechanismView())
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), new ObservableTestAssessmentSectionStub()))
{
var assessmentSection = new ObservableTestAssessmentSectionStub();
@@ -181,85 +216,79 @@
[Test]
public void Data_ClosingStructuresFailureMechanismContext_DataUpdatedToCollectionOfFilledMapData()
{
- // Setup
- using (var view = new ClosingStructuresFailureMechanismView())
+ // Setup
+ var calculationA = new StructuresCalculation
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var geometryPoints = new[]
+ InputParameters =
{
- new Point2D(0.0, 0.0),
- new Point2D(2.0, 0.0),
- new Point2D(4.0, 4.0),
- new Point2D(6.0, 4.0)
- };
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestClosingStructure(new Point2D(1.2, 2.3))
+ }
+ };
- var referenceLine = new ReferenceLine();
- referenceLine.SetGeometry(new[]
+ var calculationB = new StructuresCalculation
+ {
+ InputParameters =
{
- new Point2D(1.0, 2.0),
- new Point2D(2.0, 1.0)
- });
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6),
+ Structure = new TestClosingStructure(new Point2D(2.7, 2.0))
+ }
+ };
- var assessmentSection = new ObservableTestAssessmentSectionStub
- {
- HydraulicBoundaryDatabase =
- {
- Locations =
- {
- new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)
- }
- },
- ReferenceLine = referenceLine
- };
+ var geometryPoints = new[]
+ {
+ new Point2D(0.0, 0.0),
+ new Point2D(2.0, 0.0),
+ new Point2D(4.0, 4.0),
+ new Point2D(6.0, 4.0)
+ };
- var calculationLocationA = new Point2D(1.2, 2.3);
- var calculationLocationB = new Point2D(2.7, 2.0);
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.AddSection(new FailureMechanismSection("A", geometryPoints.Take(2)));
+ failureMechanism.AddSection(new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2)));
+ failureMechanism.AddSection(new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2)));
- var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3);
- var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6);
+ var profile1 = new TestForeshoreProfile("profile1 ID", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ });
+ var profile2 = new TestForeshoreProfile("profile2 ID", new[]
+ {
+ new Point2D(2, 2),
+ new Point2D(3, 3)
+ });
+ failureMechanism.ForeshoreProfiles.AddRange(new[]
+ {
+ profile1,
+ profile2
+ }, "path");
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
- var calculationA = new StructuresCalculation
- {
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationA,
- Structure = new TestClosingStructure(calculationLocationA)
- }
- };
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(2.0, 1.0)
+ });
- var calculationB = new StructuresCalculation
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase =
{
- InputParameters =
+ Locations =
{
- HydraulicBoundaryLocation = hydraulicBoundaryLocationB,
- Structure = new TestClosingStructure(calculationLocationB)
+ new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)
}
- };
+ },
+ ReferenceLine = referenceLine
+ };
- var failureMechanism = new ClosingStructuresFailureMechanism();
- failureMechanism.AddSection(new FailureMechanismSection("A", geometryPoints.Take(2)));
- failureMechanism.AddSection(new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2)));
- failureMechanism.AddSection(new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2)));
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var profile1 = new TestForeshoreProfile("profile1 ID", new[]
- {
- new Point2D(0, 0),
- new Point2D(1, 1)
- });
- var profile2 = new TestForeshoreProfile("profile2 ID", new[]
- {
- new Point2D(2, 2),
- new Point2D(3, 3)
- });
- failureMechanism.ForeshoreProfiles.AddRange(new[]
- {
- profile1,
- profile2
- }, "path");
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
- failureMechanism.CalculationsGroup.Children.Add(calculationB);
-
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection);
// Call
@@ -290,21 +319,21 @@
public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryLocationsUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var assessmentSection = new ObservableTestAssessmentSectionStub
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var assessmentSection = new ObservableTestAssessmentSectionStub
+ HydraulicBoundaryDatabase =
{
- HydraulicBoundaryDatabase =
+ Locations =
{
- Locations =
- {
- new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0)
- }
+ new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0)
}
- };
+ }
+ };
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), assessmentSection);
view.Data = failureMechanismContext;
@@ -327,23 +356,23 @@
public void GivenViewWithHydraulicBoundaryLocationsData_WhenLocationUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- var random = new Random(21);
- using (var view = new ClosingStructuresFailureMechanismView())
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0);
+ var assessmentSection = new ObservableTestAssessmentSectionStub
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0);
- var assessmentSection = new ObservableTestAssessmentSectionStub
+ HydraulicBoundaryDatabase =
{
- HydraulicBoundaryDatabase =
+ Locations =
{
- Locations =
- {
- hydraulicBoundaryLocation
- }
+ hydraulicBoundaryLocation
}
- };
+ }
+ };
+ var random = new Random(21);
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), assessmentSection);
view.Data = failureMechanismContext;
@@ -375,28 +404,20 @@
public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var assessmentSection = new ObservableTestAssessmentSectionStub
{
+ ReferenceLine = new ReferenceLine()
+ };
+ assessmentSection.ReferenceLine.SetGeometry(new List
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(2.0, 1.0)
+ });
+
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), assessmentSection))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var points1 = new List
- {
- new Point2D(1.0, 2.0),
- new Point2D(2.0, 1.0)
- };
-
- var points2 = new List
- {
- new Point2D(2.0, 5.0),
- new Point2D(4.0, 3.0)
- };
-
- var assessmentSection = new ObservableTestAssessmentSectionStub
- {
- ReferenceLine = new ReferenceLine()
- };
- assessmentSection.ReferenceLine.SetGeometry(points1);
-
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), assessmentSection);
view.Data = failureMechanismContext;
@@ -407,7 +428,11 @@
MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
// When
- assessmentSection.ReferenceLine.SetGeometry(points2);
+ assessmentSection.ReferenceLine.SetGeometry(new List
+ {
+ new Point2D(2.0, 5.0),
+ new Point2D(4.0, 3.0)
+ });
assessmentSection.NotifyObservers();
// Then
@@ -419,11 +444,12 @@
public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
view.Data = failureMechanismContext;
@@ -451,23 +477,23 @@
public void GivenViewWithForeshoreProfileData_WhenForeshoreProfileUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var foreshoreProfile = new TestForeshoreProfile("originalProfile ID", new[]
{
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ });
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.ForeshoreProfiles.AddRange(new[]
+ {
+ foreshoreProfile
+ }, "path");
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
- var foreshoreProfile = new TestForeshoreProfile("originalProfile ID", new[]
- {
- new Point2D(0, 0),
- new Point2D(1, 1)
- });
- failureMechanism.ForeshoreProfiles.AddRange(new[]
- {
- foreshoreProfile
- }, "path");
-
view.Data = failureMechanismContext;
MapData foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex);
@@ -493,22 +519,22 @@
public void GivenViewWithForeshoreProfilesData_WhenForeshoreProfilesUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.ForeshoreProfiles.AddRange(new[]
{
+ new TestForeshoreProfile("originalProfile ID", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ })
+ }, "path");
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
- failureMechanism.ForeshoreProfiles.AddRange(new[]
- {
- new TestForeshoreProfile("originalProfile ID", new[]
- {
- new Point2D(0, 0),
- new Point2D(1, 1)
- })
- }, "path");
-
view.Data = failureMechanismContext;
MapData foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex);
@@ -536,19 +562,18 @@
public void GivenViewWithStructureData_WhenStructureUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.ClosingStructures.AddRange(new[]
{
+ new TestClosingStructure(new Point2D(0, 0), "Id")
+ }, "path");
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
- var structure = new TestClosingStructure(new Point2D(0, 0), "Id");
- failureMechanism.ClosingStructures.AddRange(new[]
- {
- structure
- }, "path");
-
view.Data = failureMechanismContext;
MapData structuresData = map.Data.Collection.ElementAt(structuresIndex);
@@ -558,8 +583,8 @@
structuresData);
// When
- structure.CopyProperties(new TestClosingStructure(new Point2D(1, 1), "Id"));
- structure.NotifyObservers();
+ new TestClosingStructure(new Point2D(0, 0), "Id").CopyProperties(new TestClosingStructure(new Point2D(1, 1), "Id"));
+ new TestClosingStructure(new Point2D(0, 0), "Id").NotifyObservers();
// Then
MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures,
@@ -571,19 +596,19 @@
public void GivenViewWithStructuresData_WhenStructuresUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.ClosingStructures.AddRange(new[]
{
+ new TestClosingStructure(new Point2D(0, 0), "Id1")
+ }, "path");
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism,
new ObservableTestAssessmentSectionStub());
- failureMechanism.ClosingStructures.AddRange(new[]
- {
- new TestClosingStructure(new Point2D(0, 0), "Id1")
- }, "path");
-
view.Data = failureMechanismContext;
MapData structuresData = map.Data.Collection.ElementAt(structuresIndex);
@@ -609,38 +634,22 @@
public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var calculationA = new StructuresCalculation
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var failureMechanism = new ClosingStructuresFailureMechanism();
- var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
-
- var calculationLocationA = new Point2D(1.2, 2.3);
- var calculationLocationB = new Point2D(2.7, 2.0);
-
- var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3);
- var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6);
-
- var calculationA = new StructuresCalculation
+ InputParameters =
{
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationA,
- Structure = new TestClosingStructure(calculationLocationA)
- }
- };
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestClosingStructure(new Point2D(1.2, 2.3))
+ }
+ };
- var calculationB = new StructuresCalculation
- {
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationB,
- Structure = new TestClosingStructure(calculationLocationB)
- }
- };
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+ var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
view.Data = failureMechanismContext;
@@ -651,6 +660,15 @@
calculationMapData);
// When
+ var calculationB = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6),
+ Structure = new TestClosingStructure(new Point2D(2.7, 2.0))
+ }
+ };
+
failureMechanism.CalculationsGroup.Children.Add(calculationB);
failureMechanism.CalculationsGroup.NotifyObservers();
@@ -663,28 +681,23 @@
public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var calculationA = new StructuresCalculation
{
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestClosingStructure(new Point2D(1.2, 2.3))
+ }
+ };
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
- var calculationLocationA = new Point2D(1.2, 2.3);
- var calculationLocationB = new Point2D(2.7, 2.0);
-
- var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3);
-
- var calculationA = new StructuresCalculation
- {
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationA,
- Structure = new TestClosingStructure(calculationLocationA)
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
-
view.Data = failureMechanismContext;
var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
@@ -694,7 +707,7 @@
calculationMapData);
// When
- calculationA.InputParameters.Structure = new TestClosingStructure(calculationLocationB);
+ calculationA.InputParameters.Structure = new TestClosingStructure(new Point2D(2.7, 2.0));
calculationA.InputParameters.NotifyObservers();
// Then
@@ -706,27 +719,24 @@
public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new ClosingStructuresFailureMechanismView())
+ var calculationA = new StructuresCalculation
{
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestClosingStructure(new Point2D(1.2, 2.3))
+ }
+ };
+
+ var failureMechanism = new ClosingStructuresFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ using (var view = new ClosingStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
- var calculationLocationA = new Point2D(1.2, 2.3);
-
- var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3);
-
- var calculationA = new StructuresCalculation
- {
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationA,
- Structure = new TestClosingStructure(calculationLocationA)
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
-
view.Data = failureMechanismContext;
var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
@@ -757,11 +767,11 @@
const int updatedStructuresLayerIndex = structuresIndex - 1;
const int updatedCalculationsIndex = calculationsIndex - 1;
- using (var view = new ClosingStructuresFailureMechanismView())
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), assessmentSection))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var assessmentSection = new ObservableTestAssessmentSectionStub();
var failureMechanism = new ClosingStructuresFailureMechanism();
var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection);
@@ -855,7 +865,7 @@
var oldClosingStructuresFailureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), oldAssessmentSection);
var newClosingStructuresFailureMechanismContext = new ClosingStructuresFailureMechanismContext(new ClosingStructuresFailureMechanism(), newAssessmentSection);
- using (var view = new ClosingStructuresFailureMechanismView())
+ using (var view = new ClosingStructuresFailureMechanismView(new ClosingStructuresFailureMechanism(), oldAssessmentSection))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
@@ -893,6 +903,7 @@
calculation.InputParameters.HydraulicBoundaryLocation.Location
}, geometries[0].PointCollections.First());
}
+
Assert.AreEqual("Berekeningen", mapData.Name);
}