Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.Designer.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.Designer.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.Designer.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.
+
+namespace Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState
+{
+ partial class MacroStabilityInwardsFailureMechanismView
+ {
+ ///
+ /// 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.riskeerMapControl = new Riskeer.Common.Forms.Views.RiskeerMapControl();
+ this.SuspendLayout();
+ //
+ // riskeerMapControl
+ //
+ this.riskeerMapControl.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.riskeerMapControl.Location = new System.Drawing.Point(0, 0);
+ this.riskeerMapControl.Name = "riskeerMapControl";
+ this.riskeerMapControl.Size = new System.Drawing.Size(150, 150);
+ this.riskeerMapControl.TabIndex = 0;
+ //
+ // MacroStabilityInwardsFailureMechanismView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.riskeerMapControl);
+ this.Name = "MacroStabilityInwardsFailureMechanismView";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Common.Forms.Views.RiskeerMapControl riskeerMapControl;
+ }
+}
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,284 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Components.Gis.Data;
+using Core.Components.Gis.Forms;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Calculation;
+using Riskeer.Common.Forms.Factories;
+using Riskeer.Common.Forms.MapLayers;
+using Riskeer.MacroStabilityInwards.Data;
+using Riskeer.MacroStabilityInwards.Data.SoilProfile;
+using Riskeer.MacroStabilityInwards.Forms.Factories;
+using Riskeer.MacroStabilityInwards.Primitives;
+using MacroStabilityInwardsDataResources = Riskeer.MacroStabilityInwards.Data.Properties.Resources;
+
+namespace Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState
+{
+ ///
+ /// Calculations state view showing map data for a macro stability inwards failure mechanism.
+ ///
+ public partial class MacroStabilityInwardsFailureMechanismView : UserControl, IMapView
+ {
+ private HydraulicBoundaryLocationsMapLayer hydraulicBoundaryLocationsMapLayer;
+
+ private MapLineData referenceLineMapData;
+ private MapLineData stochasticSoilModelsMapData;
+ private MapLineData surfaceLinesMapData;
+ private MapLineData calculationsMapData;
+
+ private Observer assessmentSectionObserver;
+ private Observer referenceLineObserver;
+ private Observer surfaceLinesObserver;
+ private Observer stochasticSoilModelsObserver;
+
+ private RecursiveObserver calculationInputObserver;
+ private RecursiveObserver calculationGroupObserver;
+ private RecursiveObserver calculationObserver;
+ private RecursiveObserver surfaceLineObserver;
+
+ ///
+ /// 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 MacroStabilityInwardsFailureMechanismView(MacroStabilityInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ InitializeComponent();
+
+ FailureMechanism = failureMechanism;
+ AssessmentSection = assessmentSection;
+ }
+
+ ///
+ /// Gets the failure mechanism.
+ ///
+ public MacroStabilityInwardsFailureMechanism FailureMechanism { get; }
+
+ ///
+ /// Gets the assessment section.
+ ///
+ public IAssessmentSection AssessmentSection { get; }
+
+ public object Data { get; set; }
+
+ public IMapControl Map
+ {
+ get
+ {
+ return riskeerMapControl.MapControl;
+ }
+ }
+
+ ///
+ /// Gets the .
+ ///
+ protected MapDataCollection MapDataCollection { get; private set; }
+
+ protected override void OnLoad(EventArgs e)
+ {
+ CreateObservers();
+
+ CreateMapData();
+
+ SetAllMapDataFeatures();
+
+ riskeerMapControl.SetAllData(MapDataCollection, AssessmentSection.BackgroundData);
+
+ base.OnLoad(e);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ hydraulicBoundaryLocationsMapLayer.Dispose();
+
+ assessmentSectionObserver.Dispose();
+ referenceLineObserver.Dispose();
+ stochasticSoilModelsObserver.Dispose();
+ calculationInputObserver.Dispose();
+ calculationGroupObserver.Dispose();
+ calculationObserver.Dispose();
+ surfaceLinesObserver.Dispose();
+ surfaceLineObserver.Dispose();
+
+ if (disposing)
+ {
+ components?.Dispose();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ ///
+ /// Creates the map data.
+ ///
+ protected virtual void CreateMapData()
+ {
+ hydraulicBoundaryLocationsMapLayer = new HydraulicBoundaryLocationsMapLayer(AssessmentSection);
+ MapDataCollection = new MapDataCollection(MacroStabilityInwardsDataResources.MacroStabilityInwardsFailureMechanism_DisplayName);
+ referenceLineMapData = RiskeerMapDataFactory.CreateReferenceLineMapData();
+ stochasticSoilModelsMapData = RiskeerMapDataFactory.CreateStochasticSoilModelsMapData();
+ surfaceLinesMapData = RiskeerMapDataFactory.CreateSurfaceLinesMapData();
+ calculationsMapData = RiskeerMapDataFactory.CreateCalculationsMapData();
+
+ MapDataCollection.Add(referenceLineMapData);
+ MapDataCollection.Add(stochasticSoilModelsMapData);
+ MapDataCollection.Add(surfaceLinesMapData);
+ MapDataCollection.Add(hydraulicBoundaryLocationsMapLayer.MapData);
+ MapDataCollection.Add(calculationsMapData);
+ }
+
+ ///
+ /// Creates the observers.
+ ///
+ protected virtual void CreateObservers()
+ {
+ assessmentSectionObserver = new Observer(UpdateReferenceLineMapData)
+ {
+ Observable = AssessmentSection
+ };
+ referenceLineObserver = new Observer(UpdateReferenceLineMapData)
+ {
+ Observable = AssessmentSection.ReferenceLine
+ };
+ surfaceLinesObserver = new Observer(UpdateSurfaceLinesMapData)
+ {
+ Observable = FailureMechanism.SurfaceLines
+ };
+ stochasticSoilModelsObserver = new Observer(UpdateStochasticSoilModelsMapData)
+ {
+ Observable = FailureMechanism.StochasticSoilModels
+ };
+
+ calculationInputObserver = new RecursiveObserver(
+ UpdateCalculationsMapData, pcg => pcg.Children.Concat(pcg.Children.OfType().Select(pc => pc.InputParameters)))
+ {
+ Observable = FailureMechanism.CalculationsGroup
+ };
+ calculationGroupObserver = new RecursiveObserver(UpdateCalculationsMapData, pcg => pcg.Children)
+ {
+ Observable = FailureMechanism.CalculationsGroup
+ };
+ calculationObserver = new RecursiveObserver(UpdateCalculationsMapData, pcg => pcg.Children)
+ {
+ Observable = FailureMechanism.CalculationsGroup
+ };
+
+ surfaceLineObserver = new RecursiveObserver(UpdateSurfaceLinesMapData, rpslc => rpslc)
+ {
+ Observable = FailureMechanism.SurfaceLines
+ };
+ }
+
+ ///
+ /// Sets all map data features.
+ ///
+ protected virtual void SetAllMapDataFeatures()
+ {
+ SetCalculationsMapData();
+ SetReferenceLineMapData();
+
+ SetSurfaceLinesMapData();
+ SetStochasticSoilModelsMapData();
+ }
+
+ #region Calculations MapData
+
+ private void UpdateCalculationsMapData()
+ {
+ SetCalculationsMapData();
+ calculationsMapData.NotifyObservers();
+ }
+
+ private void SetCalculationsMapData()
+ {
+ IEnumerable calculations =
+ FailureMechanism.CalculationsGroup.GetCalculations().Cast();
+ calculationsMapData.Features = MacroStabilityInwardsMapDataFeaturesFactory.CreateCalculationFeatures(calculations);
+ }
+
+ #endregion
+
+ #region AssessmentSection MapData
+
+ private void UpdateReferenceLineMapData()
+ {
+ SetReferenceLineMapData();
+ referenceLineMapData.NotifyObservers();
+ }
+
+ private void SetReferenceLineMapData()
+ {
+ ReferenceLine referenceLine = AssessmentSection.ReferenceLine;
+ referenceLineMapData.Features = RiskeerMapDataFeaturesFactory.CreateReferenceLineFeatures(referenceLine, AssessmentSection.Id, AssessmentSection.Name);
+ }
+
+ #endregion
+
+ #region SurfaceLines MapData
+
+ private void UpdateSurfaceLinesMapData()
+ {
+ SetSurfaceLinesMapData();
+ surfaceLinesMapData.NotifyObservers();
+ }
+
+ private void SetSurfaceLinesMapData()
+ {
+ MacroStabilityInwardsSurfaceLineCollection macroStabilityInwardsSurfaceLines = FailureMechanism.SurfaceLines;
+ surfaceLinesMapData.Features = MacroStabilityInwardsMapDataFeaturesFactory.CreateSurfaceLineFeatures(macroStabilityInwardsSurfaceLines.ToArray());
+ }
+
+ #endregion
+
+ #region StochasticSoilModels MapData
+
+ private void UpdateStochasticSoilModelsMapData()
+ {
+ SetStochasticSoilModelsMapData();
+ stochasticSoilModelsMapData.NotifyObservers();
+ }
+
+ private void SetStochasticSoilModelsMapData()
+ {
+ MacroStabilityInwardsStochasticSoilModelCollection stochasticSoilModels = FailureMechanism.StochasticSoilModels;
+ stochasticSoilModelsMapData.Features = MacroStabilityInwardsMapDataFeaturesFactory.CreateStochasticSoilModelFeatures(stochasticSoilModels.ToArray());
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.resx
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.resx (revision 0)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/CalculationsState/MacroStabilityInwardsFailureMechanismView.resx (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -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
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.Designer.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.resx'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailurePathView.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/RegistrationState/MacroStabilityInwardsFailureMechanismView.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/RegistrationState/MacroStabilityInwardsFailureMechanismView.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/Views/RegistrationState/MacroStabilityInwardsFailureMechanismView.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,123 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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 Core.Common.Base;
+using Core.Components.Gis.Data;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Forms.Factories;
+using Riskeer.Common.Forms.MapLayers;
+using Riskeer.MacroStabilityInwards.Data;
+using MacroStabilityInwardsDataResources = Riskeer.MacroStabilityInwards.Data.Properties.Resources;
+
+namespace Riskeer.MacroStabilityInwards.Forms.Views.RegistrationState
+{
+ ///
+ /// Registration state view showing map data for a macro stability inwards failure mechanism.
+ ///
+ public class MacroStabilityInwardsFailureMechanismView : CalculationsState.MacroStabilityInwardsFailureMechanismView
+ {
+ private MapLineData sectionsMapData;
+ private MapPointData sectionsStartPointMapData;
+ private MapPointData sectionsEndPointMapData;
+
+ private CalculatableFailureMechanismSectionResultsMapLayer assemblyResultsMapLayer;
+
+ private Observer failureMechanismObserver;
+
+ ///
+ /// 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 MacroStabilityInwardsFailureMechanismView(MacroStabilityInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ : base(failureMechanism, assessmentSection) {}
+
+ protected override void Dispose(bool disposing)
+ {
+ failureMechanismObserver.Dispose();
+ assemblyResultsMapLayer.Dispose();
+
+ base.Dispose(disposing);
+ }
+
+ protected override void CreateMapData()
+ {
+ base.CreateMapData();
+
+ MapDataCollection sectionsMapDataCollection = RiskeerMapDataFactory.CreateSectionsMapDataCollection();
+ sectionsMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsMapData();
+ sectionsStartPointMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsStartPointMapData();
+ sectionsEndPointMapData = RiskeerMapDataFactory.CreateFailureMechanismSectionsEndPointMapData();
+
+ assemblyResultsMapLayer = new CalculatableFailureMechanismSectionResultsMapLayer(
+ FailureMechanism, sr => MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleSection(sr, FailureMechanism, AssessmentSection));
+
+ sectionsMapDataCollection.Add(sectionsMapData);
+ sectionsMapDataCollection.Add(sectionsStartPointMapData);
+ sectionsMapDataCollection.Add(sectionsEndPointMapData);
+ MapDataCollection.Insert(3, sectionsMapDataCollection);
+
+ MapDataCollection.Insert(4, assemblyResultsMapLayer.MapData);
+ }
+
+ protected override void CreateObservers()
+ {
+ base.CreateObservers();
+
+ failureMechanismObserver = new Observer(UpdateFailureMechanismMapData)
+ {
+ Observable = FailureMechanism
+ };
+ }
+
+ protected override void SetAllMapDataFeatures()
+ {
+ base.SetAllMapDataFeatures();
+
+ SetSectionsMapData();
+ }
+
+ #region FailureMechanism MapData
+
+ private void UpdateFailureMechanismMapData()
+ {
+ SetSectionsMapData();
+ sectionsMapData.NotifyObservers();
+ sectionsStartPointMapData.NotifyObservers();
+ sectionsEndPointMapData.NotifyObservers();
+ }
+
+ private void SetSectionsMapData()
+ {
+ IEnumerable failureMechanismSections = FailureMechanism.Sections;
+
+ sectionsMapData.Features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionFeatures(failureMechanismSections);
+ sectionsStartPointMapData.Features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionStartPointFeatures(failureMechanismSections);
+ sectionsEndPointMapData.Features = RiskeerMapDataFeaturesFactory.CreateFailureMechanismSectionEndPointFeatures(failureMechanismSections);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs
===================================================================
diff -u -r28c89f52a156d628eb86a1807d03e6b49de5ba89 -r683f8939ea395ffe9b29a54cc87005244a5af182
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -63,6 +63,8 @@
using Riskeer.MacroStabilityInwards.Service;
using CalculationsStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState.MacroStabilityInwardsFailureMechanismProperties;
using RegistrationStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState.MacroStabilityInwardsFailureMechanismProperties;
+using CalculationsStateFailureMechanismView = Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState.MacroStabilityInwardsFailureMechanismView;
+using RegistrationStateFailureMechanismView = Riskeer.MacroStabilityInwards.Forms.Views.RegistrationState.MacroStabilityInwardsFailureMechanismView;
using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources;
using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources;
@@ -245,17 +247,17 @@
public override IEnumerable GetViewInfos()
{
- yield return new RiskeerViewInfo(() => Gui)
+ yield return new RiskeerViewInfo(() => Gui)
{
GetViewName = (view, context) => context.WrappedData.Name,
- CreateInstance = context => new MacroStabilityInwardsFailureMechanismView(context.WrappedData, context.Parent)
+ CreateInstance = context => new CalculationsStateFailureMechanismView(context.WrappedData, context.Parent)
};
- yield return new RiskeerViewInfo(() => Gui)
+ yield return new RiskeerViewInfo(() => Gui)
{
GetViewName = (view, context) => context.WrappedData.Name,
AdditionalDataCheck = context => context.WrappedData.InAssembly,
- CreateInstance = context => new MacroStabilityInwardsFailurePathView(context.WrappedData, context.Parent),
+ CreateInstance = context => new RegistrationStateFailureMechanismView(context.WrappedData, context.Parent),
CloseForData = CloseFailurePathViewForData
};
@@ -453,7 +455,7 @@
#region ViewInfos
- private static bool CloseFailurePathViewForData(MacroStabilityInwardsFailurePathView view, object dataToCloseFor)
+ private static bool CloseFailurePathViewForData(RegistrationStateFailureMechanismView view, object dataToCloseFor)
{
var failureMechanism = dataToCloseFor as MacroStabilityInwardsFailureMechanism;
@@ -762,7 +764,7 @@
nodeData.FailureMechanism,
nodeData.AssessmentSection));
}
- else if (item is CalculationGroup @group)
+ else if (item is CalculationGroup group)
{
childNodeObjects.Add(new MacroStabilityInwardsCalculationGroupContext(group,
nodeData.WrappedData,
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/CalculationsState/MacroStabilityInwardsFailureMechanismViewTest.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/CalculationsState/MacroStabilityInwardsFailureMechanismViewTest.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/CalculationsState/MacroStabilityInwardsFailureMechanismViewTest.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,777 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Collections.ObjectModel;
+using System.Linq;
+using System.Threading;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Forms;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Forms.TestUtil;
+using Riskeer.Common.Forms.Views;
+using Riskeer.MacroStabilityInwards.Data;
+using Riskeer.MacroStabilityInwards.Data.SoilProfile;
+using Riskeer.MacroStabilityInwards.Data.TestUtil;
+using Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState;
+using Riskeer.MacroStabilityInwards.Primitives;
+
+namespace Riskeer.MacroStabilityInwards.Forms.Test.Views.CalculationsState
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismViewTest
+ {
+ private const int referenceLineIndex = 0;
+ private const int stochasticSoilModelsIndex = 1;
+ private const int surfaceLinesIndex = 2;
+ private const int hydraulicBoundaryLocationsIndex = 3;
+ private const int calculationsIndex = 4;
+
+ private const int calculationObserverIndex = 3;
+
+ private Form testForm;
+
+ [SetUp]
+ public void Setup()
+ {
+ testForm = new Form();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ testForm.Dispose();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ void Call() => new MacroStabilityInwardsFailureMechanismView(null, assessmentSection);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => new MacroStabilityInwardsFailureMechanismView(new MacroStabilityInwardsFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ MacroStabilityInwardsFailureMechanismView view = CreateView(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, ((RiskeerMapControl) view.Controls[0]).MapControl);
+ Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock);
+ AssertEmptyMapData(view.Map.Data);
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_AssessmentSectionWithBackgroundData_BackgroundDataSet()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ MacroStabilityInwardsFailureMechanismView view = CreateView(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ // Assert
+ MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, view.Map.BackgroundMapData);
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_WithAllData_DataUpdatedToCollectionOfFilledMapData()
+ {
+ // Setup
+ MacroStabilityInwardsStochasticSoilModel stochasticSoilModel1 =
+ MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name1", new[]
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(1.1, 2.2)
+ });
+
+ MacroStabilityInwardsStochasticSoilModel stochasticSoilModel2 =
+ MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name2", new[]
+ {
+ new Point2D(3.0, 4.0),
+ new Point2D(3.3, 4.4)
+ });
+
+ var surfaceLineA = new MacroStabilityInwardsSurfaceLine("Line A");
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+
+ var surfaceLineB = new MacroStabilityInwardsSurfaceLine("Name B");
+ surfaceLineB.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.5),
+ new Point3D(3.0, 0.0, 1.8)
+ });
+ surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
+ surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);
+
+ 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 failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ const string arbitraryFilePath = "path";
+ failureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLineA,
+ surfaceLineB
+ }, arbitraryFilePath);
+ 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))
+ });
+ failureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ stochasticSoilModel1,
+ stochasticSoilModel2
+ }, arbitraryFilePath);
+
+ var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(1, "test", 1.0, 2.0);
+ var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(2, "test", 3.0, 4.0);
+
+ MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation1);
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+ MacroStabilityInwardsCalculationScenario calculationB = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation2);
+ calculationB.InputParameters.SurfaceLine = surfaceLineB;
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
+
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(0.0, 3.0),
+ new Point2D(3.0, 0.0)
+ });
+
+ var assessmentSection = new AssessmentSectionStub
+ {
+ ReferenceLine = referenceLine
+ };
+
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation1,
+ hydraulicBoundaryLocation2
+ });
+
+ // Call
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, assessmentSection);
+
+ IMapControl map = ((RiskeerMapControl) 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]);
+ AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, mapDataList[surfaceLinesIndex]);
+
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapDataList[hydraulicBoundaryLocationsIndex]);
+ AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, mapDataList[stochasticSoilModelsIndex]);
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), mapDataList[calculationsIndex]);
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ 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
+ };
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ var referenceLineMapData = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex);
+
+ // Precondition
+ MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features);
+
+ // When
+ assessmentSection.Name = "New name";
+ assessmentSection.NotifyObservers();
+
+ // Then
+ MapFeaturesTestHelper.AssertReferenceLineMetaData(assessmentSection.ReferenceLine, assessmentSection, referenceLineMapData.Features);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ 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
+ };
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ IMapControl map = ((RiskeerMapControl) 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);
+
+ // When
+ referenceLine.SetGeometry(new List
+ {
+ new Point2D(2.0, 5.0),
+ new Point2D(4.0, 3.0)
+ });
+ referenceLine.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithSurfaceLinesData_WhenSurfaceLinesUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLine.SetGeometry(new Collection
+ {
+ new Point3D(1, 2, 3),
+ new Point3D(4, 5, 6)
+ });
+
+ var surfaceLineMapData = (MapLineData) map.Data.Collection.ElementAt(surfaceLinesIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ failureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "path");
+ failureMechanism.SurfaceLines.NotifyObservers();
+
+ // Then
+ AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "path");
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ surfaceLine.SetGeometry(new[]
+ {
+ new Point3D(7, 8, 9),
+ new Point3D(10, 11, 12)
+ });
+ surfaceLine.NotifyObservers();
+
+ // Then
+ var surfaceLineMapData = (MapLineData) map.Data.Collection.ElementAt(surfaceLinesIndex);
+ AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, surfaceLineMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithStochasticSoilModels_WhenStochasticSoilModelsUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var stochasticSoilModelMapData = (MapLineData) map.Data.Collection.ElementAt(stochasticSoilModelsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ failureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("", new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(1, 2)
+ })
+ }, "path");
+ failureMechanism.StochasticSoilModels.NotifyObservers();
+
+ // Then
+ AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, stochasticSoilModelMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+ surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
+
+ MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var surfaceLineB = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLineB.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.5),
+ new Point3D(3.0, 0.0, 1.8)
+ });
+ surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);
+
+ MacroStabilityInwardsCalculationScenario calculationB = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
+ calculationB.InputParameters.SurfaceLine = surfaceLineB;
+
+ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[calculationObserverIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
+ failureMechanism.CalculationsGroup.NotifyObservers();
+
+ // Then
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+ surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
+
+ MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var surfaceLineB = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLineB.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.5),
+ new Point3D(3.0, 0.0, 1.8)
+ });
+ surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);
+
+ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[calculationObserverIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ calculationA.InputParameters.SurfaceLine = surfaceLineB;
+ calculationA.InputParameters.NotifyObservers();
+
+ // Then
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var surfaceLineA = new MacroStabilityInwardsSurfaceLine(string.Empty);
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+ surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
+
+ MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[calculationObserverIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ calculationA.Name = "new name";
+ calculationA.NotifyObservers();
+
+ // Then
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void UpdateObserver_DataUpdated_MapLayersSameOrder()
+ {
+ // Setup
+ const int updatedReferenceLineLayerIndex = referenceLineIndex + 4;
+ const int updatedSurfaceLineLayerIndex = surfaceLinesIndex - 1;
+ const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1;
+ const int updatedStochasticSoilModelsLayerIndex = stochasticSoilModelsIndex - 1;
+ const int updatedCalculationsIndex = calculationsIndex - 1;
+
+ var assessmentSection = new AssessmentSectionStub();
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ MapDataCollection mapData = map.Data;
+
+ var dataToMove = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex);
+ mapData.Remove(dataToMove);
+ mapData.Add(dataToMove);
+
+ IEnumerable mapDataCollection = mapData.Collection;
+
+ // Precondition
+ var referenceLineData = (MapLineData) mapDataCollection.ElementAt(updatedReferenceLineLayerIndex);
+ Assert.AreEqual("Referentielijn", referenceLineData.Name);
+
+ var surfaceLineData = (MapLineData) mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex);
+ Assert.AreEqual("Profielschematisaties", surfaceLineData.Name);
+
+ var hydraulicLocationsData = (MapPointData) mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex);
+ Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name);
+
+ var stochasticSoilModelsData = (MapLineData) mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex);
+ Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsData.Name);
+
+ var calculationsData = (MapLineData) mapDataCollection.ElementAt(updatedCalculationsIndex);
+ Assert.AreEqual("Berekeningen", calculationsData.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) mapDataCollection.ElementAt(updatedReferenceLineLayerIndex);
+ Assert.AreEqual("Referentielijn", actualReferenceLineData.Name);
+
+ var actualSurfaceLineData = (MapLineData) mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex);
+ Assert.AreEqual("Profielschematisaties", actualSurfaceLineData.Name);
+
+ var actualHydraulicLocationsData = (MapPointData) mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex);
+ Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name);
+
+ var actualStochasticSoilModelsData = (MapLineData) mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex);
+ Assert.AreEqual("Stochastische ondergrondmodellen", actualStochasticSoilModelsData.Name);
+
+ var actualCalculationsData = (MapLineData) mapDataCollection.ElementAt(updatedCalculationsIndex);
+ Assert.AreEqual("Berekeningen", actualCalculationsData.Name);
+ }
+
+ private MacroStabilityInwardsFailureMechanismView CreateView(MacroStabilityInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ {
+ var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection);
+
+ testForm.Controls.Add(view);
+ testForm.Show();
+
+ return view;
+ }
+
+ private static void AssertSurfaceLinesMapData(IEnumerable surfaceLines, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var surfaceLinesMapData = (MapLineData) mapData;
+ MapFeature[] surfaceLineFeatures = surfaceLinesMapData.Features.ToArray();
+ MacroStabilityInwardsSurfaceLine[] surfaceLinesArray = surfaceLines.ToArray();
+ Assert.AreEqual(surfaceLinesArray.Length, surfaceLineFeatures.Length);
+
+ for (var index = 0; index < surfaceLinesArray.Length; index++)
+ {
+ Assert.AreEqual(1, surfaceLineFeatures[index].MapGeometries.Count());
+ MacroStabilityInwardsSurfaceLine surfaceLine = surfaceLinesArray[index];
+ CollectionAssert.AreEquivalent(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)), surfaceLineFeatures[index].MapGeometries.First().PointCollections.First());
+ }
+
+ Assert.AreEqual("Profielschematisaties", mapData.Name);
+ }
+
+ private static void AssertStochasticSoilModelsMapData(IEnumerable soilModels, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var soilModelsMapData = (MapLineData) mapData;
+ MapFeature[] soilModelsFeatures = soilModelsMapData.Features.ToArray();
+ MacroStabilityInwardsStochasticSoilModel[] stochasticSoilModelsArray = soilModels.ToArray();
+ Assert.AreEqual(stochasticSoilModelsArray.Length, soilModelsFeatures.Length);
+
+ for (var index = 0; index < stochasticSoilModelsArray.Length; index++)
+ {
+ Assert.AreEqual(1, soilModelsFeatures[index].MapGeometries.Count());
+ MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = stochasticSoilModelsArray[index];
+ CollectionAssert.AreEquivalent(stochasticSoilModel.Geometry.Select(p => new Point2D(p)), soilModelsFeatures[index].MapGeometries.First().PointCollections.First());
+ }
+
+ Assert.AreEqual("Stochastische ondergrondmodellen", mapData.Name);
+ }
+
+ private static void AssertCalculationsMapData(IEnumerable calculations, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var calculationsMapData = (MapLineData) mapData;
+ MacroStabilityInwardsCalculationScenario[] calculationsArray = calculations.ToArray();
+ MapFeature[] calculationsFeatures = calculationsMapData.Features.ToArray();
+ Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length);
+
+ for (var index = 0; index < calculationsArray.Length; index++)
+ {
+ MapGeometry[] geometries = calculationsFeatures[index].MapGeometries.ToArray();
+ Assert.AreEqual(1, geometries.Length);
+
+ MacroStabilityInwardsCalculationScenario calculation = calculationsArray[index];
+ CollectionAssert.AreEquivalent(new[]
+ {
+ calculation.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint,
+ calculation.InputParameters.HydraulicBoundaryLocation.Location
+ },
+ geometries[0].PointCollections.First());
+ }
+
+ Assert.AreEqual("Berekeningen", mapData.Name);
+ }
+
+ private static void AssertEmptyMapData(MapDataCollection mapDataCollection)
+ {
+ Assert.AreEqual("Macrostabiliteit binnenwaarts", mapDataCollection.Name);
+
+ List mapDataList = mapDataCollection.Collection.ToList();
+
+ Assert.AreEqual(5, mapDataList.Count);
+
+ var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex];
+ var stochasticSoilModelsMapData = (MapLineData) mapDataList[stochasticSoilModelsIndex];
+ var surfaceLinesMapData = (MapLineData) mapDataList[surfaceLinesIndex];
+ var hydraulicBoundaryLocationsMapData = (MapPointData) mapDataList[hydraulicBoundaryLocationsIndex];
+ var calculationsMapData = (MapLineData) mapDataList[calculationsIndex];
+
+ CollectionAssert.IsEmpty(referenceLineMapData.Features);
+ CollectionAssert.IsEmpty(stochasticSoilModelsMapData.Features);
+ CollectionAssert.IsEmpty(surfaceLinesMapData.Features);
+ CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features);
+ CollectionAssert.IsEmpty(calculationsMapData.Features);
+
+ Assert.AreEqual("Referentielijn", referenceLineMapData.Name);
+ Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsMapData.Name);
+ Assert.AreEqual("Profielschematisaties", surfaceLinesMapData.Name);
+ Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.Name);
+ Assert.AreEqual("Berekeningen", calculationsMapData.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 stochasticSoilModelsMapDataObserver = mocks.StrictMock();
+ mapDataArray[stochasticSoilModelsIndex].Attach(stochasticSoilModelsMapDataObserver);
+
+ var surfaceLinesMapDataObserver = mocks.StrictMock();
+ mapDataArray[surfaceLinesIndex].Attach(surfaceLinesMapDataObserver);
+
+ var calculationsMapDataObserver = mocks.StrictMock();
+ mapDataArray[calculationsIndex].Attach(calculationsMapDataObserver);
+
+ return new[]
+ {
+ referenceLineMapDataObserver,
+ stochasticSoilModelsMapDataObserver,
+ surfaceLinesMapDataObserver,
+ calculationsMapDataObserver
+ };
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailurePathViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/RegistrationState/MacroStabilityInwardsFailureMechanismViewTest.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/RegistrationState/MacroStabilityInwardsFailureMechanismViewTest.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/Views/RegistrationState/MacroStabilityInwardsFailureMechanismViewTest.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,496 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Forms;
+using Core.Components.Gis.Geometries;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.AssemblyTool.KernelWrapper.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Forms.TestUtil;
+using Riskeer.Common.Forms.Views;
+using Riskeer.MacroStabilityInwards.Data;
+using Riskeer.MacroStabilityInwards.Data.SoilProfile;
+using Riskeer.MacroStabilityInwards.Data.TestUtil;
+using Riskeer.MacroStabilityInwards.Forms.Views.RegistrationState;
+using Riskeer.MacroStabilityInwards.Primitives;
+using CalculationsStateFailureMechanismView = Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState.MacroStabilityInwardsFailureMechanismView;
+
+namespace Riskeer.MacroStabilityInwards.Forms.Test.Views.RegistrationState
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismViewTest
+ {
+ private const int referenceLineIndex = 0;
+ private const int stochasticSoilModelsIndex = 1;
+ private const int surfaceLinesIndex = 2;
+ private const int sectionsCollectionIndex = 3;
+ private const int assemblyResultsIndex = 4;
+ private const int hydraulicBoundaryLocationsIndex = 5;
+ private const int calculationsIndex = 6;
+
+ private const int sectionsIndex = 0;
+ private const int sectionsStartPointIndex = 1;
+ private const int sectionsEndPointIndex = 2;
+
+ private const int sectionsObserverIndex = 0;
+ private const int sectionsStartPointObserverIndex = 1;
+ private const int sectionsEndPointObserverIndex = 2;
+
+ private Form testForm;
+
+ [SetUp]
+ public void Setup()
+ {
+ testForm = new Form();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ testForm.Dispose();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var assessmentSection = new AssessmentSectionStub();
+
+ // Call
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf(view);
+ Assert.IsNull(view.Data);
+ Assert.AreSame(failureMechanism, view.FailureMechanism);
+ Assert.AreSame(assessmentSection, view.AssessmentSection);
+ AssertEmptyMapData(view.Map.Data);
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void Constructor_WithAllData_DataUpdatedToCollectionOfFilledMapData()
+ {
+ // Setup
+ MacroStabilityInwardsStochasticSoilModel stochasticSoilModel1 =
+ MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name1", new[]
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(1.1, 2.2)
+ });
+
+ MacroStabilityInwardsStochasticSoilModel stochasticSoilModel2 =
+ MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel("name2", new[]
+ {
+ new Point2D(3.0, 4.0),
+ new Point2D(3.3, 4.4)
+ });
+
+ var surfaceLineA = new MacroStabilityInwardsSurfaceLine("Line A");
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+
+ var surfaceLineB = new MacroStabilityInwardsSurfaceLine("Name B");
+ surfaceLineB.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.5),
+ new Point3D(3.0, 0.0, 1.8)
+ });
+ surfaceLineA.ReferenceLineIntersectionWorldPoint = new Point2D(1.3, 1.3);
+ surfaceLineB.ReferenceLineIntersectionWorldPoint = new Point2D(1.5, 1.5);
+
+ 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 failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ const string arbitraryFilePath = "path";
+ failureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLineA,
+ surfaceLineB
+ }, arbitraryFilePath);
+ 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))
+ });
+ failureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ stochasticSoilModel1,
+ stochasticSoilModel2
+ }, arbitraryFilePath);
+
+ var hydraulicBoundaryLocation1 = new HydraulicBoundaryLocation(1, "test", 1.0, 2.0);
+ var hydraulicBoundaryLocation2 = new HydraulicBoundaryLocation(2, "test", 3.0, 4.0);
+
+ MacroStabilityInwardsCalculationScenario calculationA = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation1);
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+ MacroStabilityInwardsCalculationScenario calculationB = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(hydraulicBoundaryLocation2);
+ calculationB.InputParameters.SurfaceLine = surfaceLineB;
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
+
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(0.0, 3.0),
+ new Point2D(3.0, 0.0)
+ });
+
+ var assessmentSection = new AssessmentSectionStub
+ {
+ ReferenceLine = referenceLine
+ };
+
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation1,
+ hydraulicBoundaryLocation2
+ });
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ // Call
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, assessmentSection);
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ // Assert
+ MapDataCollection mapData = map.Data;
+ Assert.IsInstanceOf(mapData);
+
+ List mapDataList = mapData.Collection.ToList();
+ Assert.AreEqual(7, mapDataList.Count);
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]);
+ AssertSurfaceLinesMapData(failureMechanism.SurfaceLines, mapDataList[surfaceLinesIndex]);
+
+ IEnumerable sectionsCollection = ((MapDataCollection) mapDataList[sectionsCollectionIndex]).Collection;
+ MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsIndex));
+ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsStartPointIndex));
+ MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsCollection.ElementAt(sectionsEndPointIndex));
+
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(assessmentSection, mapDataList[hydraulicBoundaryLocationsIndex]);
+ AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, mapDataList[stochasticSoilModelsIndex]);
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), mapDataList[calculationsIndex]);
+
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorFactory.LastCreatedFailureMechanismSectionAssemblyCalculator;
+ MapDataTestHelper.AssertAssemblyMapData(failureMechanism, calculator.FailureMechanismSectionAssemblyResultOutput, mapDataList[assemblyResultsIndex]);
+ }
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(failureMechanism, new AssessmentSectionStub());
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ IEnumerable sectionsCollection = ((MapDataCollection) map.Data.Collection.ElementAt(sectionsCollectionIndex)).Collection;
+ var sectionMapData = (MapLineData) sectionsCollection.ElementAt(sectionsIndex);
+ var sectionStartsMapData = (MapPointData) sectionsCollection.ElementAt(sectionsStartPointIndex);
+ var sectionsEndsMapData = (MapPointData) sectionsCollection.ElementAt(sectionsEndPointIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[sectionsObserverIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsStartPointObserverIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsEndPointObserverIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ FailureMechanismTestHelper.SetSections(failureMechanism, new[]
+ {
+ new FailureMechanismSection(string.Empty, new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(1, 2)
+ })
+ });
+ failureMechanism.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, sectionMapData);
+ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, sectionStartsMapData);
+ MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, sectionsEndsMapData);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [Apartment(ApartmentState.STA)]
+ public void UpdateObserver_DataUpdated_MapLayersSameOrder()
+ {
+ // Setup
+ const int updatedReferenceLineLayerIndex = referenceLineIndex + 6;
+ const int updatedSurfaceLineLayerIndex = surfaceLinesIndex - 1;
+ const int updatedSectionCollectionIndex = sectionsCollectionIndex - 1;
+ const int updatedAssemblyResultsIndex = assemblyResultsIndex - 1;
+ const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1;
+ const int updatedStochasticSoilModelsLayerIndex = stochasticSoilModelsIndex - 1;
+ const int updatedCalculationsIndex = calculationsIndex - 1;
+
+ var assessmentSection = new AssessmentSectionStub();
+
+ MacroStabilityInwardsFailureMechanismView view = CreateView(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ IMapControl map = ((RiskeerMapControl) view.Controls[0]).MapControl;
+
+ MapDataCollection mapData = map.Data;
+
+ var dataToMove = (MapLineData) map.Data.Collection.ElementAt(referenceLineIndex);
+ mapData.Remove(dataToMove);
+ mapData.Add(dataToMove);
+
+ IEnumerable mapDataCollection = mapData.Collection;
+
+ // Precondition
+ var referenceLineData = (MapLineData) mapDataCollection.ElementAt(updatedReferenceLineLayerIndex);
+ Assert.AreEqual("Referentielijn", referenceLineData.Name);
+
+ var surfaceLineData = (MapLineData) mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex);
+ Assert.AreEqual("Profielschematisaties", surfaceLineData.Name);
+
+ var sectionsData = (MapDataCollection) mapDataCollection.ElementAt(updatedSectionCollectionIndex);
+ Assert.AreEqual("Vakindeling", sectionsData.Name);
+
+ var assemblyResultsData = (MapLineData) mapDataCollection.ElementAt(updatedAssemblyResultsIndex);
+ Assert.AreEqual("Duidingsklasse per vak", assemblyResultsData.Name);
+
+ var hydraulicLocationsData = (MapPointData) mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex);
+ Assert.AreEqual("Hydraulische belastingen", hydraulicLocationsData.Name);
+
+ var stochasticSoilModelsData = (MapLineData) mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex);
+ Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsData.Name);
+
+ var calculationsData = (MapLineData) mapDataCollection.ElementAt(updatedCalculationsIndex);
+ Assert.AreEqual("Berekeningen", calculationsData.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) mapDataCollection.ElementAt(updatedReferenceLineLayerIndex);
+ Assert.AreEqual("Referentielijn", actualReferenceLineData.Name);
+
+ var actualSurfaceLineData = (MapLineData) mapDataCollection.ElementAt(updatedSurfaceLineLayerIndex);
+ Assert.AreEqual("Profielschematisaties", actualSurfaceLineData.Name);
+
+ var actualSectionsData = (MapDataCollection) mapDataCollection.ElementAt(updatedSectionCollectionIndex);
+ Assert.AreEqual("Vakindeling", actualSectionsData.Name);
+
+ var actualAssemblyResultsData = (MapLineData) mapDataCollection.ElementAt(updatedAssemblyResultsIndex);
+ Assert.AreEqual("Duidingsklasse per vak", actualAssemblyResultsData.Name);
+
+ var actualHydraulicLocationsData = (MapPointData) mapDataCollection.ElementAt(updatedHydraulicLocationsLayerIndex);
+ Assert.AreEqual("Hydraulische belastingen", actualHydraulicLocationsData.Name);
+
+ var actualStochasticSoilModelsData = (MapLineData) mapDataCollection.ElementAt(updatedStochasticSoilModelsLayerIndex);
+ Assert.AreEqual("Stochastische ondergrondmodellen", actualStochasticSoilModelsData.Name);
+
+ var actualCalculationsData = (MapLineData) mapDataCollection.ElementAt(updatedCalculationsIndex);
+ Assert.AreEqual("Berekeningen", actualCalculationsData.Name);
+ }
+
+ private MacroStabilityInwardsFailureMechanismView CreateView(MacroStabilityInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ {
+ var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection);
+
+ testForm.Controls.Add(view);
+ testForm.Show();
+
+ return view;
+ }
+
+ private static void AssertSurfaceLinesMapData(IEnumerable surfaceLines, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var surfaceLinesMapData = (MapLineData) mapData;
+ MapFeature[] surfaceLineFeatures = surfaceLinesMapData.Features.ToArray();
+ MacroStabilityInwardsSurfaceLine[] surfaceLinesArray = surfaceLines.ToArray();
+ Assert.AreEqual(surfaceLinesArray.Length, surfaceLineFeatures.Length);
+
+ for (var index = 0; index < surfaceLinesArray.Length; index++)
+ {
+ Assert.AreEqual(1, surfaceLineFeatures[index].MapGeometries.Count());
+ MacroStabilityInwardsSurfaceLine surfaceLine = surfaceLinesArray[index];
+ CollectionAssert.AreEquivalent(surfaceLine.Points.Select(p => new Point2D(p.X, p.Y)), surfaceLineFeatures[index].MapGeometries.First().PointCollections.First());
+ }
+
+ Assert.AreEqual("Profielschematisaties", mapData.Name);
+ }
+
+ private static void AssertStochasticSoilModelsMapData(IEnumerable soilModels, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var soilModelsMapData = (MapLineData) mapData;
+ MapFeature[] soilModelsFeatures = soilModelsMapData.Features.ToArray();
+ MacroStabilityInwardsStochasticSoilModel[] stochasticSoilModelsArray = soilModels.ToArray();
+ Assert.AreEqual(stochasticSoilModelsArray.Length, soilModelsFeatures.Length);
+
+ for (var index = 0; index < stochasticSoilModelsArray.Length; index++)
+ {
+ Assert.AreEqual(1, soilModelsFeatures[index].MapGeometries.Count());
+ MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = stochasticSoilModelsArray[index];
+ CollectionAssert.AreEquivalent(stochasticSoilModel.Geometry.Select(p => new Point2D(p)), soilModelsFeatures[index].MapGeometries.First().PointCollections.First());
+ }
+
+ Assert.AreEqual("Stochastische ondergrondmodellen", mapData.Name);
+ }
+
+ private static void AssertCalculationsMapData(IEnumerable calculations, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var calculationsMapData = (MapLineData) mapData;
+ MacroStabilityInwardsCalculationScenario[] calculationsArray = calculations.ToArray();
+ MapFeature[] calculationsFeatures = calculationsMapData.Features.ToArray();
+ Assert.AreEqual(calculationsArray.Length, calculationsFeatures.Length);
+
+ for (var index = 0; index < calculationsArray.Length; index++)
+ {
+ MapGeometry[] geometries = calculationsFeatures[index].MapGeometries.ToArray();
+ Assert.AreEqual(1, geometries.Length);
+
+ MacroStabilityInwardsCalculationScenario calculation = calculationsArray[index];
+ CollectionAssert.AreEquivalent(new[]
+ {
+ calculation.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint,
+ calculation.InputParameters.HydraulicBoundaryLocation.Location
+ },
+ geometries[0].PointCollections.First());
+ }
+
+ Assert.AreEqual("Berekeningen", mapData.Name);
+ }
+
+ private static void AssertEmptyMapData(MapDataCollection mapDataCollection)
+ {
+ Assert.AreEqual("Macrostabiliteit binnenwaarts", mapDataCollection.Name);
+
+ List mapDataList = mapDataCollection.Collection.ToList();
+
+ Assert.AreEqual(7, mapDataList.Count);
+
+ var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex];
+ var stochasticSoilModelsMapData = (MapLineData) mapDataList[stochasticSoilModelsIndex];
+ var surfaceLinesMapData = (MapLineData) mapDataList[surfaceLinesIndex];
+ var assemblyResultsMapData = (MapLineData) mapDataList[assemblyResultsIndex];
+ var hydraulicBoundaryLocationsMapData = (MapPointData) mapDataList[hydraulicBoundaryLocationsIndex];
+ var calculationsMapData = (MapLineData) mapDataList[calculationsIndex];
+
+ CollectionAssert.IsEmpty(referenceLineMapData.Features);
+ CollectionAssert.IsEmpty(stochasticSoilModelsMapData.Features);
+ CollectionAssert.IsEmpty(surfaceLinesMapData.Features);
+ CollectionAssert.IsEmpty(assemblyResultsMapData.Features);
+ CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features);
+ CollectionAssert.IsEmpty(calculationsMapData.Features);
+
+ Assert.AreEqual("Referentielijn", referenceLineMapData.Name);
+ Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsMapData.Name);
+ Assert.AreEqual("Profielschematisaties", surfaceLinesMapData.Name);
+ Assert.AreEqual("Duidingsklasse per vak", assemblyResultsMapData.Name);
+ Assert.AreEqual("Hydraulische belastingen", hydraulicBoundaryLocationsMapData.Name);
+ Assert.AreEqual("Berekeningen", calculationsMapData.Name);
+
+ var sectionsMapDataCollection = (MapDataCollection) mapDataList[sectionsCollectionIndex];
+ Assert.AreEqual("Vakindeling", sectionsMapDataCollection.Name);
+ List sectionsDataList = sectionsMapDataCollection.Collection.ToList();
+ Assert.AreEqual(3, sectionsDataList.Count);
+
+ var sectionsMapData = (MapLineData) sectionsDataList[sectionsIndex];
+ var sectionsStartPointMapData = (MapPointData) sectionsDataList[sectionsStartPointIndex];
+ var sectionsEndPointMapData = (MapPointData) sectionsDataList[sectionsEndPointIndex];
+
+ CollectionAssert.IsEmpty(sectionsEndPointMapData.Features);
+ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features);
+ CollectionAssert.IsEmpty(sectionsMapData.Features);
+
+ Assert.AreEqual("Vakindeling (eindpunten)", sectionsEndPointMapData.Name);
+ Assert.AreEqual("Vakindeling (startpunten)", sectionsStartPointMapData.Name);
+ Assert.AreEqual("Vakindeling", sectionsMapData.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();
+
+ MapData[] sectionsCollection = ((MapDataCollection) mapDataArray[sectionsCollectionIndex]).Collection.ToArray();
+ var sectionsMapDataObserver = mocks.StrictMock();
+ sectionsCollection[sectionsIndex].Attach(sectionsMapDataObserver);
+
+ var sectionsStartPointMapDataObserver = mocks.StrictMock();
+ sectionsCollection[sectionsStartPointIndex].Attach(sectionsStartPointMapDataObserver);
+
+ var sectionsEndPointMapDataObserver = mocks.StrictMock();
+ sectionsCollection[sectionsEndPointIndex].Attach(sectionsEndPointMapDataObserver);
+ return new[]
+ {
+ sectionsMapDataObserver,
+ sectionsStartPointMapDataObserver,
+ sectionsEndPointMapDataObserver
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/MacroStabilityInwardsPluginTest.cs
===================================================================
diff -u -r28c89f52a156d628eb86a1807d03e6b49de5ba89 -r683f8939ea395ffe9b29a54cc87005244a5af182
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/MacroStabilityInwardsPluginTest.cs (.../MacroStabilityInwardsPluginTest.cs) (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/MacroStabilityInwardsPluginTest.cs (.../MacroStabilityInwardsPluginTest.cs) (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -43,6 +43,8 @@
using Riskeer.MacroStabilityInwards.Primitives;
using CalculationsStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState.MacroStabilityInwardsFailureMechanismProperties;
using RegistrationStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState.MacroStabilityInwardsFailureMechanismProperties;
+using CalculationsStateFailureMechanismView = Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState.MacroStabilityInwardsFailureMechanismView;
+using RegistrationStateFailureMechanismView = Riskeer.MacroStabilityInwards.Forms.Views.RegistrationState.MacroStabilityInwardsFailureMechanismView;
namespace Riskeer.MacroStabilityInwards.Plugin.Test
{
@@ -177,12 +179,12 @@
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(MacroStabilityInwardsCalculationsContext),
- typeof(MacroStabilityInwardsFailureMechanismView));
+ typeof(CalculationsStateFailureMechanismView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
typeof(MacroStabilityInwardsFailurePathContext),
- typeof(MacroStabilityInwardsFailurePathView));
+ typeof(RegistrationStateFailureMechanismView));
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/CalculationsState/MacroStabilityInwardsFailureMechanismViewInfoTest.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/CalculationsState/MacroStabilityInwardsFailureMechanismViewInfoTest.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/CalculationsState/MacroStabilityInwardsFailureMechanismViewInfoTest.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,97 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Linq;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.MacroStabilityInwards.Data;
+using Riskeer.MacroStabilityInwards.Forms.PresentationObjects;
+using Riskeer.MacroStabilityInwards.Forms.Views.CalculationsState;
+
+namespace Riskeer.MacroStabilityInwards.Plugin.Test.ViewInfos.CalculationsState
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismViewInfoTest
+ {
+ private MockRepository mocks;
+ private MacroStabilityInwardsPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new MacroStabilityInwardsPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(MacroStabilityInwardsFailureMechanismView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(MacroStabilityInwardsCalculationsContext), info.DataType);
+ Assert.AreEqual(typeof(MacroStabilityInwardsCalculationsContext), info.ViewDataType);
+ }
+
+ [Test]
+ public void GetViewName_WithContext_ReturnsNameOfFailureMechanism()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var context = new MacroStabilityInwardsCalculationsContext(failureMechanism, assessmentSection);
+
+ // Call
+ string viewName = info.GetViewName(null, context);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Name, viewName);
+ }
+
+ [Test]
+ public void CreateInstance_WithContext_ReturnMacroStabilityInwardsFailureMechanismView()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var context = new MacroStabilityInwardsCalculationsContext(failureMechanism, assessmentSection);
+
+ // Call
+ var view = (MacroStabilityInwardsFailureMechanismView) info.CreateInstance(context);
+
+ // Assert
+ Assert.AreSame(failureMechanism, view.FailureMechanism);
+ Assert.AreSame(assessmentSection, view.AssessmentSection);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsFailureMechanismViewInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 683f8939ea395ffe9b29a54cc87005244a5af182 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsFailurePathViewInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/RegistrationState/MacroStabilityInwardsFailureMechanismViewInfoTest.cs
===================================================================
diff -u
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/RegistrationState/MacroStabilityInwardsFailureMechanismViewInfoTest.cs (revision 0)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/ViewInfos/RegistrationState/MacroStabilityInwardsFailureMechanismViewInfoTest.cs (revision 683f8939ea395ffe9b29a54cc87005244a5af182)
@@ -0,0 +1,188 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Linq;
+using Core.Gui.Plugin;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.MacroStabilityInwards.Data;
+using Riskeer.MacroStabilityInwards.Forms.PresentationObjects;
+using Riskeer.MacroStabilityInwards.Forms.Views.RegistrationState;
+
+namespace Riskeer.MacroStabilityInwards.Plugin.Test.ViewInfos.RegistrationState
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismViewInfoTest
+ {
+ private MockRepository mocks;
+ private MacroStabilityInwardsPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new MacroStabilityInwardsPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(MacroStabilityInwardsFailureMechanismView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(MacroStabilityInwardsFailurePathContext), info.DataType);
+ Assert.AreEqual(typeof(MacroStabilityInwardsFailurePathContext), info.ViewDataType);
+ }
+
+ [Test]
+ public void GetViewName_WithContext_ReturnsNameOfFailureMechanism()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var context = new MacroStabilityInwardsFailurePathContext(failureMechanism, assessmentSection);
+
+ // Call
+ string viewName = info.GetViewName(null, context);
+
+ // Assert
+ Assert.AreEqual(failureMechanism.Name, viewName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismInAssembly(bool inAssembly)
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism
+ {
+ InAssembly = inAssembly
+ };
+
+ var context = new MacroStabilityInwardsFailurePathContext(failureMechanism, assessmentSection);
+
+ // Call
+ bool result = info.AdditionalDataCheck(context);
+
+ // Assert
+ Assert.AreEqual(inAssembly, result);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CreateInstance_WithContext_ReturnMacroStabilityInwardsFailureMechanismView()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var context = new MacroStabilityInwardsFailurePathContext(failureMechanism, assessmentSection);
+
+ // Call
+ var view = (MacroStabilityInwardsFailureMechanismView) info.CreateInstance(context);
+
+ // Assert
+ Assert.AreSame(failureMechanism, view.FailureMechanism);
+ Assert.AreSame(assessmentSection, view.AssessmentSection);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ var otherAssessmentSection = new AssessmentSectionStub();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection);
+
+ // Call
+ bool closeForData = info.CloseForData(view, otherAssessmentSection);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection);
+
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var otherMacroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection);
+
+ // Call
+ bool closeForData = info.CloseForData(view, otherMacroStabilityInwardsFailureMechanism);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSectionStub();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var view = new MacroStabilityInwardsFailureMechanismView(failureMechanism, assessmentSection);
+
+ // Call
+ bool closeForData = info.CloseForData(view, failureMechanism);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+}
\ No newline at end of file