Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -rf70e531b2ee3cf4877e41d4ea47c7d759c48de07 -rb8b024eb53a66982983e881cdf054ee64f4cee46
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision f70e531b2ee3cf4877e41d4ea47c7d759c48de07)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -225,12 +225,6 @@
CalculationsView.cs
-
- UserControl
-
-
- FailureMechanismView.cs
-
@@ -321,9 +315,6 @@
CalculationsView.cs
-
- FailureMechanismView.cs
-
CommentView.cs
Fisheye: Tag b8b024eb53a66982983e881cdf054ee64f4cee46 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag b8b024eb53a66982983e881cdf054ee64f4cee46 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag b8b024eb53a66982983e881cdf054ee64f4cee46 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismView.resx'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -rf70e531b2ee3cf4877e41d4ea47c7d759c48de07 -rb8b024eb53a66982983e881cdf054ee64f4cee46
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision f70e531b2ee3cf4877e41d4ea47c7d759c48de07)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -171,7 +171,6 @@
-
Fisheye: Tag b8b024eb53a66982983e881cdf054ee64f4cee46 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r783cff34ad1121a4898d0e9c1928d7397539f97d -rb8b024eb53a66982983e881cdf054ee64f4cee46
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 783cff34ad1121a4898d0e9c1928d7397539f97d)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -118,6 +118,12 @@
AssessmentSectionView.cs
+
+ UserControl
+
+
+ FailureMechanismView.cs
+
UserControl
@@ -339,6 +345,9 @@
AssessmentSectionView.cs
+
+ FailureMechanismView.cs
+
MacroStabilityOutwardsAssemblyCategoriesView.cs
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.Designer.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.Designer.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.Designer.cs (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -0,0 +1,66 @@
+// Copyright (C) Stichting Deltares 2018. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using Ringtoets.Common.Forms.Views;
+
+namespace Ringtoets.Integration.Forms.Views
+{
+ partial class FailureMechanismView
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.ringtoetsMapControl = new Ringtoets.Common.Forms.Views.RingtoetsMapControl();
+ this.SuspendLayout();
+ //
+ // ringtoetsMapControl
+ //
+ this.ringtoetsMapControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.ringtoetsMapControl.Location = new System.Drawing.Point(0, 0);
+ this.ringtoetsMapControl.Name = "ringtoetsMapControl";
+ this.ringtoetsMapControl.Size = new System.Drawing.Size(150, 150);
+ this.ringtoetsMapControl.TabIndex = 0;
+ //
+ // FailureMechanismView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.ringtoetsMapControl);
+ this.Name = "FailureMechanismView";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private RingtoetsMapControl ringtoetsMapControl;
+ }
+}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.cs (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -0,0 +1,236 @@
+// Copyright (C) Stichting Deltares 2018. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Forms;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.Helpers;
+
+namespace Ringtoets.Integration.Forms.Views
+{
+ ///
+ /// This class is a view showing map data for a failure mechanism.
+ ///
+ public partial class FailureMechanismView : UserControl, IMapView where T : IFailureMechanism
+ {
+ private readonly MapLineData referenceLineMapData;
+ private readonly MapLineData sectionsMapData;
+ private readonly MapPointData sectionsStartPointMapData;
+ private readonly MapPointData sectionsEndPointMapData;
+ private readonly MapPointData hydraulicBoundaryLocationsMapData;
+
+ private Observer failureMechanismObserver;
+ private Observer assessmentSectionObserver;
+ private Observer hydraulicBoundaryLocationsObserver;
+
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForFactorizedSignalingNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForSignalingNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForLowerLimitNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waterLevelCalculationsForFactorizedLowerLimitNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForFactorizedSignalingNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForSignalingNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForLowerLimitNormObserver;
+ private RecursiveObserver, HydraulicBoundaryLocationCalculation> waveHeightCalculationsForFactorizedLowerLimitNormObserver;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The failure mechanism to show the data for.
+ /// The assessment section to show the data for.
+ /// Thrown when any parameter is null.
+ public FailureMechanismView(T failureMechanism, IAssessmentSection assessmentSection)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ InitializeComponent();
+
+ FailureMechanism = failureMechanism;
+ AssessmentSection = assessmentSection;
+
+ CreateObservers();
+
+ var mapDataCollection = new MapDataCollection(failureMechanism.Name);
+ referenceLineMapData = RingtoetsMapDataFactory.CreateReferenceLineMapData();
+ hydraulicBoundaryLocationsMapData = RingtoetsMapDataFactory.CreateHydraulicBoundaryLocationsMapData();
+ sectionsMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsMapData();
+ sectionsStartPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsStartPointMapData();
+ sectionsEndPointMapData = RingtoetsMapDataFactory.CreateFailureMechanismSectionsEndPointMapData();
+
+ mapDataCollection.Add(referenceLineMapData);
+ mapDataCollection.Add(sectionsMapData);
+ mapDataCollection.Add(sectionsStartPointMapData);
+ mapDataCollection.Add(sectionsEndPointMapData);
+ mapDataCollection.Add(hydraulicBoundaryLocationsMapData);
+
+ SetAllMapDataFeatures();
+ ringtoetsMapControl.SetAllData(mapDataCollection, assessmentSection.BackgroundData);
+ }
+
+ ///
+ /// Gets the failure mechanism.
+ ///
+ public T FailureMechanism { get; }
+
+ ///
+ /// Gets the assessment section.
+ ///
+ public IAssessmentSection AssessmentSection { get; }
+
+ public object Data { get; set; }
+
+ public IMapControl Map
+ {
+ get
+ {
+ return ringtoetsMapControl.MapControl;
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ failureMechanismObserver.Dispose();
+ assessmentSectionObserver.Dispose();
+ hydraulicBoundaryLocationsObserver.Dispose();
+ waterLevelCalculationsForFactorizedSignalingNormObserver.Dispose();
+ waterLevelCalculationsForSignalingNormObserver.Dispose();
+ waterLevelCalculationsForLowerLimitNormObserver.Dispose();
+ waterLevelCalculationsForFactorizedLowerLimitNormObserver.Dispose();
+ waveHeightCalculationsForFactorizedSignalingNormObserver.Dispose();
+ waveHeightCalculationsForSignalingNormObserver.Dispose();
+ waveHeightCalculationsForLowerLimitNormObserver.Dispose();
+ waveHeightCalculationsForFactorizedLowerLimitNormObserver.Dispose();
+
+ if (disposing)
+ {
+ components?.Dispose();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ private void CreateObservers()
+ {
+ failureMechanismObserver = new Observer(UpdateSectionsMapData)
+ {
+ Observable = FailureMechanism
+ };
+ assessmentSectionObserver = new Observer(UpdateReferenceLineMapData)
+ {
+ Observable = AssessmentSection
+ };
+ hydraulicBoundaryLocationsObserver = new Observer(UpdateHydraulicBoundaryLocationsMapData)
+ {
+ Observable = AssessmentSection.HydraulicBoundaryDatabase.Locations
+ };
+
+ waterLevelCalculationsForFactorizedSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waterLevelCalculationsForSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaterLevelCalculationsForSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waterLevelCalculationsForLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaterLevelCalculationsForLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waterLevelCalculationsForFactorizedLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waveHeightCalculationsForFactorizedSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waveHeightCalculationsForSignalingNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaveHeightCalculationsForSignalingNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waveHeightCalculationsForLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaveHeightCalculationsForLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
+ waveHeightCalculationsForFactorizedLowerLimitNormObserver = ObserverHelper.CreateHydraulicBoundaryLocationCalculationsObserver(
+ AssessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm, UpdateHydraulicBoundaryLocationsMapData);
+ }
+
+ private void SetAllMapDataFeatures()
+ {
+ SetReferenceLineMapData();
+ SetSectionsMapData();
+ SetHydraulicBoundaryLocationsMapData();
+ }
+
+ #region ReferenceLine MapData
+
+ private void UpdateReferenceLineMapData()
+ {
+ SetReferenceLineMapData();
+ referenceLineMapData.NotifyObservers();
+ }
+
+ private void SetReferenceLineMapData()
+ {
+ referenceLineMapData.Features = RingtoetsMapDataFeaturesFactory.CreateReferenceLineFeatures(
+ AssessmentSection.ReferenceLine, AssessmentSection.Id, AssessmentSection.Name);
+ }
+
+ #endregion
+
+ #region Sections MapData
+
+ private void UpdateSectionsMapData()
+ {
+ SetSectionsMapData();
+ sectionsMapData.NotifyObservers();
+ sectionsStartPointMapData.NotifyObservers();
+ sectionsEndPointMapData.NotifyObservers();
+ }
+
+ private void SetSectionsMapData()
+ {
+ IEnumerable failureMechanismSections = FailureMechanism.Sections;
+
+ sectionsMapData.Features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(failureMechanismSections);
+ sectionsStartPointMapData.Features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures(failureMechanismSections);
+ sectionsEndPointMapData.Features = RingtoetsMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(failureMechanismSections);
+ }
+
+ #endregion
+
+ #region HydraulicBoundaryLocations MapData
+
+ private void UpdateHydraulicBoundaryLocationsMapData()
+ {
+ SetHydraulicBoundaryLocationsMapData();
+ hydraulicBoundaryLocationsMapData.NotifyObservers();
+ }
+
+ private void SetHydraulicBoundaryLocationsMapData()
+ {
+ hydraulicBoundaryLocationsMapData.Features = RingtoetsMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(AssessmentSection);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.resx
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.resx (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/FailureMechanismView.resx (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r9244e97aa2d6ccaf1ca7eb23f0fe200b85a7fe8a -rb8b024eb53a66982983e881cdf054ee64f4cee46
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 9244e97aa2d6ccaf1ca7eb23f0fe200b85a7fe8a)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -87,6 +87,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/FailureMechanismViewTest.cs (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -0,0 +1,472 @@
+// Copyright (C) Stichting Deltares 2018. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// 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;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.TestUtil;
+using Ringtoets.Common.Forms.Views;
+using Ringtoets.Integration.Forms.Views;
+
+namespace Ringtoets.Integration.Forms.Test.Views
+{
+ [TestFixture]
+ public class FailureMechanismViewTest
+ {
+ private const int referenceLineIndex = 0;
+ private const int sectionsIndex = 1;
+ private const int sectionsStartPointIndex = 2;
+ private const int sectionsEndPointIndex = 3;
+ private const int hydraulicBoundaryLocationsIndex = 4;
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var failureMechanism = new TestFailureMechanism();
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ using (var view = new FailureMechanismView(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);
+ AssertEmptyMapData(view.Map.Data);
+ }
+ }
+
+ [Test]
+ public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new FailureMechanismView(null, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new FailureMechanismView(failureMechanism, null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionWithBackgroundData_BackgroundDataSet()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ using (var view = new FailureMechanismView(new TestFailureMechanism(), assessmentSection))
+ {
+ // Assert
+ MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, view.Map.BackgroundMapData);
+ }
+ }
+
+ [Test]
+ public void Constructor_WithAllData_DataUpdatedToCollectionOfFilledMapData()
+ {
+ // Setup
+ 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 referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(2.0, 1.0)
+ });
+
+ var assessmentSection = new AssessmentSectionStub
+ {
+ ReferenceLine = referenceLine
+ };
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)
+ });
+
+ var failureMechanism = new TestFailureMechanism();
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ new FailureMechanismSection("A", geometryPoints.Take(2)),
+ new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2)),
+ new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2))
+ });
+
+ // Call
+ using (var view = new FailureMechanismView(failureMechanism, assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ // Assert
+ MapDataCollection mapData = map.Data;
+ Assert.IsInstanceOf(mapData);
+
+ List mapDataList = mapData.Collection.ToList();
+ Assert.AreEqual(5, mapDataList.Count);
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]);
+ MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, mapDataList[sectionsIndex]);
+ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]);
+ MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, mapDataList[sectionsEndPointIndex]);
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapDataList[hydraulicBoundaryLocationsIndex]);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(typeof(MapViewTestHelper), nameof(MapViewTestHelper.GetCalculationFuncs))]
+ public void GivenViewWithHydraulicBoundaryLocationsData_WhenHydraulicBoundaryLocationCalculationUpdatedAndNotified_ThenMapDataUpdated(
+ Func getCalculationFunc)
+ {
+ // Given
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0);
+ var assessmentSection = new AssessmentSectionStub();
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation
+ });
+
+ using (var view = new FailureMechanismView(new TestFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex);
+
+ // Precondition
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, hydraulicBoundaryLocationsMapData);
+
+ // When
+ HydraulicBoundaryLocationCalculation calculation = getCalculationFunc(assessmentSection);
+ calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(new Random(21).NextDouble());
+ calculation.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, hydraulicBoundaryLocationsMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void UpdateObserver_HydraulicBoundaryLocationsDataUpdated_MapDataUpdated()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0)
+ });
+
+ using (var view = new FailureMechanismView(new TestFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex);
+
+ // Precondition
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, hydraulicBoundaryLocationsMapData);
+
+ // Call
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ new HydraulicBoundaryLocation(2, "test2", 3.0, 4.0)
+ });
+ assessmentSection.HydraulicBoundaryDatabase.Locations.NotifyObservers();
+
+ // Assert
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, hydraulicBoundaryLocationsMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void UpdateObserver_ReferenceLineUpdated_MapDataUpdated()
+ {
+ // Setup
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new List
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(2.0, 1.0)
+ });
+
+ var assessmentSection = new AssessmentSectionStub
+ {
+ ReferenceLine = referenceLine
+ };
+
+ using (var view = new FailureMechanismView(new TestFailureMechanism(), assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex);
+
+ // Precondition
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
+
+ // Call
+ assessmentSection.ReferenceLine.SetGeometry(new List
+ {
+ new Point2D(2.0, 5.0),
+ new Point2D(4.0, 3.0)
+ });
+ assessmentSection.NotifyObservers();
+
+ // Assert
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void UpdateObserver_FailureMechanismSectionsUpdated_MapDataUpdated()
+ {
+ // Setup
+ var failureMechanism = new TestFailureMechanism();
+
+ using (var view = new FailureMechanismView(failureMechanism, new AssessmentSectionStub()))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[sectionsIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsStartPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsEndPointIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ var sectionMapData = (MapLineData) map.Data.Collection.ElementAt(sectionsIndex);
+ var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex);
+ var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex);
+
+ // Call
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ new FailureMechanismSection(string.Empty, new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(1, 2)
+ })
+ });
+ failureMechanism.NotifyObservers();
+
+ // Assert
+ MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionMapData);
+ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionStartsMapData);
+ MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsEndsMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void UpdateObserver_DataUpdated_MapLayersSameOrder()
+ {
+ // Setup
+ const int updatedReferenceLineLayerIndex = referenceLineIndex + 4;
+ const int updatedSectionsLayerIndex = sectionsIndex - 1;
+ const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1;
+ const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1;
+ const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1;
+
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new TestFailureMechanism();
+
+ using (var view = new FailureMechanismView(failureMechanism, assessmentSection))
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ MapDataCollection mapData = map.Data;
+
+ var dataToMove = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex);
+ mapData.Remove(dataToMove);
+ mapData.Add(dataToMove);
+
+ List mapDataList = mapData.Collection.ToList();
+
+ // Precondition
+ var referenceLineData = (MapLineData) mapDataList[updatedReferenceLineLayerIndex];
+ Assert.AreEqual("Referentielijn", referenceLineData.Name);
+
+ var sectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex];
+ Assert.AreEqual("Vakindeling", sectionsData.Name);
+
+ var sectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex];
+ Assert.AreEqual("Vakindeling (startpunten)", sectionStartsData.Name);
+
+ var sectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex];
+ Assert.AreEqual("Vakindeling (eindpunten)", sectionEndsData.Name);
+
+ var hydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex];
+ Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name);
+
+ var points = new List
+ {
+ new Point2D(2.0, 5.0),
+ new Point2D(4.0, 3.0)
+ };
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(points);
+ assessmentSection.ReferenceLine = referenceLine;
+
+ // Call
+ assessmentSection.NotifyObservers();
+
+ // Assert
+ var actualReferenceLineData = (MapLineData) mapDataList[updatedReferenceLineLayerIndex];
+ Assert.AreEqual("Referentielijn", actualReferenceLineData.Name);
+
+ var actualSectionsData = (MapLineData) mapDataList[updatedSectionsLayerIndex];
+ Assert.AreEqual("Vakindeling", actualSectionsData.Name);
+
+ var actualSectionStartsData = (MapPointData) mapDataList[updateSectionStartLayerIndex];
+ Assert.AreEqual("Vakindeling (startpunten)", actualSectionStartsData.Name);
+
+ var actualSectionEndsData = (MapPointData) mapDataList[updatedSectionEndLayerIndex];
+ Assert.AreEqual("Vakindeling (eindpunten)", actualSectionEndsData.Name);
+
+ var actualHydraulicLocationsData = (MapPointData) mapDataList[updatedHydraulicLocationsLayerIndex];
+ Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name);
+ }
+ }
+
+ private static void AssertEmptyMapData(MapDataCollection mapDataCollection)
+ {
+ Assert.AreEqual("Test failure mechanism", mapDataCollection.Name);
+
+ List mapDataList = mapDataCollection.Collection.ToList();
+
+ Assert.AreEqual(5, mapDataList.Count);
+
+ var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex];
+ var sectionsMapData = (MapLineData) mapDataList[sectionsIndex];
+ var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex];
+ var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex];
+ var hydraulicBoundaryLocationsMapData = (MapPointData) mapDataList[hydraulicBoundaryLocationsIndex];
+
+ CollectionAssert.IsEmpty(referenceLineMapData.Features);
+ CollectionAssert.IsEmpty(sectionsMapData.Features);
+ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features);
+ CollectionAssert.IsEmpty(sectionsEndPointMapData.Features);
+ CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features);
+
+ Assert.AreEqual("Referentielijn", referenceLineMapData.Name);
+ Assert.AreEqual("Vakindeling", sectionsMapData.Name);
+ Assert.AreEqual("Vakindeling (startpunten)", sectionsStartPointMapData.Name);
+ Assert.AreEqual("Vakindeling (eindpunten)", sectionsEndPointMapData.Name);
+ Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.Name);
+ }
+
+ ///
+ /// Attaches mocked observers to all map data components.
+ ///
+ /// The .
+ /// The map data collection containing the
+ /// elements.
+ /// An array of mocked observers attached to the data in .
+ private static IObserver[] AttachMapDataObservers(MockRepository mocks, IEnumerable mapData)
+ {
+ MapData[] mapDataArray = mapData.ToArray();
+
+ var referenceLineMapDataObserver = mocks.StrictMock();
+ mapDataArray[referenceLineIndex].Attach(referenceLineMapDataObserver);
+
+ var sectionsMapDataObserver = mocks.StrictMock();
+ mapDataArray[sectionsIndex].Attach(sectionsMapDataObserver);
+
+ var sectionsStartPointMapDataObserver = mocks.StrictMock();
+ mapDataArray[sectionsStartPointIndex].Attach(sectionsStartPointMapDataObserver);
+
+ var sectionsEndPointMapDataObserver = mocks.StrictMock();
+ mapDataArray[sectionsEndPointIndex].Attach(sectionsEndPointMapDataObserver);
+
+ var hydraulicBoundaryLocationsMapDataObserver = mocks.StrictMock();
+ mapDataArray[hydraulicBoundaryLocationsIndex].Attach(hydraulicBoundaryLocationsMapDataObserver);
+
+ return new[]
+ {
+ referenceLineMapDataObserver,
+ sectionsMapDataObserver,
+ sectionsStartPointMapDataObserver,
+ sectionsEndPointMapDataObserver,
+ hydraulicBoundaryLocationsMapDataObserver
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs
===================================================================
diff -u -r2a81f01756e227d5ce93717b21b87e8a5cd5fcbb -rb8b024eb53a66982983e881cdf054ee64f4cee46
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs (.../FailureMechanismViewInfoTest.cs) (revision 2a81f01756e227d5ce93717b21b87e8a5cd5fcbb)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/FailureMechanismViewInfoTest.cs (.../FailureMechanismViewInfoTest.cs) (revision b8b024eb53a66982983e881cdf054ee64f4cee46)
@@ -30,7 +30,7 @@
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Forms.PresentationObjects;
-using Ringtoets.Common.Forms.Views;
+using Ringtoets.Integration.Forms.Views;
using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.Integration.Plugin.Test.ViewInfos