Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismContextProperties.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismContextProperties.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismContextProperties.cs (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -0,0 +1,346 @@
+// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Base;
+using Core.Common.Base.Data;
+using Core.Common.Gui.Attributes;
+using Core.Common.Gui.PropertyBag;
+using Core.Common.Utils.Attributes;
+using Ringtoets.Common.Forms.PropertyClasses;
+using Ringtoets.MacroStabilityInwards.Data;
+using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects;
+using Ringtoets.MacroStabilityInwards.Forms.Properties;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.MacroStabilityInwards.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of properties panel.
+ ///
+ public class MacroStabilityInwardsFailureMechanismContextProperties : ObjectProperties
+ {
+ private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The instance to show the properties of.
+ /// Handler responsible for handling effects of a property change.
+ /// Thrown when any input parameter is null.
+ public MacroStabilityInwardsFailureMechanismContextProperties(
+ MacroStabilityInwardsFailureMechanismContext data,
+ IFailureMechanismPropertyChangeHandler handler)
+ {
+ if (data == null)
+ {
+ throw new ArgumentNullException(nameof(data));
+ }
+ if (handler == null)
+ {
+ throw new ArgumentNullException(nameof(handler));
+ }
+ Data = data;
+ propertyChangeHandler = handler;
+ }
+
+ #region Heave
+
+ [DynamicVisible]
+ [PropertyOrder(31)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Heave))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_CriticalHeaveGradient_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_CriticalHeaveGradient_Description))]
+ public double CriticalHeaveGradient
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.CriticalHeaveGradient;
+ }
+ }
+
+ #endregion
+
+ [DynamicVisibleValidationMethod]
+ public bool DynamicVisibleValidationMethod(string propertyName)
+ {
+ if (!data.WrappedData.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private void ChangePropertyValueAndNotifyAffectedObjects(
+ SetFailureMechanismPropertyValueDelegate setPropertyValue,
+ TValue value)
+ {
+ IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(
+ data.WrappedData,
+ value,
+ setPropertyValue);
+
+ NotifyAffectedObjects(affectedObjects);
+ }
+
+ private static void NotifyAffectedObjects(IEnumerable affectedObjects)
+ {
+ foreach (IObservable affectedObject in affectedObjects)
+ {
+ affectedObject.NotifyObservers();
+ }
+ }
+
+ private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName)
+ {
+ return nameof(CriticalHeaveGradient).Equals(propertyName)
+ || nameof(WaterVolumetricWeight).Equals(propertyName)
+ || nameof(A).Equals(propertyName)
+ || nameof(B).Equals(propertyName)
+ || nameof(SandParticlesVolumicWeight).Equals(propertyName)
+ || nameof(WhitesDragCoefficient).Equals(propertyName)
+ || nameof(BeddingAngle).Equals(propertyName)
+ || nameof(WaterKinematicViscosity).Equals(propertyName)
+ || nameof(Gravity).Equals(propertyName)
+ || nameof(MeanDiameter70).Equals(propertyName)
+ || nameof(SellmeijerReductionFactor).Equals(propertyName)
+ || nameof(UpliftModelFactor).Equals(propertyName)
+ || nameof(SellmeijerModelFactor).Equals(propertyName);
+ }
+
+ #region General
+
+ [PropertyOrder(1)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_Name_DisplayName))]
+ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_Name_Description))]
+ public string Name
+ {
+ get
+ {
+ return data.WrappedData.Name;
+ }
+ }
+
+ [PropertyOrder(2)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_Code_DisplayName))]
+ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_Code_Description))]
+ public string Code
+ {
+ get
+ {
+ return data.WrappedData.Code;
+ }
+ }
+
+ [PropertyOrder(3)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_IsRelevant_DisplayName))]
+ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.FailureMechanism_IsRelevant_Description))]
+ public bool IsRelevant
+ {
+ get
+ {
+ return data.WrappedData.IsRelevant;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(4)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_WaterVolumetricWeight_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_WaterVolumetricWeight_Description))]
+ public RoundedDouble WaterVolumetricWeight
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.WaterVolumetricWeight;
+ }
+ set
+ {
+ ChangePropertyValueAndNotifyAffectedObjects((f, v) => f.GeneralInput.WaterVolumetricWeight = v, value);
+ }
+ }
+
+ #endregion
+
+ #region Semi-probabilistic parameters
+
+ [DynamicVisible]
+ [PropertyOrder(21)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_SemiProbabilisticParameters))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_A_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_A_Description))]
+ public double A
+ {
+ get
+ {
+ return data.WrappedData.PipingProbabilityAssessmentInput.A;
+ }
+ set
+ {
+ ChangePropertyValueAndNotifyAffectedObjects((f, v) => f.PipingProbabilityAssessmentInput.A = v, value);
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(22)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_SemiProbabilisticParameters))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_B_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_B_Description))]
+ public double B
+ {
+ get
+ {
+ return data.WrappedData.PipingProbabilityAssessmentInput.B;
+ }
+ }
+
+ #endregion
+
+ #region Sellmeijer
+
+ [DynamicVisible]
+ [PropertyOrder(51)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_SandParticlesVolumicWeight_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_SandParticlesVolumicWeight_Description))]
+ public RoundedDouble SandParticlesVolumicWeight
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.SandParticlesVolumicWeight;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(52)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_WhitesDragCoefficient_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_WhitesDragCoefficient_Description))]
+ public double WhitesDragCoefficient
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.WhitesDragCoefficient;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(53)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_BeddingAngle_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_BeddingAngle_Description))]
+ public double BeddingAngle
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.BeddingAngle;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(54)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_WaterKinematicViscosity_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_WaterKinematicViscosity_Description))]
+ public double WaterKinematicViscosity
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.WaterKinematicViscosity;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(55)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.GravitationalAcceleration_DisplayName))]
+ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.GravitationalAcceleration_Description))]
+ public double Gravity
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.Gravity;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(56)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_MeanDiameter70_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_MeanDiameter70_Description))]
+ public double MeanDiameter70
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.MeanDiameter70;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(57)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Sellmeijer))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_SellmeijerReductionFactor_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_SellmeijerReductionFactor_Description))]
+ public double SellmeijerReductionFactor
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.SellmeijerReductionFactor;
+ }
+ }
+
+ #endregion
+
+ #region Model factors
+
+ [DynamicVisible]
+ [PropertyOrder(11)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_ModelSettings))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_UpliftModelFactor_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_UpliftModelFactor_Description))]
+ public double UpliftModelFactor
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.UpliftModelFactor;
+ }
+ }
+
+ [DynamicVisible]
+ [PropertyOrder(12)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_ModelSettings))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.GeneralPipingInput_SellmeijerModelFactor_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.GeneralPipingInput_SellmeijerModelFactor_Description))]
+ public double SellmeijerModelFactor
+ {
+ get
+ {
+ return data.WrappedData.GeneralInput.SellmeijerModelFactor;
+ }
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Fisheye: Tag 26fde08dff31104fdc204b8fab78a61adaa214d6 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj
===================================================================
diff -u -r4bd71eca0b6db2959ccb01d6504d1bf5058603bd -r26fde08dff31104fdc204b8fab78a61adaa214d6
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 4bd71eca0b6db2959ccb01d6504d1bf5058603bd)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -76,7 +76,7 @@
-
+
@@ -115,11 +115,11 @@
UserControl
-
+
UserControl
-
- PipingFailureMechanismView.cs
+
+ MacroStabilityInwardsFailureMechanismView.cs
@@ -220,8 +220,8 @@
PipingCalculationsView.cs
-
- PipingFailureMechanismView.cs
+
+ MacroStabilityInwardsFailureMechanismView.cs
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.Designer.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.Designer.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.Designer.cs (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -0,0 +1,64 @@
+// Copyright (C) Stichting Deltares 2017. 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.
+
+namespace Ringtoets.MacroStabilityInwards.Forms.Views
+{
+ 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.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;
+ //
+ // MacroStabilityInwardsFailureMechanismView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.ringtoetsMapControl);
+ this.Name = "MacroStabilityInwardsFailureMechanismView";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Common.Forms.Views.RingtoetsMapControl ringtoetsMapControl;
+ }
+}
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismView.cs (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -0,0 +1,311 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using System.Linq;
+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.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Forms.Factories;
+using Ringtoets.Common.Forms.Views;
+using Ringtoets.MacroStabilityInwards.Data;
+using Ringtoets.MacroStabilityInwards.Forms.Factories;
+using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects;
+using Ringtoets.MacroStabilityInwards.Primitives;
+using MacroStabilityInwardsDataResources = Ringtoets.MacroStabilityInwards.Data.Properties.Resources;
+
+namespace Ringtoets.MacroStabilityInwards.Forms.Views
+{
+ ///
+ /// This class is a view showing map data for a macrostability inwards failure mechanism.
+ ///
+ public partial class MacroStabilityInwardsFailureMechanismView : UserControl, IMapView
+ {
+ private readonly Observer failureMechanismObserver;
+ private readonly Observer hydraulicBoundaryDatabaseObserver;
+ private readonly Observer assessmentSectionObserver;
+ private readonly Observer surfaceLinesObserver;
+ private readonly Observer stochasticSoilModelsObserver;
+
+ private readonly RecursiveObserver calculationInputObserver;
+ private readonly RecursiveObserver calculationGroupObserver;
+ private readonly RecursiveObserver calculationObserver;
+ private readonly RecursiveObserver surfaceLineObserver;
+
+ private readonly MapDataCollection mapDataCollection;
+ private readonly MapLineData referenceLineMapData;
+ private readonly MapLineData sectionsMapData;
+ private readonly MapLineData stochasticSoilModelsMapData;
+ private readonly MapLineData surfaceLinesMapData;
+ private readonly MapPointData sectionsStartPointMapData;
+ private readonly MapPointData sectionsEndPointMapData;
+ private readonly MapPointData hydraulicBoundaryLocationsMapData;
+ private readonly MapLineData calculationsMapData;
+
+ private MacroStabilityInwardsFailureMechanismContext data;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ public MacroStabilityInwardsFailureMechanismView()
+ {
+ InitializeComponent();
+
+ failureMechanismObserver = new Observer(UpdateMapData);
+ assessmentSectionObserver = new Observer(() =>
+ {
+ if (!ReferenceEquals(hydraulicBoundaryDatabaseObserver.Observable, data.Parent.HydraulicBoundaryDatabase))
+ {
+ hydraulicBoundaryDatabaseObserver.Observable = data.Parent.HydraulicBoundaryDatabase;
+ }
+
+ UpdateMapData();
+ });
+ hydraulicBoundaryDatabaseObserver = new Observer(UpdateHydraulicBoundaryLocationsMapData);
+ surfaceLinesObserver = new Observer(UpdateSurfaceLinesMapData);
+ stochasticSoilModelsObserver = new Observer(UpdateStochasticSoilModelsMapData);
+
+ calculationInputObserver = new RecursiveObserver(
+ UpdateCalculationsMapData, pcg => pcg.Children.Concat
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismViewTest.cs (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -0,0 +1,1140 @@
+// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Base.Geometry;
+using Core.Components.BruTile.TestUtil;
+using Core.Components.Gis.Data;
+using Core.Components.Gis.Features;
+using Core.Components.Gis.Forms;
+using Core.Components.Gis.Geometries;
+using Core.Components.Gis.TestUtil;
+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.Common.Utils.TypeConverters;
+using Ringtoets.MacroStabilityInwards.Data;
+using Ringtoets.MacroStabilityInwards.Data.TestUtil;
+using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects;
+using Ringtoets.MacroStabilityInwards.Forms.Views;
+using Ringtoets.MacroStabilityInwards.Primitives;
+
+namespace Ringtoets.MacroStabilityInwards.Forms.Test.Views
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismViewTest
+ {
+ private const int referenceLineIndex = 0;
+ private const int stochasticSoilModelsIndex = 1;
+ private const int surfaceLinesIndex = 2;
+ private const int sectionsIndex = 3;
+ private const int sectionsStartPointIndex = 4;
+ private const int sectionsEndPointIndex = 5;
+ private const int hydraulicBoundaryLocationsIndex = 6;
+ private const int calculationsIndex = 7;
+
+ [Test]
+ public void DefaultConstructor_DefaultValues()
+ {
+ // Call
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ // Assert
+ Assert.IsInstanceOf(view);
+ Assert.IsInstanceOf(view);
+ Assert.IsNotNull(view.Map);
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void DefaultConstructor_Always_AddEmptyMapControl()
+ {
+ // Call
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ // Assert
+ Assert.AreEqual(1, view.Controls.Count);
+ Assert.IsInstanceOf(view.Controls[0]);
+ Assert.AreSame(view.Map, ((RingtoetsMapControl) view.Controls[0]).MapControl);
+ Assert.AreEqual(DockStyle.Fill, ((Control) view.Map).Dock);
+ Assert.IsNull(view.Map.Data);
+ }
+ }
+
+ [Test]
+ public void Data_MacroStabilityInwardsFailureMechanismContext_DataSet()
+ {
+ // Setup
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(
+ new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ // Call
+ view.Data = failureMechanismContext;
+
+ // Assert
+ Assert.AreSame(failureMechanismContext, view.Data);
+ }
+ }
+
+ [Test]
+ public void Data_OtherThanMacroStabilityInwardsFailureMechanismContext_DataNull()
+ {
+ // Setup
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ var data = new object();
+
+ // Call
+ view.Data = data;
+
+ // Assert
+ Assert.IsNull(view.Data);
+ }
+ }
+
+ [Test]
+ public void Data_SetToNull_MapDataCleared()
+ {
+ // Setup
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(
+ new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ view.Data = failureMechanismContext;
+
+ // Precondition
+ Assert.AreEqual(8, view.Map.Data.Collection.Count());
+
+ // Call
+ view.Data = null;
+
+ // Assert
+ Assert.IsNull(view.Data);
+ Assert.IsNull(view.Map.Data);
+ }
+ }
+
+ [Test]
+ public void Data_EmptyMacroStabilityInwardsFailureMechanismContext_NoMapDataSet()
+ {
+ // Setup
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(
+ new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ // Call
+ view.Data = failureMechanismContext;
+
+ // Assert
+ Assert.AreSame(failureMechanismContext, view.Data);
+ AssertEmptyMapData(view.Map.Data);
+ MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, view.Map.BackgroundMapData);
+ }
+ }
+
+ [Test]
+ public void Data_AssessmentSectionWithBackgroundData_BackgroundDataSet()
+ {
+ // Setup
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ // Call
+ view.Data = failureMechanismContext;
+
+ // Assert
+ MapDataTestHelper.AssertImageBasedMapData(assessmentSection.BackgroundData, view.Map.BackgroundMapData);
+ }
+ }
+
+ [Test]
+ public void Data_SetToNull_ClearMapDataProperties()
+ {
+ // Setup
+ WmtsMapData backgroundMapData = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ BackgroundData = BackgroundDataConverter.ConvertTo(backgroundMapData)
+ };
+
+ using (new UseCustomTileSourceFactoryConfig(backgroundMapData))
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ view.Data = new MacroStabilityInwardsFailureMechanismContext(
+ new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ // Precondition
+ Assert.IsNotNull(view.Map.Data);
+ Assert.IsNotNull(view.Map.BackgroundMapData);
+
+ // Call
+ view.Data = null;
+
+ // Assert
+ Assert.IsNull(view.Map.Data);
+ Assert.IsNull(view.Map.BackgroundMapData);
+ }
+ }
+
+ [Test]
+ public void Data_MacroStabilityInwardsFailureMechanismContext_DataUpdatedToCollectionOfFilledMapData()
+ {
+ // Setup
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ 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 hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "test", 1.0, 2.0)
+ }
+ };
+
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(0.0, 3.0),
+ new Point2D(3.0, 0.0)
+ });
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase = hydraulicBoundaryDatabase,
+ ReferenceLine = referenceLine
+ };
+
+ var stochasticSoilModel1 = new StochasticSoilModel(0, "name1", "");
+ stochasticSoilModel1.Geometry.AddRange(new[]
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(1.1, 2.2)
+ });
+ var stochasticSoilModel2 = new StochasticSoilModel(0, "name2", "");
+ stochasticSoilModel2.Geometry.AddRange(new[]
+ {
+ new Point2D(3.0, 4.0),
+ new Point2D(3.3, 4.4)
+ });
+
+ var surfaceLineA = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Line A"
+ };
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+
+ var surfaceLineB = new RingtoetsPipingSurfaceLine
+ {
+ Name = "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 failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ const string arbitraryFilePath = "path";
+ failureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLineA,
+ surfaceLineB
+ }, arbitraryFilePath);
+ failureMechanism.AddSection(new FailureMechanismSection("A", geometryPoints.Take(2)));
+ failureMechanism.AddSection(new FailureMechanismSection("B", geometryPoints.Skip(1).Take(2)));
+ failureMechanism.AddSection(new FailureMechanismSection("C", geometryPoints.Skip(2).Take(2)));
+ failureMechanism.StochasticSoilModels.AddRange(new[]
+ {
+ stochasticSoilModel1,
+ stochasticSoilModel2
+ }, arbitraryFilePath);
+
+ PipingCalculationScenario calculationA = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+ PipingCalculationScenario calculationB = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ calculationB.InputParameters.SurfaceLine = surfaceLineB;
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
+
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ view.Data = failureMechanismContext;
+
+ // Assert
+ Assert.AreSame(failureMechanismContext, view.Data);
+
+ MapDataCollection mapData = map.Data;
+ Assert.IsInstanceOf(mapData);
+
+ List mapDataList = mapData.Collection.ToList();
+ Assert.AreEqual(8, mapDataList.Count);
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, mapDataList[referenceLineIndex]);
+ AssertSurfacelinesMapData(failureMechanism.SurfaceLines, mapDataList[surfaceLinesIndex]);
+ MapDataTestHelper.AssertFailureMechanismSectionsMapData(failureMechanism.Sections, mapDataList[sectionsIndex]);
+ MapDataTestHelper.AssertFailureMechanismSectionsStartPointMapData(failureMechanism.Sections, mapDataList[sectionsStartPointIndex]);
+ MapDataTestHelper.AssertFailureMechanismSectionsEndPointMapData(failureMechanism.Sections, mapDataList[sectionsEndPointIndex]);
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, mapDataList[hydraulicBoundaryLocationsIndex]);
+ AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, mapDataList[stochasticSoilModelsIndex]);
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), mapDataList[calculationsIndex]);
+ }
+ }
+
+ [Test]
+ public void GivenViewWithAssessmentSectionData_WhenAssessmentSectionUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var hydraulicBoundaryDatabase1 = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0)
+ }
+ };
+ var hydraulicBoundaryDatabase2 = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0),
+ new HydraulicBoundaryLocation(3, "test3", 2.3, 4.6)
+ }
+ };
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase = hydraulicBoundaryDatabase1
+ };
+
+ view.Data = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
+ observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
+ observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsStartPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsEndPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver());
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex);
+
+ // Precondition
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase1.Locations, hydraulicBoundaryLocationsMapData);
+
+ // When
+ assessmentSection.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase2;
+ assessmentSection.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase2.Locations, hydraulicBoundaryLocationsMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenViewWithHydraulicBoundaryDatabaseData_WhenHydraulicBoundaryDatabaseUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "test1", 1.0, 2.0)
+ }
+ };
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase = hydraulicBoundaryDatabase
+ };
+
+ view.Data = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ 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(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData);
+
+ // When
+ hydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "test2", 2.0, 3.0));
+ hydraulicBoundaryDatabase.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(hydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenAssessmentSectionWithHydraulicBoundaryDatabase_WhenNewDatabaseIsSetAndNotified_ThenMapDataUpdatedAndObserversNotified()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var currentHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "old 1", 1, 2)
+ }
+ };
+ var newHydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ Locations =
+ {
+ new HydraulicBoundaryLocation(1, "new 1", 1, 2)
+ }
+ };
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ HydraulicBoundaryDatabase = currentHydraulicBoundaryDatabase
+ };
+
+ view.Data = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
+ observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
+ observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsStartPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsEndPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver()).Repeat.Twice();
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ MapData hydraulicBoundaryLocationsMapData = map.Data.Collection.ElementAt(hydraulicBoundaryLocationsIndex);
+
+ // Precondition
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(currentHydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData);
+
+ // When
+ assessmentSection.HydraulicBoundaryDatabase = newHydraulicBoundaryDatabase;
+ assessmentSection.NotifyObservers();
+ newHydraulicBoundaryDatabase.Locations.Add(new HydraulicBoundaryLocation(2, "new 2", 2, 3));
+ newHydraulicBoundaryDatabase.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertHydraulicBoundaryLocationsMapData(newHydraulicBoundaryDatabase.Locations, hydraulicBoundaryLocationsMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenViewWithReferenceLineData_WhenReferenceLineUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var points1 = new List
+ {
+ new Point2D(1.0, 2.0),
+ new Point2D(2.0, 1.0)
+ };
+
+ var points2 = new List
+ {
+ new Point2D(2.0, 5.0),
+ new Point2D(4.0, 3.0)
+ };
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub
+ {
+ ReferenceLine = new ReferenceLine()
+ };
+ assessmentSection.ReferenceLine.SetGeometry(points1);
+
+ view.Data = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
+ observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
+ observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsStartPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsEndPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver());
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ MapData referenceLineMapData = map.Data.Collection.ElementAt(referenceLineIndex);
+
+ // Precondition
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
+
+ // When
+ assessmentSection.ReferenceLine.SetGeometry(points2);
+ assessmentSection.NotifyObservers();
+
+ // Then
+ MapDataTestHelper.AssertReferenceLineMapData(assessmentSection.ReferenceLine, referenceLineMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenViewWithSurfaceLinesData_WhenSurfaceLinesUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+
+ var geometry1 = new Collection
+ {
+ new Point3D(1, 2, 3),
+ new Point3D(4, 5, 6)
+ };
+
+ surfaceLine.SetGeometry(geometry1);
+
+ view.Data = failureMechanismContext;
+
+ 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]
+ public void GivenViewWithSurfaceLineData_WhenSurfaceLineUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.SurfaceLines.AddRange(new[]
+ {
+ surfaceLine
+ }, "path");
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+
+ view.Data = failureMechanismContext;
+
+ 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]
+ public void GivenViewWithFailureMechanismSectionsData_WhenFailureMechanismSectionsUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+
+ view.Data = failureMechanismContext;
+
+ var sectionMapData = (MapLineData) map.Data.Collection.ElementAt(sectionsIndex);
+ var sectionStartsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsStartPointIndex);
+ var sectionsEndsMapData = (MapPointData) map.Data.Collection.ElementAt(sectionsEndPointIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[referenceLineIndex].Expect(obs => obs.UpdateObserver());
+ observers[stochasticSoilModelsIndex].Expect(obs => obs.UpdateObserver());
+ observers[surfaceLinesIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsStartPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[sectionsEndPointIndex].Expect(obs => obs.UpdateObserver());
+ observers[hydraulicBoundaryLocationsIndex].Expect(obs => obs.UpdateObserver());
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ failureMechanism.AddSection(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]
+ public void GivenViewWithStochasticSoilModels_WhenStochasticSoilModelsUpdatedAndNotified_ThenMapDataUpdatedAndObserverNotified()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+ var stochasticSoilModel = new StochasticSoilModel(0, "", "");
+
+ stochasticSoilModel.Geometry.AddRange(new[]
+ {
+ new Point2D(1, 2),
+ new Point2D(1, 2)
+ });
+
+ view.Data = failureMechanismContext;
+
+ 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[]
+ {
+ stochasticSoilModel
+ }, "path");
+ failureMechanism.StochasticSoilModels.NotifyObservers();
+
+ // Then
+ AssertStochasticSoilModelsMapData(failureMechanism.StochasticSoilModels, stochasticSoilModelMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenViewWithCalculationGroupData_WhenCalculationGroupUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+
+ var surfaceLineA = new RingtoetsPipingSurfaceLine();
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+
+ var surfaceLineB = new RingtoetsPipingSurfaceLine();
+ 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);
+
+ PipingCalculationScenario calculationA = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+ PipingCalculationScenario calculationB = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ calculationB.InputParameters.SurfaceLine = surfaceLineB;
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+
+ view.Data = failureMechanismContext;
+
+ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ failureMechanism.CalculationsGroup.Children.Add(calculationB);
+ failureMechanism.CalculationsGroup.NotifyObservers();
+
+ // Then
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenViewWithCalculationInputData_WhenCalculationInputUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var surfaceLineA = new RingtoetsPipingSurfaceLine();
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+
+ var surfaceLineB = new RingtoetsPipingSurfaceLine();
+ 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);
+
+ PipingCalculationScenario calculationA = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+
+ view.Data = failureMechanismContext;
+
+ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ calculationA.InputParameters.SurfaceLine = surfaceLineB;
+ calculationA.InputParameters.NotifyObservers();
+
+ // Then
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void GivenViewWithCalculationData_WhenCalculationUpdatedAndNotified_ThenMapDataUpdated()
+ {
+ // Given
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var surfaceLineA = new RingtoetsPipingSurfaceLine();
+ surfaceLineA.SetGeometry(new[]
+ {
+ new Point3D(0.0, 0.0, 1.0),
+ new Point3D(3.0, 0.0, 1.7)
+ });
+
+ var surfaceLineB = new RingtoetsPipingSurfaceLine();
+ 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);
+
+ PipingCalculationScenario calculationA = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ calculationA.InputParameters.SurfaceLine = surfaceLineA;
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(calculationA);
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, new ObservableTestAssessmentSectionStub());
+
+ view.Data = failureMechanismContext;
+
+ var calculationMapData = (MapLineData) map.Data.Collection.ElementAt(calculationsIndex);
+
+ var mocks = new MockRepository();
+ IObserver[] observers = AttachMapDataObservers(mocks, map.Data.Collection);
+ observers[calculationsIndex].Expect(obs => obs.UpdateObserver());
+ mocks.ReplayAll();
+
+ // When
+ calculationA.Name = "new name";
+ calculationA.NotifyObservers();
+
+ // Then
+ AssertCalculationsMapData(failureMechanism.Calculations.Cast(), calculationMapData);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void UpdateObserver_DataUpdated_MapLayersSameOrder()
+ {
+ // Setup
+ const int updatedRefenceLineLayerIndex = referenceLineIndex + 7;
+ const int updatedSurfaceLineLayerIndex = surfaceLinesIndex - 1;
+ const int updatedSectionsLayerIndex = sectionsIndex - 1;
+ const int updateSectionStartLayerIndex = sectionsStartPointIndex - 1;
+ const int updatedSectionEndLayerIndex = sectionsEndPointIndex - 1;
+ const int updatedHydraulicLocationsLayerIndex = hydraulicBoundaryLocationsIndex - 1;
+ const int updatedStochasticSoilModelsLayerIndex = stochasticSoilModelsIndex - 1;
+ const int updatedCalculationsIndex = calculationsIndex - 1;
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ view.Data = failureMechanismContext;
+
+ 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[updatedRefenceLineLayerIndex];
+ Assert.AreEqual("Referentielijn", referenceLineData.Name);
+
+ var surfaceLineData = (MapLineData) mapDataList[updatedSurfaceLineLayerIndex];
+ Assert.AreEqual("Profielschematisaties", surfaceLineData.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 randvoorwaarden", hydraulicLocationsData.Name);
+
+ var stochasticSoilModelsData = (MapLineData) mapDataList[updatedStochasticSoilModelsLayerIndex];
+ Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsData.Name);
+
+ var calculationsData = (MapLineData) mapDataList[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) mapDataList[updatedRefenceLineLayerIndex];
+ Assert.AreEqual("Referentielijn", actualReferenceLineData.Name);
+
+ var actualSurfaceLineData = (MapLineData) mapDataList[updatedSurfaceLineLayerIndex];
+ Assert.AreEqual("Profielschematisaties", actualSurfaceLineData.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 randvoorwaarden", actualHydraulicLocationsData.Name);
+
+ var actualStochasticSoilModelsData = (MapLineData) mapDataList[updatedStochasticSoilModelsLayerIndex];
+ Assert.AreEqual("Stochastische ondergrondmodellen", actualStochasticSoilModelsData.Name);
+
+ var actualCalculationsData = (MapLineData) mapDataList[updatedCalculationsIndex];
+ Assert.AreEqual("Berekeningen", actualCalculationsData.Name);
+ }
+ }
+
+ [Test]
+ public void NotifyObservers_DataUpdatedNotifyObserversOnOldData_NoUpdateInViewData()
+ {
+ // Setup
+ IAssessmentSection oldAssessmentSection = new ObservableTestAssessmentSectionStub();
+ IAssessmentSection newAssessmentSection = new ObservableTestAssessmentSectionStub();
+
+ newAssessmentSection.ReferenceLine = new ReferenceLine();
+ newAssessmentSection.ReferenceLine.SetGeometry(new[]
+ {
+ new Point2D(2, 4),
+ new Point2D(3, 4)
+ });
+
+ var oldMacroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), oldAssessmentSection);
+ var newMacroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), newAssessmentSection);
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ IMapControl map = ((RingtoetsMapControl) view.Controls[0]).MapControl;
+
+ view.Data = oldMacroStabilityInwardsFailureMechanismContext;
+ view.Data = newMacroStabilityInwardsFailureMechanismContext;
+ MapData dataBeforeUpdate = map.Data;
+
+ newAssessmentSection.ReferenceLine.SetGeometry(Enumerable.Empty());
+
+ // Call
+ oldAssessmentSection.NotifyObservers();
+
+ // Assert
+ Assert.AreEqual(dataBeforeUpdate, map.Data);
+ }
+ }
+
+ private static void AssertSurfacelinesMapData(IEnumerable surfaceLines, MapData mapData)
+ {
+ Assert.IsInstanceOf(mapData);
+ var surfacelinesMapData = (MapLineData) mapData;
+ MapFeature[] surfacelineFeatures = surfacelinesMapData.Features.ToArray();
+ RingtoetsPipingSurfaceLine[] surfaceLinesArray = surfaceLines.ToArray();
+ Assert.AreEqual(surfaceLinesArray.Length, surfacelineFeatures.Length);
+
+ for (var index = 0; index < surfaceLinesArray.Length; index++)
+ {
+ Assert.AreEqual(1, surfacelineFeatures[index].MapGeometries.Count());
+ RingtoetsPipingSurfaceLine 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();
+ StochasticSoilModel[] stochasticSoilModelsArray = soilModels.ToArray();
+ Assert.AreEqual(stochasticSoilModelsArray.Length, soilModelsFeatures.Length);
+
+ for (var index = 0; index < stochasticSoilModelsArray.Length; index++)
+ {
+ Assert.AreEqual(1, soilModelsFeatures[index].MapGeometries.Count());
+ StochasticSoilModel stochasticSoilModel = stochasticSoilModelsArray[index];
+ CollectionAssert.AreEquivalent(stochasticSoilModel.Geometry.Select(p => new Point2D(p.X, p.Y)), 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;
+ PipingCalculationScenario[] 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);
+
+ PipingCalculationScenario 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("Dijken en dammen - Piping", mapDataCollection.Name);
+
+ List mapDataList = mapDataCollection.Collection.ToList();
+
+ Assert.AreEqual(8, mapDataList.Count);
+
+ var referenceLineMapData = (MapLineData) mapDataList[referenceLineIndex];
+ var sectionsMapData = (MapLineData) mapDataList[sectionsIndex];
+ var stochasticSoilModelsMapData = (MapLineData) mapDataList[stochasticSoilModelsIndex];
+ var surfaceLinesMapData = (MapLineData) mapDataList[surfaceLinesIndex];
+ var sectionsStartPointMapData = (MapPointData) mapDataList[sectionsStartPointIndex];
+ var sectionsEndPointMapData = (MapPointData) mapDataList[sectionsEndPointIndex];
+ var hydraulicBoundaryLocationsMapData = (MapPointData) mapDataList[hydraulicBoundaryLocationsIndex];
+ var calculationsMapData = (MapLineData) mapDataList[calculationsIndex];
+
+ CollectionAssert.IsEmpty(referenceLineMapData.Features);
+ CollectionAssert.IsEmpty(sectionsMapData.Features);
+ CollectionAssert.IsEmpty(stochasticSoilModelsMapData.Features);
+ CollectionAssert.IsEmpty(surfaceLinesMapData.Features);
+ CollectionAssert.IsEmpty(sectionsStartPointMapData.Features);
+ CollectionAssert.IsEmpty(sectionsEndPointMapData.Features);
+ CollectionAssert.IsEmpty(hydraulicBoundaryLocationsMapData.Features);
+ CollectionAssert.IsEmpty(calculationsMapData.Features);
+
+ Assert.AreEqual("Referentielijn", referenceLineMapData.Name);
+ Assert.AreEqual("Vakindeling", sectionsMapData.Name);
+ Assert.AreEqual("Stochastische ondergrondmodellen", stochasticSoilModelsMapData.Name);
+ Assert.AreEqual("Profielschematisaties", surfaceLinesMapData.Name);
+ Assert.AreEqual("Vakindeling (startpunten)", sectionsStartPointMapData.Name);
+ Assert.AreEqual("Vakindeling (eindpunten)", sectionsEndPointMapData.Name);
+ Assert.AreEqual("Hydraulische randvoorwaarden", 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 stochasticSoilModelMapDataObserver = mocks.StrictMock();
+ mapDataArray[stochasticSoilModelsIndex].Attach(stochasticSoilModelMapDataObserver);
+
+ var surfaceLineMapDataObserver = mocks.StrictMock();
+ mapDataArray[surfaceLinesIndex].Attach(surfaceLineMapDataObserver);
+
+ 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);
+
+ var calculationsMapDataObserver = mocks.StrictMock();
+ mapDataArray[calculationsIndex].Attach(calculationsMapDataObserver);
+
+ return new[]
+ {
+ referenceLineMapDataObserver,
+ stochasticSoilModelMapDataObserver,
+ surfaceLineMapDataObserver,
+ sectionsMapDataObserver,
+ sectionsStartPointMapDataObserver,
+ sectionsEndPointMapDataObserver,
+ hydraulicBoundaryLocationsMapDataObserver,
+ calculationsMapDataObserver
+ };
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 26fde08dff31104fdc204b8fab78a61adaa214d6 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/PipingFailureMechanismViewTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/PipingPluginTest.cs
===================================================================
diff -u -r4bd71eca0b6db2959ccb01d6504d1bf5058603bd -r26fde08dff31104fdc204b8fab78a61adaa214d6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 4bd71eca0b6db2959ccb01d6504d1bf5058603bd)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -65,7 +65,7 @@
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
typeof(MacroStabilityInwardsFailureMechanismContext),
- typeof(PipingFailureMechanismContextProperties));
+ typeof(MacroStabilityInwardsFailureMechanismContextProperties));
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
@@ -143,7 +143,7 @@
// Assert
Assert.AreEqual(5, viewInfos.Length);
- Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingFailureMechanismView)));
+ Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(MacroStabilityInwardsFailureMechanismView)));
Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingCalculationsView)));
Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingFailureMechanismResultView)));
Assert.IsTrue(viewInfos.Any(vi => vi.ViewType == typeof(PipingInputView)));
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/PropertyInfos/PipingFailureMechanismContextPropertyInfoTest.cs
===================================================================
diff -u -r4bd71eca0b6db2959ccb01d6504d1bf5058603bd -r26fde08dff31104fdc204b8fab78a61adaa214d6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/PropertyInfos/PipingFailureMechanismContextPropertyInfoTest.cs (.../PipingFailureMechanismContextPropertyInfoTest.cs) (revision 4bd71eca0b6db2959ccb01d6504d1bf5058603bd)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/PropertyInfos/PipingFailureMechanismContextPropertyInfoTest.cs (.../PipingFailureMechanismContextPropertyInfoTest.cs) (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -41,7 +41,7 @@
public void SetUp()
{
plugin = new PipingPlugin();
- info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(PipingFailureMechanismContextProperties));
+ info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(MacroStabilityInwardsFailureMechanismContextProperties));
}
[TearDown]
@@ -55,7 +55,7 @@
{
// Assert
Assert.AreEqual(typeof(MacroStabilityInwardsFailureMechanismContext), info.DataType);
- Assert.AreEqual(typeof(PipingFailureMechanismContextProperties), info.PropertyObjectType);
+ Assert.AreEqual(typeof(MacroStabilityInwardsFailureMechanismContextProperties), info.PropertyObjectType);
}
[Test]
@@ -73,7 +73,7 @@
IObjectProperties objectProperties = info.CreateInstance(context);
// Assert
- Assert.IsInstanceOf(objectProperties);
+ Assert.IsInstanceOf(objectProperties);
Assert.AreSame(context, objectProperties.Data);
mocks.VerifyAll();
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/Ringtoets.MacroStabilityInwards.Plugin.Test.csproj
===================================================================
diff -u -r4a27dfb1033419dd325dee88fd4abe3cb56e452d -r26fde08dff31104fdc204b8fab78a61adaa214d6
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/Ringtoets.MacroStabilityInwards.Plugin.Test.csproj (.../Ringtoets.MacroStabilityInwards.Plugin.Test.csproj) (revision 4a27dfb1033419dd325dee88fd4abe3cb56e452d)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/Ringtoets.MacroStabilityInwards.Plugin.Test.csproj (.../Ringtoets.MacroStabilityInwards.Plugin.Test.csproj) (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -87,7 +87,7 @@
-
+
@@ -101,7 +101,7 @@
-
+
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -0,0 +1,824 @@
+// Copyright (C) Stichting Deltares 2017. 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.Drawing;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Core.Common.Controls.TreeView;
+using Core.Common.Gui;
+using Core.Common.Gui.Commands;
+using Core.Common.Gui.ContextMenu;
+using Core.Common.Gui.Forms.MainWindow;
+using Core.Common.Gui.TestUtil.ContextMenu;
+using Core.Common.TestUtil;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.MacroStabilityInwards.Data;
+using Ringtoets.MacroStabilityInwards.Data.TestUtil;
+using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects;
+using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources;
+
+namespace Ringtoets.MacroStabilityInwards.Plugin.Test.TreeNodeInfos
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest : NUnitFormTest
+ {
+ private const int contextMenuRelevancyIndexWhenRelevant = 2;
+ private const int contextMenuRelevancyIndexWhenNotRelevant = 0;
+
+ private const int contextMenuValidateAllIndex = 4;
+ private const int contextMenuCalculateAllIndex = 5;
+ private const int contextMenuClearIndex = 7;
+
+ private MockRepository mocks;
+ private PipingPlugin plugin;
+ private TreeNodeInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new PipingPlugin();
+ info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(MacroStabilityInwardsFailureMechanismContext));
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Assert
+ Assert.IsNotNull(info.Text);
+ Assert.IsNotNull(info.ForeColor);
+ Assert.IsNotNull(info.Image);
+ Assert.IsNotNull(info.ContextMenuStrip);
+ Assert.IsNull(info.EnsureVisibleOnCreate);
+ Assert.IsNull(info.ExpandOnCreate);
+ Assert.IsNotNull(info.ChildNodeObjects);
+ Assert.IsNull(info.CanRename);
+ Assert.IsNull(info.OnNodeRenamed);
+ Assert.IsNull(info.CanRemove);
+ Assert.IsNull(info.OnNodeRemoved);
+ Assert.IsNull(info.CanCheck);
+ Assert.IsNull(info.IsChecked);
+ Assert.IsNull(info.OnNodeChecked);
+ Assert.IsNull(info.CanDrag);
+ Assert.IsNull(info.CanDrop);
+ Assert.IsNull(info.CanInsert);
+ Assert.IsNull(info.OnDrop);
+ }
+
+ [Test]
+ public void Text_Always_ReturnsName()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var mechanism = new MacroStabilityInwardsFailureMechanism();
+ var mechanismContext = new MacroStabilityInwardsFailureMechanismContext(mechanism, assessmentSection);
+
+ // Call
+ string text = info.Text(mechanismContext);
+
+ // Assert
+ Assert.AreEqual("Dijken en dammen - Piping", text);
+ }
+
+ [Test]
+ public void Image_Always_ReturnsMacroStabilityInwardsIcon()
+ {
+ // Setup
+ mocks.ReplayAll();
+
+ // Call
+ Image image = info.Image(null);
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculationIcon, image);
+ }
+
+ [Test]
+ public void ChildNodeObjects_FailureMechanismIsRelevant_ReturnChildDataNodes()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var generalInputParameters = new GeneralPipingInput();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(generalInputParameters));
+ failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(generalInputParameters));
+
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(3, children.Length);
+ var inputsFolder = (CategoryTreeFolder) children[0];
+ Assert.AreEqual("Invoer", inputsFolder.Name);
+ Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category);
+
+ Assert.AreEqual(4, inputsFolder.Contents.Count);
+ var failureMechanismSectionsContext = (FailureMechanismSectionsContext) inputsFolder.Contents[0];
+ Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData);
+ Assert.AreSame(assessmentSection, failureMechanismSectionsContext.ParentAssessmentSection);
+
+ var surfaceLinesContext = (RingtoetsPipingSurfaceLinesContext) inputsFolder.Contents[1];
+ Assert.AreSame(failureMechanism.SurfaceLines, surfaceLinesContext.WrappedData);
+ Assert.AreSame(failureMechanism, surfaceLinesContext.FailureMechanism);
+ Assert.AreSame(assessmentSection, surfaceLinesContext.AssessmentSection);
+
+ var stochasticSoilModelContext = (StochasticSoilModelCollectionContext) inputsFolder.Contents[2];
+ Assert.AreSame(failureMechanism, stochasticSoilModelContext.FailureMechanism);
+ Assert.AreSame(failureMechanism, stochasticSoilModelContext.FailureMechanism);
+ Assert.AreSame(assessmentSection, stochasticSoilModelContext.AssessmentSection);
+
+ var comment = (Comment) inputsFolder.Contents[3];
+ Assert.AreSame(failureMechanism.InputComments, comment);
+
+ var calculationsFolder = (PipingCalculationGroupContext) children[1];
+ Assert.AreEqual("Berekeningen", calculationsFolder.WrappedData.Name);
+ CollectionAssert.AreEqual(failureMechanism.CalculationsGroup.Children, calculationsFolder.WrappedData.Children);
+ Assert.AreSame(failureMechanism.SurfaceLines, calculationsFolder.AvailablePipingSurfaceLines);
+ Assert.AreEqual(failureMechanism.StochasticSoilModels, calculationsFolder.AvailableStochasticSoilModels);
+ Assert.AreSame(failureMechanism, calculationsFolder.FailureMechanism);
+
+ var outputsFolder = (CategoryTreeFolder) children[2];
+ Assert.AreEqual("Oordeel", outputsFolder.Name);
+ Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category);
+
+ Assert.AreEqual(3, outputsFolder.Contents.Count);
+ var failureMechanismScenariosContext = (PipingScenariosContext) outputsFolder.Contents[0];
+ Assert.AreSame(failureMechanism, failureMechanismScenariosContext.ParentFailureMechanism);
+ Assert.AreSame(failureMechanism.CalculationsGroup, failureMechanismScenariosContext.WrappedData);
+
+ var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents[1];
+ Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism);
+ Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData);
+
+ var commentContext = (Comment) outputsFolder.Contents[2];
+ Assert.AreSame(failureMechanism.OutputComments, commentContext);
+ }
+
+ [Test]
+ public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismNotRelevantComments()
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var generalInputParameters = new GeneralPipingInput();
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism
+ {
+ IsRelevant = false
+ };
+ failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(generalInputParameters));
+ failureMechanism.CalculationsGroup.Children.Add(new PipingCalculationScenario(generalInputParameters));
+
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ object[] children = info.ChildNodeObjects(failureMechanismContext).ToArray();
+
+ // Assert
+ Assert.AreEqual(1, children.Length);
+ var comment = (Comment) children[0];
+ Assert.AreSame(failureMechanism.NotRelevantComments, comment);
+ }
+
+ [Test]
+ [TestCase(false)]
+ [TestCase(true)]
+ public void GivenMultiplePipingCalculationsWithOutput_WhenClearingOutputFromContextMenu_ThenPipingOutputCleared(bool confirm)
+ {
+ // Given
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var generalInputParameters = new GeneralPipingInput();
+ var pipingCalculation1 = new PipingCalculationScenario(generalInputParameters)
+ {
+ Output = new TestPipingOutput(),
+ SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput()
+ };
+ var pipingCalculation2 = new PipingCalculationScenario(generalInputParameters)
+ {
+ Output = new TestPipingOutput(),
+ SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput()
+ };
+
+ var observer = mocks.StrictMock();
+ if (confirm)
+ {
+ observer.Expect(o => o.UpdateObserver()).Repeat.Twice();
+ }
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation1);
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation2);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation1);
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation2);
+ failureMechanism.CalculationsGroup.Children.ElementAt(0).Attach(observer);
+ failureMechanism.CalculationsGroup.Children.ElementAt(1).Attach(observer);
+
+ string messageBoxTitle = null, messageBoxText = null;
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var messageBox = new MessageBoxTester(wnd);
+
+ messageBoxText = messageBox.Text;
+ messageBoxTitle = messageBox.Title;
+
+ if (confirm)
+ {
+ messageBox.ClickOk();
+ }
+ else
+ {
+ messageBox.ClickCancel();
+ }
+ };
+
+ using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // When
+ contextMenuStrip.Items[contextMenuClearIndex].PerformClick();
+
+ // Then
+ foreach (ICalculation calc in failureMechanism.CalculationsGroup.Children.OfType())
+ {
+ Assert.AreNotEqual(confirm, calc.HasOutput);
+ }
+
+ Assert.AreEqual("Bevestigen", messageBoxTitle);
+ Assert.AreEqual("Weet u zeker dat u alle uitvoer wilt wissen?", messageBoxText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_HasCalculationWithOutput_ReturnsContextMenuWithCommonItems()
+ {
+ // Setup
+ var failureMechanism = new TestMacroStabilityInwardsFailureMechanism();
+ var pipingCalculation = new PipingCalculationScenario(failureMechanism.GeneralInput)
+ {
+ Output = new TestPipingOutput(),
+ SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput()
+ };
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var applicationFeatureCommandHandler = mocks.Stub();
+ var importCommandHandler = mocks.Stub();
+ var exportCommandHandler = mocks.Stub();
+ var updateCommandHandler = mocks.Stub();
+ var viewCommandsHandler = mocks.Stub();
+
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilder = new ContextMenuBuilder(applicationFeatureCommandHandler,
+ importCommandHandler,
+ exportCommandHandler,
+ updateCommandHandler,
+ viewCommandsHandler,
+ failureMechanismContext,
+ treeViewControl);
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip menu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Assert
+ Assert.AreEqual(13, menu.Items.Count);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 0,
+ "&Openen",
+ "Open de gegevens in een nieuw documentvenster.",
+ CoreCommonGuiResources.OpenIcon,
+ false);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 2,
+ "I&s relevant",
+ "Geeft aan of dit toetsspoor relevant is of niet.",
+ RingtoetsCommonFormsResources.Checkbox_ticked);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 4,
+ "Alles &valideren",
+ "Valideer alle berekeningen binnen dit toetsspoor.",
+ RingtoetsCommonFormsResources.ValidateAllIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 5,
+ "Alles be&rekenen",
+ "Voer alle berekeningen binnen dit toetsspoor uit.",
+ RingtoetsCommonFormsResources.CalculateAllIcon);
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 7,
+ "&Wis alle uitvoer...",
+ "Wis de uitvoer van alle berekeningen binnen dit toetsspoor.",
+ RingtoetsCommonFormsResources.ClearIcon);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 9,
+ "Alles i&nklappen",
+ "Klap dit element en alle onderliggende elementen in.",
+ CoreCommonGuiResources.CollapseAllIcon,
+ false);
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 10,
+ "Alles ui&tklappen",
+ "Klap dit element en alle onderliggende elementen uit.",
+ CoreCommonGuiResources.ExpandAllIcon,
+ false);
+
+ TestHelper.AssertContextMenuStripContainsItem(menu,
+ 12,
+ "Ei&genschappen",
+ "Toon de eigenschappen in het Eigenschappenpaneel.",
+ CoreCommonGuiResources.PropertiesHS,
+ false);
+
+ CollectionAssert.AllItemsAreInstancesOfType(new[]
+ {
+ menu.Items[1],
+ menu.Items[3],
+ menu.Items[8],
+ menu.Items[11]
+ }, typeof(ToolStripSeparator));
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_MacroStabilityInwardsFailureMechanismNoOutput_ContextMenuItemClearAllOutputDisabled()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var dataMock = mocks.StrictMock();
+ dataMock.Stub(dm => dm.Calculations).Return(new ICalculation[0]);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(dataMock, assessmentSection);
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem clearOutputItem = contextMenu.Items[contextMenuClearIndex];
+ Assert.IsFalse(clearOutputItem.Enabled);
+ Assert.AreEqual("Er zijn geen berekeningen met uitvoer om te wissen.", clearOutputItem.ToolTipText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_MacroStabilityInwardsFailureMechanismWithOutput_ContextMenuItemClearAllOutputEnabled()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var pipingCalculation = new PipingCalculationScenario(new GeneralPipingInput())
+ {
+ Output = new TestPipingOutput(),
+ SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput()
+ };
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ failureMechanism.CalculationsGroup.Children.Add(pipingCalculation);
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Assert
+ ToolStripItem clearOutputItem = contextMenu.Items[contextMenuClearIndex];
+ Assert.IsTrue(clearOutputItem.Enabled);
+ Assert.AreEqual("Wis de uitvoer van alle berekeningen binnen dit toetsspoor.", clearOutputItem.ToolTipText);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismContributionZero_ContextMenuItemCalculateAllAndValidateAllDisabledAndTooltipSet()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism
+ {
+ CalculationsGroup =
+ {
+ Children =
+ {
+ PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput()
+ }
+ }
+ };
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex,
+ "Alles be&rekenen",
+ "De bijdrage van dit toetsspoor is nul.",
+ RingtoetsCommonFormsResources.CalculateAllIcon,
+ false);
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateAllIndex,
+ "Alles &valideren",
+ "De bijdrage van dit toetsspoor is nul.",
+ RingtoetsCommonFormsResources.ValidateAllIcon,
+ false);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllAndValidateAllEnabled()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanism = new TestMacroStabilityInwardsFailureMechanism
+ {
+ CalculationsGroup =
+ {
+ Children =
+ {
+ PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput()
+ }
+ }
+ };
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Assert
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex,
+ "Alles be&rekenen",
+ "Voer alle berekeningen binnen dit toetsspoor uit.",
+ RingtoetsCommonFormsResources.CalculateAllIcon);
+
+ TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateAllIndex,
+ "Alles &valideren",
+ "Valideer alle berekeningen binnen dit toetsspoor.",
+ RingtoetsCommonFormsResources.ValidateAllIcon);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = mocks.StrictMock();
+ using (mocks.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
+ }
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(failureMechanismContext, null, treeViewControl);
+ }
+
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsNotRelevant_CallsContextMenuBuilderMethods()
+ {
+ // Setup
+ var treeViewControl = new TreeViewControl();
+ {
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism
+ {
+ IsRelevant = false
+ };
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = mocks.StrictMock();
+ using (mocks.Ordered())
+ {
+ menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
+ menuBuilder.Expect(mb => mb.Build()).Return(null);
+ }
+
+ var gui = mocks.Stub();
+ gui.Stub(cmp => cmp.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ // Call
+ info.ContextMenuStrip(failureMechanismContext, null, treeViewControl);
+ }
+
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+
+ [Test]
+ public void ContextMenuStrip_ClickOnValidateAllItem_ValidateAllChildCalculations()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanism = new TestMacroStabilityInwardsFailureMechanism();
+ PipingCalculationScenario validCalculation = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ validCalculation.Name = "A";
+ PipingCalculationScenario invalidCalculation = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithInvalidInput();
+ invalidCalculation.Name = "B";
+
+ failureMechanism.CalculationsGroup.Children.Add(validCalculation);
+ failureMechanism.CalculationsGroup.Children.Add(invalidCalculation);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Call
+ Action call = () => contextMenu.Items[contextMenuValidateAllIndex].PerformClick();
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(9, msgs.Length);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", validCalculation.Name), msgs[0]);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", validCalculation.Name), msgs[1]);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", invalidCalculation.Name), msgs[2]);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", invalidCalculation.Name), msgs[8]);
+ });
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanism = new TestMacroStabilityInwardsFailureMechanism();
+ PipingCalculationScenario validCalculation = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithValidInput();
+ validCalculation.Name = "A";
+ PipingCalculationScenario invalidCalculation = PipingCalculationScenarioFactory.CreatePipingCalculationScenarioWithInvalidInput();
+ invalidCalculation.Name = "B";
+
+ failureMechanism.CalculationsGroup.Children.Add(validCalculation);
+ failureMechanism.CalculationsGroup.Children.Add(invalidCalculation);
+
+ IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase(
+ failureMechanism, mocks);
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSectionStub);
+
+ var mainWindow = mocks.Stub();
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.MainWindow).Return(mainWindow);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Expect an activity dialog which is automatically closed
+ };
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[contextMenuCalculateAllIndex].PerformClick();
+ }
+ }
+
+ // Assert
+ // Assert expectancies are called in TearDown()
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsRelevantAndClickOnIsRelevantItem_MakeFailureMechanismNotRelevant()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanismObserver = mocks.Stub();
+ failureMechanismObserver.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism();
+ failureMechanism.Attach(failureMechanismObserver);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var viewCommands = mocks.StrictMock();
+ viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext));
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[contextMenuRelevancyIndexWhenRelevant].PerformClick();
+
+ // Assert
+ Assert.IsFalse(failureMechanism.IsRelevant);
+ }
+ }
+ }
+
+ [Test]
+ public void ContextMenuStrip_FailureMechanismIsNotRelevantAndClickOnIsRelevantItem_MakeFailureMechanismRelevant()
+ {
+ // Setup
+ using (var treeViewControl = new TreeViewControl())
+ {
+ var failureMechanismObserver = mocks.Stub();
+ failureMechanismObserver.Expect(o => o.UpdateObserver());
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism
+ {
+ IsRelevant = false
+ };
+ failureMechanism.Attach(failureMechanismObserver);
+
+ var assessmentSection = mocks.Stub();
+ var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ var viewCommands = mocks.StrictMock();
+ viewCommands.Expect(vs => vs.RemoveAllViewsForItem(failureMechanismContext));
+
+ var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
+
+ var gui = mocks.Stub();
+ gui.Stub(g => g.ViewCommands).Return(viewCommands);
+ gui.Stub(g => g.Get(failureMechanismContext, treeViewControl)).Return(menuBuilder);
+ mocks.ReplayAll();
+
+ plugin.Gui = gui;
+
+ using (ContextMenuStrip contextMenu = info.ContextMenuStrip(failureMechanismContext, null, treeViewControl))
+ {
+ // Call
+ contextMenu.Items[contextMenuRelevancyIndexWhenNotRelevant].PerformClick();
+
+ // Assert
+ Assert.IsTrue(failureMechanism.IsRelevant);
+ }
+ }
+ }
+
+ public override void TearDown()
+ {
+ plugin.Dispose();
+ mocks.VerifyAll();
+
+ base.TearDown();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 26fde08dff31104fdc204b8fab78a61adaa214d6 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/PipingFailureMechanismContextTreeNodeInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsFailureMechanismViewInfoTest.cs
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsFailureMechanismViewInfoTest.cs (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsFailureMechanismViewInfoTest.cs (revision 26fde08dff31104fdc204b8fab78a61adaa214d6)
@@ -0,0 +1,203 @@
+// Copyright (C) Stichting Deltares 2017. 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.Linq;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.MacroStabilityInwards.Data;
+using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects;
+using Ringtoets.MacroStabilityInwards.Forms.Views;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.MacroStabilityInwards.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class MacroStabilityInwardsFailureMechanismViewInfoTest
+ {
+ private MockRepository mocks;
+ private PipingPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mocks = new MockRepository();
+ plugin = new PipingPlugin();
+ 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(MacroStabilityInwardsFailureMechanismContext), info.DataType);
+ Assert.AreEqual(typeof(MacroStabilityInwardsFailureMechanismContext), info.ViewDataType);
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.CalculationIcon, info.Image);
+ }
+
+ [Test]
+ public void GetViewName_WithMacroStabilityInwardsFailureMechanism_ReturnsNameOfFailureMechanism()
+ {
+ // Setup
+ var assessmentSectionStub = mocks.Stub();
+ mocks.ReplayAll();
+
+ var macroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var macroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(macroStabilityInwardsFailureMechanism, assessmentSectionStub);
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView())
+ {
+ // Call
+ string viewName = info.GetViewName(view, macroStabilityInwardsFailureMechanismContext);
+
+ // Assert
+ Assert.AreEqual(macroStabilityInwardsFailureMechanism.Name, viewName);
+ }
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+ var otherAssessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var macroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var macroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(macroStabilityInwardsFailureMechanism, assessmentSection);
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView
+ {
+ Data = macroStabilityInwardsFailureMechanismContext
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, otherAssessmentSection);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ var macroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var macroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(macroStabilityInwardsFailureMechanism, assessmentSection);
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView
+ {
+ Data = macroStabilityInwardsFailureMechanismContext
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse()
+ {
+ // Setup
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ var macroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var otherMacroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+
+ var macroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(macroStabilityInwardsFailureMechanism, assessmentSection);
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView
+ {
+ Data = macroStabilityInwardsFailureMechanismContext
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, otherMacroStabilityInwardsFailureMechanism);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue()
+ {
+ // Setup
+ var assessmentSection = new ObservableTestAssessmentSectionStub();
+
+ var macroStabilityInwardsFailureMechanism = new MacroStabilityInwardsFailureMechanism();
+ var macroStabilityInwardsFailureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(macroStabilityInwardsFailureMechanism, assessmentSection);
+
+ using (var view = new MacroStabilityInwardsFailureMechanismView
+ {
+ Data = macroStabilityInwardsFailureMechanismContext
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, macroStabilityInwardsFailureMechanism);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void AdditionalDataCheck_Always_ReturnTrueOnlyIfFailureMechanismRelevant(bool isRelevant)
+ {
+ // Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new MacroStabilityInwardsFailureMechanism
+ {
+ IsRelevant = isRelevant
+ };
+
+ var context = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection);
+
+ // Call
+ bool result = info.AdditionalDataCheck(context);
+
+ // Assert
+ Assert.AreEqual(isRelevant, result);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 26fde08dff31104fdc204b8fab78a61adaa214d6 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/PipingFailureMechanismViewInfoTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?