Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs
===================================================================
diff -u -r61702582a3dce7f9e122b9404fa5bcfc70756f1d -r8e761caf9d9a0440b655a16a3c4b25d7fb87f5c2
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision 61702582a3dce7f9e122b9404fa5bcfc70756f1d)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismView.cs (.../StabilityPointStructuresFailureMechanismView.cs) (revision 8e761caf9d9a0440b655a16a3c4b25d7fb87f5c2)
@@ -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,10 +73,27 @@
///
/// Creates a new instance of .
///
- public StabilityPointStructuresFailureMechanismView()
+ /// The failure mechanism to show the data for.
+ /// The assessment section to show data for.
+ /// Thrown when any parameter is null.
+ public StabilityPointStructuresFailureMechanismView(StabilityPointStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
{
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
InitializeComponent();
+ FailureMechanism = failureMechanism;
+ AssessmentSection = assessmentSection;
+
failureMechanismObserver = new Observer(UpdateMapData);
assessmentSectionObserver = new Observer(UpdateMapData);
hydraulicBoundaryLocationsObserver = new Observer(UpdateMapData);
@@ -111,6 +129,16 @@
mapDataCollection.Add(calculationsMapData);
}
+ ///
+ /// Gets the failure mechanism.
+ ///
+ public StabilityPointStructuresFailureMechanism FailureMechanism { get; }
+
+ ///
+ /// Gets the assessment section.
+ ///
+ public IAssessmentSection AssessmentSection { get; }
+
public object Data
{
get
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs
===================================================================
diff -u -r545e6ebc8295651982afabfc450e4c5f6760bf7d -r8e761caf9d9a0440b655a16a3c4b25d7fb87f5c2
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision 545e6ebc8295651982afabfc450e4c5f6760bf7d)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision 8e761caf9d9a0440b655a16a3c4b25d7fb87f5c2)
@@ -29,6 +29,7 @@
using Core.Components.Gis.Forms;
using Core.Components.Gis.Geometries;
using NUnit.Framework;
+using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Hydraulics;
@@ -56,15 +57,49 @@
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 StabilityPointStructuresFailureMechanismView(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 StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
public void Constructor_ExpectedValues()
{
+ // Setup
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
// Call
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, assessmentSection))
{
// Assert
Assert.IsInstanceOf(view);
Assert.IsInstanceOf(view);
Assert.IsNotNull(view.Map);
+ Assert.AreSame(failureMechanism, view.FailureMechanism);
+ Assert.AreSame(assessmentSection, view.AssessmentSection);
Assert.AreEqual(1, view.Controls.Count);
Assert.IsInstanceOf(view.Controls[0]);
@@ -78,7 +113,7 @@
public void Data_StabilityPointStructuresFailureMechanismContext_DataSet()
{
// Setup
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ using (var view = new StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), new ObservableTestAssessmentSectionStub()))
{
var assessmentSection = new ObservableTestAssessmentSectionStub();
@@ -97,7 +132,7 @@
public void Data_OtherThanStabilityPointStructuresFailureMechanismContext_DataNull()
{
// Setup
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ using (var view = new StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), new ObservableTestAssessmentSectionStub()))
{
var data = new object();
@@ -115,7 +150,7 @@
// Setup
IAssessmentSection assessmentSection = new ObservableTestAssessmentSectionStub();
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ using (var view = new StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), assessmentSection))
{
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(
new StabilityPointStructuresFailureMechanism(), assessmentSection);
@@ -132,10 +167,10 @@
public void Data_SetToNull_MapDataCleared()
{
// Setup
- using (var view = new StabilityPointStructuresFailureMechanismView())
- {
- var assessmentSection = new ObservableTestAssessmentSectionStub();
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+ using (var view = new StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), assessmentSection))
+ {
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(
new StabilityPointStructuresFailureMechanism(), assessmentSection);
@@ -159,10 +194,10 @@
public void Data_EmptyStabilityPointStructuresFailureMechanismContext_NoMapDataSet()
{
// Setup
- using (var view = new StabilityPointStructuresFailureMechanismView())
- {
- var assessmentSection = new ObservableTestAssessmentSectionStub();
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+ using (var view = new StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), assessmentSection))
+ {
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(
new StabilityPointStructuresFailureMechanism(), assessmentSection);
@@ -180,85 +215,79 @@
public void Data_StabilityPointStructuresFailureMechanismContext_DataUpdatedToCollectionOfFilledMapData()
{
// Setup
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ 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 TestStabilityPointStructure(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 TestStabilityPointStructure(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 StabilityPointStructuresFailureMechanism();
+ 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");
- var calculationA = new StructuresCalculation
- {
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationA,
- Structure = new TestStabilityPointStructure(calculationLocationA)
- }
- };
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
- var calculationB = new StructuresCalculation
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(2.0, 1.0)
+ });
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase =
{
- InputParameters =
+ Locations =
{
- HydraulicBoundaryLocation = hydraulicBoundaryLocationB,
- Structure = new TestStabilityPointStructure(calculationLocationB)
+ new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)
}
- };
+ },
+ ReferenceLine = referenceLine
+ };
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- 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 StabilityPointStructuresFailureMechanismView(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 StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
// Call
@@ -289,21 +318,21 @@
public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryLocationsUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ 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 StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), assessmentSection);
view.Data = failureMechanismContext;
@@ -326,23 +355,23 @@
public void GivenViewWithHydraulicBoundaryLocationsData_WhenLocationUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- var random = new Random(21);
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ 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 StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), assessmentSection);
view.Data = failureMechanismContext;
@@ -374,28 +403,20 @@
public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ 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 StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), 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 StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), assessmentSection);
view.Data = failureMechanismContext;
@@ -406,7 +427,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
@@ -418,11 +443,12 @@
public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
view.Data = failureMechanismContext;
@@ -450,23 +476,24 @@
public void GivenViewWithForeshoreProfileData_WhenForeshoreProfileUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var foreshoreProfile = new TestForeshoreProfile("originalProfile ID", new[]
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ });
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
- var foreshoreProfile = new TestForeshoreProfile("originalProfile ID", new[]
- {
- new Point2D(0, 0),
- new Point2D(1, 1)
- });
- failureMechanism.ForeshoreProfiles.AddRange(new[]
- {
- foreshoreProfile
- }, "path");
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.ForeshoreProfiles.AddRange(new[]
+ {
+ foreshoreProfile
+ }, "path");
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
view.Data = failureMechanismContext;
MapData foreshoreProfileData = map.Data.Collection.ElementAt(foreshoreProfilesIndex);
@@ -492,22 +519,22 @@
public void GivenViewWithForeshoreProfilesData_WhenForeshoreProfilesUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.ForeshoreProfiles.AddRange(new[]
{
+ new TestForeshoreProfile("originalProfile ID", new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ })
+ }, "path");
+
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(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);
@@ -535,20 +562,20 @@
public void GivenViewWithStructureData_WhenStructureUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var structure = new TestStabilityPointStructure(new Point2D(0, 0), "Id");
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.StabilityPointStructures.AddRange(new[]
{
+ structure
+ }, "path");
+
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism,
new ObservableTestAssessmentSectionStub());
- var structure = new TestStabilityPointStructure(new Point2D(0, 0), "Id");
- failureMechanism.StabilityPointStructures.AddRange(new[]
- {
- structure
- }, "path");
-
view.Data = failureMechanismContext;
MapData structuresData = map.Data.Collection.ElementAt(structuresIndex);
@@ -571,20 +598,20 @@
public void GivenViewWithStructuresData_WhenStructuresUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.StabilityPointStructures.AddRange(
+ new[]
+ {
+ new TestStabilityPointStructure(new Point2D(0, 0), "Id1")
+ }, "path");
+
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism,
new ObservableTestAssessmentSectionStub());
- failureMechanism.StabilityPointStructures.AddRange(
- new[]
- {
- new TestStabilityPointStructure(new Point2D(0, 0), "Id1")
- }, "path");
-
view.Data = failureMechanismContext;
MapData structuresData = map.Data.Collection.ElementAt(structuresIndex);
@@ -611,39 +638,22 @@
public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var calculationA = new StructuresCalculation
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(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 TestStabilityPointStructure(calculationLocationA)
- }
- };
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestStabilityPointStructure(new Point2D(1.2, 2.3))
+ }
+ };
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
- var calculationB = new StructuresCalculation
- {
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationB,
- Structure = new TestStabilityPointStructure(calculationLocationB)
- }
- };
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
-
+ var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
view.Data = failureMechanismContext;
var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
@@ -653,6 +663,14 @@
calculationMapData);
// When
+ var calculationB = new StructuresCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6),
+ Structure = new TestStabilityPointStructure(new Point2D(2.7, 2.0))
+ }
+ };
failureMechanism.CalculationsGroup.Children.Add(calculationB);
failureMechanism.CalculationsGroup.NotifyObservers();
@@ -665,28 +683,22 @@
public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var calculationA = new StructuresCalculation
{
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestStabilityPointStructure(new Point2D(1.2, 2.3))
+ }
+ };
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(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 TestStabilityPointStructure(calculationLocationA)
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
-
view.Data = failureMechanismContext;
var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
@@ -696,7 +708,7 @@
calculationMapData);
// When
- calculationA.InputParameters.Structure = new TestStabilityPointStructure(calculationLocationB);
+ calculationA.InputParameters.Structure = new TestStabilityPointStructure(new Point2D(2.7, 2.0));
calculationA.InputParameters.NotifyObservers();
// Then
@@ -708,27 +720,22 @@
public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated()
{
// Given
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var calculationA = new StructuresCalculation
{
- IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(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 =
{
- InputParameters =
- {
- HydraulicBoundaryLocation = hydraulicBoundaryLocationA,
- Structure = new TestStabilityPointStructure(calculationLocationA)
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3),
+ Structure = new TestStabilityPointStructure(new Point2D(1.2, 2.3))
+ }
+ };
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, new ObservableTestAssessmentSectionStub()))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
view.Data = failureMechanismContext;
var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
@@ -759,12 +766,13 @@
const int updatedStructuresLayerIndex = structuresIndex - 1;
const int updatedCalculationsIndex = calculationsIndex - 1;
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+ var failureMechanism = new StabilityPointStructuresFailureMechanism();
+
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, assessmentSection))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
- var assessmentSection = new ObservableTestAssessmentSectionStub();
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
view.Data = failureMechanismContext;
@@ -857,7 +865,7 @@
var oldStabilityPointStructuresFailureMechanismContext = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), oldAssessmentSection);
var newStabilityPointStructuresFailureMechanismContext = new StabilityPointStructuresFailureMechanismContext(new StabilityPointStructuresFailureMechanism(), newAssessmentSection);
- using (var view = new StabilityPointStructuresFailureMechanismView())
+ using (var view = new StabilityPointStructuresFailureMechanismView(new StabilityPointStructuresFailureMechanism(), oldAssessmentSection))
{
IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresFailureMechanismViewInfoTest.cs
===================================================================
diff -u -r545e6ebc8295651982afabfc450e4c5f6760bf7d -r8e761caf9d9a0440b655a16a3c4b25d7fb87f5c2
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresFailureMechanismViewInfoTest.cs (.../StabilityPointStructuresFailureMechanismViewInfoTest.cs) (revision 545e6ebc8295651982afabfc450e4c5f6760bf7d)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresFailureMechanismViewInfoTest.cs (.../StabilityPointStructuresFailureMechanismViewInfoTest.cs) (revision 8e761caf9d9a0440b655a16a3c4b25d7fb87f5c2)
@@ -101,7 +101,7 @@
var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
- using (var view = new StabilityPointStructuresFailureMechanismView
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, assessmentSection)
{
Data = failureMechanismContext
})
@@ -125,7 +125,7 @@
var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
- using (var view = new StabilityPointStructuresFailureMechanismView
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, assessmentSection)
{
Data = failureMechanismContext
})
@@ -149,7 +149,7 @@
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
- using (var view = new StabilityPointStructuresFailureMechanismView
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, assessmentSection)
{
Data = failureMechanismContext
})
@@ -171,7 +171,7 @@
var failureMechanism = new StabilityPointStructuresFailureMechanism();
var failureMechanismContext = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection);
- using (var view = new StabilityPointStructuresFailureMechanismView
+ using (var view = new StabilityPointStructuresFailureMechanismView(failureMechanism, assessmentSection)
{
Data = failureMechanismContext
})