Fisheye: Tag 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c refers to a dead (removed) revision in file `Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/SemiProbabilistic/PipingInputContextProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/SemiProbabilistic/SemiProbabilisticPipingInputContextProperties.cs =================================================================== diff -u --- Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/SemiProbabilistic/SemiProbabilisticPipingInputContextProperties.cs (revision 0) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/SemiProbabilistic/SemiProbabilisticPipingInputContextProperties.cs (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -0,0 +1,490 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing.Design; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Util.Attributes; +using Riskeer.Common.Forms.ChangeHandlers; +using Riskeer.Common.Forms.Helpers; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Forms.PropertyClasses; +using Riskeer.Common.Forms.UITypeEditors; +using Riskeer.Piping.Data; +using Riskeer.Piping.Data.SemiProbabilistic; +using Riskeer.Piping.Data.SoilProfile; +using Riskeer.Piping.Forms.PresentationObjects.SemiProbabilistic; +using Riskeer.Piping.Forms.Properties; +using Riskeer.Piping.Forms.UITypeEditors; +using Riskeer.Piping.Primitives; +using Riskeer.Piping.Service; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.Piping.Forms.PropertyClasses.SemiProbabilistic +{ + /// + /// ViewModel of for properties panel. + /// + public class SemiProbabilisticPipingInputContextProperties : ObjectProperties, + IHasHydraulicBoundaryLocationProperty + { + private const int selectedHydraulicBoundaryLocationPropertyIndex = 1; + private const int assessmentLevelPropertyIndex = 2; + private const int useHydraulicBoundaryLocationPropertyIndex = 3; + private const int dampingFactorExitPropertyIndex = 4; + private const int phreaticLevelExitPropertyIndex = 5; + private const int piezometricHeadExitPropertyIndex = 6; + private const int surfaceLinePropertyIndex = 7; + private const int stochasticSoilModelPropertyIndex = 8; + private const int stochasticSoilProfilePropertyIndex = 9; + private const int entryPointLPropertyIndex = 10; + private const int exitPointLPropertyIndex = 11; + private const int seepageLengthPropertyIndex = 12; + private const int thicknessCoverageLayerPropertyIndex = 13; + private const int effectiveThicknessCoverageLayerPropertyIndex = 14; + private const int thicknessAquiferLayerPropertyIndex = 15; + private const int darcyPermeabilityPropertyIndex = 16; + private const int diameter70PropertyIndex = 17; + private const int saturatedVolumicWeightOfCoverageLayerPropertyIndex = 18; + + private readonly Func getNormativeAssessmentLevelFunc; + private readonly IObservablePropertyChangeHandler propertyChangeHandler; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties for. + /// for obtaining the normative assessment level. + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + public SemiProbabilisticPipingInputContextProperties(SemiProbabilisticPipingInputContext data, + Func getNormativeAssessmentLevelFunc, + IObservablePropertyChangeHandler propertyChangeHandler) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (getNormativeAssessmentLevelFunc == null) + { + throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc)); + } + + if (propertyChangeHandler == null) + { + throw new ArgumentNullException(nameof(propertyChangeHandler)); + } + + Data = data; + + this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc; + this.propertyChangeHandler = propertyChangeHandler; + } + + /// + /// Gets the available surface lines on . + /// + public IEnumerable GetAvailableSurfaceLines() + { + return data.AvailablePipingSurfaceLines; + } + + /// + /// Gets the available stochastic soil models on . + /// + public IEnumerable GetAvailableStochasticSoilModels() + { + if (data.WrappedData.SurfaceLine == null) + { + return data.AvailableStochasticSoilModels; + } + + return PipingCalculationConfigurationHelper.GetStochasticSoilModelsForSurfaceLine(data.WrappedData.SurfaceLine, + data.AvailableStochasticSoilModels); + } + + /// + /// Gets the available stochastic soil profiles on . + /// + public IEnumerable GetAvailableStochasticSoilProfiles() + { + return data.WrappedData.StochasticSoilModel != null + ? data.WrappedData.StochasticSoilModel.StochasticSoilProfiles + : new List(); + } + + [DynamicReadOnlyValidationMethod] + public bool DynamicReadOnlyValidationMethod(string propertyName) + { + if (propertyName == nameof(AssessmentLevel)) + { + return !data.WrappedData.UseAssessmentLevelManualInput; + } + + if (propertyName == nameof(EntryPointL) || propertyName == nameof(ExitPointL)) + { + return data.WrappedData.SurfaceLine == null; + } + + return true; + } + + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (propertyName == nameof(SelectedHydraulicBoundaryLocation)) + { + return !data.WrappedData.UseAssessmentLevelManualInput; + } + + return false; + } + + /// + /// Gets the available selectable hydraulic boundary locations on . + /// + public IEnumerable GetSelectableHydraulicBoundaryLocations() + { + Point2D referencePoint = SurfaceLine?.ReferenceLineIntersectionWorldPoint; + return SelectableHydraulicBoundaryLocationHelper.GetSortedSelectableHydraulicBoundaryLocations( + data.AssessmentSection.HydraulicBoundaryDatabase.Locations, referencePoint); + } + + private RoundedDouble GetEffectiveAssessmentLevel() + { + return data.WrappedData.UseAssessmentLevelManualInput + ? data.WrappedData.AssessmentLevel + : getNormativeAssessmentLevelFunc(); + } + + #region Hydraulic data + + [DynamicVisible] + [PropertyOrder(selectedHydraulicBoundaryLocationPropertyIndex)] + [Editor(typeof(HydraulicBoundaryLocationEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_HydraulicData))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.HydraulicBoundaryLocation_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.HydraulicBoundaryLocation_Description_with_assessment_level))] + public SelectableHydraulicBoundaryLocation SelectedHydraulicBoundaryLocation + { + get + { + Point2D referencePoint = SurfaceLine?.ReferenceLineIntersectionWorldPoint; + + return data.WrappedData.HydraulicBoundaryLocation != null + ? new SelectableHydraulicBoundaryLocation(data.WrappedData.HydraulicBoundaryLocation, + referencePoint) + : null; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation, propertyChangeHandler); + } + } + + [DynamicReadOnly] + [PropertyOrder(assessmentLevelPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_HydraulicData))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.WaterLevel_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.AssessmentLevel_Description))] + public RoundedDouble AssessmentLevel + { + get + { + return GetEffectiveAssessmentLevel(); + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WrappedData.AssessmentLevel = value, propertyChangeHandler); + } + } + + [PropertyOrder(useHydraulicBoundaryLocationPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_HydraulicData))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.UseAssessmentLevelManualInput_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.UseAssessmentLevelManualInput_Description))] + public bool UseAssessmentLevelManualInput + { + get + { + return data.WrappedData.UseAssessmentLevelManualInput; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WrappedData.UseAssessmentLevelManualInput = value, propertyChangeHandler); + } + } + + [PropertyOrder(dampingFactorExitPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_HydraulicData))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_DampingFactorExit_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_DampingFactorExit_Description))] + public LogNormalDistributionDesignVariableProperties DampingFactorExit + { + get + { + return new LogNormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.None, + SemiProbabilisticPipingDesignVariableFactory.GetDampingFactorExit(data.WrappedData), + propertyChangeHandler); + } + } + + [PropertyOrder(phreaticLevelExitPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_HydraulicData))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_PhreaticLevelExit_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_PhreaticLevelExit_Description))] + public NormalDistributionDesignVariableProperties PhreaticLevelExit + { + get + { + return new NormalDistributionDesignVariableProperties(DistributionReadOnlyProperties.None, + SemiProbabilisticPipingDesignVariableFactory.GetPhreaticLevelExit(data.WrappedData), + propertyChangeHandler); + } + } + + [PropertyOrder(piezometricHeadExitPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_HydraulicData))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_PiezometricHeadExit_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_PiezometricHeadExit_Description))] + public RoundedDouble PiezometricHeadExit + { + get + { + return DerivedPipingInput.GetPiezometricHeadExit(data.WrappedData, GetEffectiveAssessmentLevel()); + } + } + + #endregion + + #region Schematization + + [PropertyOrder(surfaceLinePropertyIndex)] + [Editor(typeof(PipingInputContextSurfaceLineSelectionEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.SurfaceLine_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.SurfaceLine_Description))] + public PipingSurfaceLine SurfaceLine + { + get + { + return data.WrappedData.SurfaceLine; + } + set + { + if (!ReferenceEquals(value, data.WrappedData.SurfaceLine)) + { + PropertyChangeHelper.ChangePropertyAndNotify(() => + { + data.WrappedData.SurfaceLine = value; + PipingInputService.SetMatchingStochasticSoilModel(data.WrappedData, GetAvailableStochasticSoilModels()); + }, propertyChangeHandler); + } + } + } + + [PropertyOrder(stochasticSoilModelPropertyIndex)] + [Editor(typeof(PipingInputContextStochasticSoilModelSelectionEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilModel_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilModel_Description))] + public PipingStochasticSoilModel StochasticSoilModel + { + get + { + return data.WrappedData.StochasticSoilModel; + } + set + { + if (!ReferenceEquals(value, data.WrappedData.StochasticSoilModel)) + { + PropertyChangeHelper.ChangePropertyAndNotify(() => + { + data.WrappedData.StochasticSoilModel = value; + PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(data.WrappedData); + }, propertyChangeHandler); + } + } + } + + [PropertyOrder(stochasticSoilProfilePropertyIndex)] + [Editor(typeof(PipingInputContextStochasticSoilProfileSelectionEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilProfile_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_StochasticSoilProfile_Description))] + public PipingStochasticSoilProfile StochasticSoilProfile + { + get + { + return data.WrappedData.StochasticSoilProfile; + } + set + { + if (!ReferenceEquals(value, data.WrappedData.StochasticSoilProfile)) + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WrappedData.StochasticSoilProfile = value, propertyChangeHandler); + } + } + } + + [DynamicReadOnly] + [PropertyOrder(entryPointLPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_EntryPointL_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_EntryPointL_Description))] + public RoundedDouble EntryPointL + { + get + { + return data.WrappedData.EntryPointL; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WrappedData.EntryPointL = value, propertyChangeHandler); + } + } + + [DynamicReadOnly] + [PropertyOrder(exitPointLPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_ExitPointL_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_ExitPointL_Description))] + public RoundedDouble ExitPointL + { + get + { + return data.WrappedData.ExitPointL; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WrappedData.ExitPointL = value, propertyChangeHandler); + } + } + + [PropertyOrder(seepageLengthPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_SeepageLength_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_SeepageLength_Description))] + public VariationCoefficientLogNormalDistributionDesignVariableProperties SeepageLength + { + get + { + return new VariationCoefficientLogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetSeepageLength(data.WrappedData)); + } + } + + [PropertyOrder(thicknessCoverageLayerPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_ThicknessCoverageLayer_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_ThicknessCoverageLayer_Description))] + public LogNormalDistributionDesignVariableProperties ThicknessCoverageLayer + { + get + { + return new LogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetThicknessCoverageLayer(data.WrappedData)); + } + } + + [PropertyOrder(effectiveThicknessCoverageLayerPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_EffectiveThicknessCoverageLayer_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_EffectiveThicknessCoverageLayer_Description))] + public LogNormalDistributionDesignVariableProperties EffectiveThicknessCoverageLayer + { + get + { + return new LogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetEffectiveThicknessCoverageLayer(data.WrappedData)); + } + } + + [PropertyOrder(thicknessAquiferLayerPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_ThicknessAquiferLayer_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_ThicknessAquiferLayer_Description))] + public LogNormalDistributionDesignVariableProperties ThicknessAquiferLayer + { + get + { + return new LogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetThicknessAquiferLayer(data.WrappedData)); + } + } + + [PropertyOrder(darcyPermeabilityPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_DarcyPermeability_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_DarcyPermeability_Description))] + public VariationCoefficientLogNormalDistributionDesignVariableProperties DarcyPermeability + { + get + { + return new VariationCoefficientLogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetDarcyPermeability(data.WrappedData)); + } + } + + [PropertyOrder(diameter70PropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_Diameter70_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_Diameter70_Description))] + public VariationCoefficientLogNormalDistributionDesignVariableProperties Diameter70 + { + get + { + return new VariationCoefficientLogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetDiameter70(data.WrappedData)); + } + } + + [PropertyOrder(saturatedVolumicWeightOfCoverageLayerPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_Schematization))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PipingInput_SaturatedVolumicWeightOfCoverageLayer_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PipingInput_SaturatedVolumicWeightOfCoverageLayer_Description))] + public ShiftedLogNormalDistributionDesignVariableProperties SaturatedVolumicWeightOfCoverageLayer + { + get + { + return new ShiftedLogNormalDistributionDesignVariableProperties( + SemiProbabilisticPipingDesignVariableFactory.GetSaturatedVolumicWeightOfCoverageLayer(data.WrappedData)); + } + } + + #endregion + } +} \ No newline at end of file Index: Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditor.cs =================================================================== diff -u -rd4f80dbede462caf32731cd5ecba60377909055d -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditor.cs (.../PipingInputContextStochasticSoilModelSelectionEditor.cs) (revision d4f80dbede462caf32731cd5ecba60377909055d) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditor.cs (.../PipingInputContextStochasticSoilModelSelectionEditor.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -32,7 +32,7 @@ /// This class defines a drop down list edit-control from which the user can select a /// from a collection. /// - public class PipingInputContextStochasticSoilModelSelectionEditor : SelectionEditor + public class PipingInputContextStochasticSoilModelSelectionEditor : SelectionEditor { /// /// Creates a new instance of . Index: Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditor.cs =================================================================== diff -u -rd4f80dbede462caf32731cd5ecba60377909055d -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditor.cs (.../PipingInputContextStochasticSoilProfileSelectionEditor.cs) (revision d4f80dbede462caf32731cd5ecba60377909055d) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditor.cs (.../PipingInputContextStochasticSoilProfileSelectionEditor.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -33,7 +33,7 @@ /// This class defines a drop down list edit-control from which the user can select a /// from a collection. /// - public class PipingInputContextStochasticSoilProfileSelectionEditor : SelectionEditor + public class PipingInputContextStochasticSoilProfileSelectionEditor : SelectionEditor { /// /// Creates a new instance of . Index: Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextSurfaceLineSelectionEditor.cs =================================================================== diff -u -rd4f80dbede462caf32731cd5ecba60377909055d -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextSurfaceLineSelectionEditor.cs (.../PipingInputContextSurfaceLineSelectionEditor.cs) (revision d4f80dbede462caf32731cd5ecba60377909055d) +++ Riskeer/Piping/src/Riskeer.Piping.Forms/UITypeEditors/PipingInputContextSurfaceLineSelectionEditor.cs (.../PipingInputContextSurfaceLineSelectionEditor.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -32,7 +32,7 @@ /// This class defines a drop down list edit-control from which the user can select a /// from a collection. /// - public class PipingInputContextSurfaceLineSelectionEditor : SelectionEditor + public class PipingInputContextSurfaceLineSelectionEditor : SelectionEditor { /// /// Creates a new instance of . Index: Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r8eb7384995560912b2fd268726abe51e7b75bfd8 -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 8eb7384995560912b2fd268726abe51e7b75bfd8) +++ Riskeer/Piping/src/Riskeer.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -83,9 +83,9 @@ CreateInstance = context => new PipingFailureMechanismProperties(context.WrappedData, context.Parent, new FailureMechanismPropertyChangeHandler()) }; - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new PipingInputContextProperties(context, + CreateInstance = context => new SemiProbabilisticPipingInputContextProperties(context, () => GetNormativeAssessmentLevel(context.AssessmentSection, context.PipingCalculation), new ObservablePropertyChangeHandler(context.PipingCalculation, context.WrappedData)) }; Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextPropertiesTest.cs =================================================================== diff -u -rd4f80dbede462caf32731cd5ecba60377909055d -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextPropertiesTest.cs (.../ProbabilisticPipingInputContextPropertiesTest.cs) (revision d4f80dbede462caf32731cd5ecba60377909055d) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/Probabilistic/ProbabilisticPipingInputContextPropertiesTest.cs (.../ProbabilisticPipingInputContextPropertiesTest.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -36,7 +36,6 @@ using Riskeer.Piping.Forms.PresentationObjects.Probabilistic; using Riskeer.Piping.Forms.PropertyClasses; using Riskeer.Piping.Forms.PropertyClasses.Probabilistic; -using Riskeer.Piping.Forms.PropertyClasses.SemiProbabilistic; using Riskeer.Piping.Primitives; namespace Riskeer.Piping.Forms.Test.PropertyClasses.Probabilistic @@ -166,40 +165,40 @@ Assert.AreSame(context, properties.Data); Assert.IsInstanceOf(properties.DampingFactorExit); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.DampingFactorExit)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.DampingFactorExit)); Assert.IsInstanceOf(properties.PhreaticLevelExit); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.PhreaticLevelExit)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.PhreaticLevelExit)); Assert.IsInstanceOf(properties.SeepageLength); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.SeepageLength)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.SeepageLength)); Assert.IsInstanceOf(properties.ThicknessCoverageLayer); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.ThicknessCoverageLayer)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.ThicknessCoverageLayer)); Assert.IsInstanceOf(properties.EffectiveThicknessCoverageLayer); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.EffectiveThicknessCoverageLayer)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.EffectiveThicknessCoverageLayer)); Assert.IsInstanceOf(properties.ThicknessAquiferLayer); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.ThicknessAquiferLayer)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.ThicknessAquiferLayer)); Assert.IsInstanceOf(properties.DarcyPermeability); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.DarcyPermeability)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.DarcyPermeability)); Assert.IsInstanceOf(properties.Diameter70); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.Diameter70)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.Diameter70)); Assert.IsInstanceOf(properties.SaturatedVolumicWeightOfCoverageLayer); - TestHelper.AssertTypeConverter( - nameof(PipingInputContextProperties.SaturatedVolumicWeightOfCoverageLayer)); + TestHelper.AssertTypeConverter( + nameof(ProbabilisticPipingInputContextProperties.SaturatedVolumicWeightOfCoverageLayer)); mocks.VerifyAll(); } Fisheye: Tag 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c refers to a dead (removed) revision in file `Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/SemiProbabilistic/PipingInputContextPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/SemiProbabilistic/SemiProbabilisticPipingInputContextPropertiesTest.cs =================================================================== diff -u --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/SemiProbabilistic/SemiProbabilisticPipingInputContextPropertiesTest.cs (revision 0) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/SemiProbabilistic/SemiProbabilisticPipingInputContextPropertiesTest.cs (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -0,0 +1,1922 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.Probabilistics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Forms.ChangeHandlers; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Forms.PropertyClasses; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.Common.Forms.UITypeEditors; +using Riskeer.Piping.Data; +using Riskeer.Piping.Data.SemiProbabilistic; +using Riskeer.Piping.Data.SoilProfile; +using Riskeer.Piping.Data.TestUtil; +using Riskeer.Piping.Forms.PresentationObjects.SemiProbabilistic; +using Riskeer.Piping.Forms.PropertyClasses; +using Riskeer.Piping.Forms.PropertyClasses.SemiProbabilistic; +using Riskeer.Piping.Primitives; +using Riskeer.Piping.Primitives.TestUtil; + +namespace Riskeer.Piping.Forms.Test.PropertyClasses.SemiProbabilistic +{ + [TestFixture] + public class SemiProbabilisticPipingInputContextPropertiesTest + { + private const int expectedSelectedHydraulicBoundaryLocationPropertyIndex = 0; + private const int expectedAssessmentLevelPropertyIndex = 1; + private const int expectedUseHydraulicBoundaryLocationPropertyIndex = 2; + private const int expectedDampingFactorExitPropertyIndex = 3; + private const int expectedPhreaticLevelExitPropertyIndex = 4; + private const int expectedPiezometricHeadExitPropertyIndex = 5; + private const int expectedSurfaceLinePropertyIndex = 6; + private const int expectedStochasticSoilModelPropertyIndex = 7; + private const int expectedStochasticSoilProfilePropertyIndex = 8; + private const int expectedEntryPointLPropertyIndex = 9; + private const int expectedExitPointLPropertyIndex = 10; + private const int expectedSeepageLengthPropertyIndex = 11; + private const int expectedThicknessCoverageLayerPropertyIndex = 12; + private const int expectedEffectiveThicknessCoverageLayerPropertyIndex = 13; + private const int expectedThicknessAquiferLayerPropertyIndex = 14; + private const int expectedDarcyPermeabilityPropertyIndex = 15; + private const int expectedDiameter70PropertyIndex = 16; + private const int expectedSaturatedVolumicWeightOfCoverageLayerPropertyIndex = 17; + + [Test] + public void Constructor_DataNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate test = () => new SemiProbabilisticPipingInputContextProperties(null, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("data", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_GetAssessmentLevelFuncNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + TestDelegate test = () => new SemiProbabilisticPipingInputContextProperties(context, null, handler); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("getNormativeAssessmentLevelFunc", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_PropertyChangeHandlerNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + TestDelegate test = () => new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("propertyChangeHandler", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_WithParameters_ExpectedValues() + { + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsInstanceOf(properties); + Assert.AreSame(context, properties.Data); + + Assert.IsInstanceOf(properties.DampingFactorExit); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.DampingFactorExit)); + + Assert.IsInstanceOf(properties.PhreaticLevelExit); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.PhreaticLevelExit)); + + Assert.IsInstanceOf(properties.SeepageLength); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.SeepageLength)); + + Assert.IsInstanceOf(properties.ThicknessCoverageLayer); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.ThicknessCoverageLayer)); + + Assert.IsInstanceOf(properties.EffectiveThicknessCoverageLayer); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.EffectiveThicknessCoverageLayer)); + + Assert.IsInstanceOf(properties.ThicknessAquiferLayer); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.ThicknessAquiferLayer)); + + Assert.IsInstanceOf(properties.DarcyPermeability); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.DarcyPermeability)); + + Assert.IsInstanceOf(properties.Diameter70); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.Diameter70)); + + Assert.IsInstanceOf(properties.SaturatedVolumicWeightOfCoverageLayer); + TestHelper.AssertTypeConverter( + nameof(SemiProbabilisticPipingInputContextProperties.SaturatedVolumicWeightOfCoverageLayer)); + + mocks.VerifyAll(); + } + + [Test] + public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler) + { + UseAssessmentLevelManualInput = false + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + Assert.AreEqual(18, dynamicProperties.Count); + + const string hydraulicDataCategory = "Hydraulische gegevens"; + const string schematizationCategory = "Schematisatie"; + + PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[expectedSelectedHydraulicBoundaryLocationPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + hydraulicBoundaryLocationProperty, + hydraulicDataCategory, + "Hydraulische belastingenlocatie", + "De hydraulische belastingenlocatie waarvan de berekende waterstand wordt gebruikt."); + + PropertyDescriptor assessmentLevelProperty = dynamicProperties[expectedAssessmentLevelPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + assessmentLevelProperty, + hydraulicDataCategory, + "Waterstand [m+NAP]", + "Waterstand met een overschrijdingsfrequentie gelijk aan de norm van het dijktraject.", + true); + + PropertyDescriptor useHydraulicBoundaryLocationProperty = dynamicProperties[expectedUseHydraulicBoundaryLocationPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + useHydraulicBoundaryLocationProperty, + hydraulicDataCategory, + "Handmatig waterstand invoeren", + "Sta toe om de waterstand handmatig te specificeren?"); + + PropertyDescriptor dampingsFactorExitProperty = dynamicProperties[expectedDampingFactorExitPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + dampingsFactorExitProperty, + hydraulicDataCategory, + "Dempingsfactor bij uittredepunt [-]", + "Dempingsfactor relateert respons van stijghoogte bij binnenteen aan buitenwaterstand.", + true); + Assert.IsInstanceOf(dampingsFactorExitProperty.Converter); + + PropertyDescriptor phreaticLevelExitProperty = dynamicProperties[expectedPhreaticLevelExitPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + phreaticLevelExitProperty, + hydraulicDataCategory, + "Binnendijkse waterstand [m+NAP]", + "Binnendijkse waterstand ter plaatse van het uittredepunt.", + true); + Assert.IsInstanceOf(phreaticLevelExitProperty.Converter); + + PropertyDescriptor piezometricHeadExitProperty = dynamicProperties[expectedPiezometricHeadExitPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + piezometricHeadExitProperty, + hydraulicDataCategory, + "Stijghoogte bij uittredepunt [m+NAP]", + "Stijghoogte bij uittredepunt.", + true); + + PropertyDescriptor surfaceLineProperty = dynamicProperties[expectedSurfaceLinePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + surfaceLineProperty, + schematizationCategory, + "Profielschematisatie", + "De schematisatie van de hoogte van het dwarsprofiel."); + + PropertyDescriptor stochasticSoilModelProperty = dynamicProperties[expectedStochasticSoilModelPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + stochasticSoilModelProperty, + schematizationCategory, + "Stochastisch ondergrondmodel", + "De verschillende opbouwen van de ondergrond en hun respectievelijke kansen van voorkomen."); + + PropertyDescriptor stochasticSoilProfileProperty = dynamicProperties[expectedStochasticSoilProfilePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + stochasticSoilProfileProperty, + schematizationCategory, + "Ondergrondschematisatie", + "De opbouw van de ondergrond."); + + PropertyDescriptor seepageLengthProperty = dynamicProperties[expectedSeepageLengthPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + seepageLengthProperty, + schematizationCategory, + "Kwelweglengte [m]", + "De horizontale afstand tussen intrede- en uittredepunt die het kwelwater ondergronds aflegt voordat het weer aan de oppervlakte komt.", + true); + Assert.IsInstanceOf(seepageLengthProperty.Converter); + + PropertyDescriptor thicknessCoverageLayerProperty = dynamicProperties[expectedThicknessCoverageLayerPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + thicknessCoverageLayerProperty, + schematizationCategory, + "Totale deklaagdikte bij uittredepunt [m]", + "Totale deklaagdikte bij uittredepunt.", + true); + Assert.IsInstanceOf(thicknessCoverageLayerProperty.Converter); + + PropertyDescriptor effectiveThicknessCoverageLayerProperty = dynamicProperties[expectedEffectiveThicknessCoverageLayerPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + effectiveThicknessCoverageLayerProperty, + schematizationCategory, + "Effectieve deklaagdikte bij uittredepunt [m]", + "Effectieve deklaagdikte bij uittredepunt.", + true); + Assert.IsInstanceOf(effectiveThicknessCoverageLayerProperty.Converter); + + PropertyDescriptor thicknessAquiferLayerProperty = dynamicProperties[expectedThicknessAquiferLayerPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + thicknessAquiferLayerProperty, + schematizationCategory, + "Dikte watervoerend pakket [m]", + "De dikte van de bovenste voor doorlatendheid te onderscheiden zandlaag of combinatie van zandlagen.", + true); + Assert.IsInstanceOf(thicknessAquiferLayerProperty.Converter); + + PropertyDescriptor darcyPermeabilityProperty = dynamicProperties[expectedDarcyPermeabilityPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + darcyPermeabilityProperty, + schematizationCategory, + "Doorlatendheid aquifer [m/s]", + "Darcy-snelheid waarmee water door de eerste voor doorlatendheid te onderscheiden zandlaag loopt.", + true); + Assert.IsInstanceOf(darcyPermeabilityProperty.Converter); + + PropertyDescriptor diameter70Property = dynamicProperties[expectedDiameter70PropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + diameter70Property, + schematizationCategory, + "De d70 in de bovenste zandlaag [m]", + "Zeefmaat waar 70 gewichtsprocent van de korrels uit een zandlaag doorheen gaat. Hier de korreldiameter van het bovenste gedeelte van de voor doorlatendheid te onderscheiden zandlaag, bepaald zonder fijne fractie (< 63µm).", + true); + Assert.IsInstanceOf(diameter70Property.Converter); + + PropertyDescriptor saturatedVolumicWeightOfCoverageLayerProperty = dynamicProperties[expectedSaturatedVolumicWeightOfCoverageLayerPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + saturatedVolumicWeightOfCoverageLayerProperty, + schematizationCategory, + "Verzadigd gewicht deklaag [kN/m³]", + "Verzadigd gewicht deklaag.", + true); + Assert.IsInstanceOf(saturatedVolumicWeightOfCoverageLayerProperty.Converter); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_WithOrWithoutSurfaceLine_EntryAndExitPointPropertyReadOnlyWithoutSurfaceLine(bool withSurfaceLine) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + if (withSurfaceLine) + { + var surfaceLine = new PipingSurfaceLine(string.Empty); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 0), + new Point3D(2, 0, 2) + }); + calculationItem.InputParameters.SurfaceLine = surfaceLine; + } + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + const string schematizationCategory = "Schematisatie"; + + PropertyDescriptor entryPointLProperty = dynamicProperties[expectedEntryPointLPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + entryPointLProperty, + schematizationCategory, + "Intredepunt", + "De positie in het dwarsprofiel van het intredepunt.", + !withSurfaceLine); + + PropertyDescriptor exitPointLProperty = dynamicProperties[expectedExitPointLPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + exitPointLProperty, + schematizationCategory, + "Uittredepunt", + "De positie in het dwarsprofiel van het uittredepunt.", + !withSurfaceLine); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void GetProperties_UseAssessmentLevelManualInput_ReturnsExpectedAttributeValues(bool useManualAssessmentLevelInput) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler) + { + UseAssessmentLevelManualInput = useManualAssessmentLevelInput + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + const string hydraulicDataCategory = "Hydraulische gegevens"; + if (!useManualAssessmentLevelInput) + { + Assert.AreEqual(18, dynamicProperties.Count); + + PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[expectedSelectedHydraulicBoundaryLocationPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + hydraulicBoundaryLocationProperty, + hydraulicDataCategory, + "Hydraulische belastingenlocatie", + "De hydraulische belastingenlocatie waarvan de berekende waterstand wordt gebruikt."); + + PropertyDescriptor assessmentLevelProperty = dynamicProperties[expectedAssessmentLevelPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + assessmentLevelProperty, + hydraulicDataCategory, + "Waterstand [m+NAP]", + "Waterstand met een overschrijdingsfrequentie gelijk aan de norm van het dijktraject.", + true); + } + else + { + Assert.AreEqual(17, dynamicProperties.Count); + + PropertyDescriptor assessmentLevelProperty = dynamicProperties[0]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + assessmentLevelProperty, + hydraulicDataCategory, + "Waterstand [m+NAP]", + "Waterstand met een overschrijdingsfrequentie gelijk aan de norm van het dijktraject."); + } + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void GetProperties_WithData_ReturnExpectedValues(bool useManualAssessmentLevelInput) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var random = new Random(22); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + var stochasticSoilProfile = new PipingStochasticSoilProfile( + 0.0, new PipingSoilProfile(string.Empty, random.NextDouble(), new[] + { + new PipingSoilLayer(random.NextDouble()) + { + IsAquifer = true + } + }, SoilProfileType.SoilProfile1D) + ); + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName", new[] + { + stochasticSoilProfile + }); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + UseAssessmentLevelManualInput = useManualAssessmentLevelInput, + AssessmentLevel = random.NextRoundedDouble(), + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + SurfaceLine = surfaceLine, + StochasticSoilModel = stochasticSoilModel, + StochasticSoilProfile = stochasticSoilProfile + } + }; + + var failureMechanism = new PipingFailureMechanism(); + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Assert + Assert.AreEqual(inputParameters.PhreaticLevelExit.Mean, properties.PhreaticLevelExit.Mean); + Assert.AreEqual(inputParameters.PhreaticLevelExit.StandardDeviation, properties.PhreaticLevelExit.StandardDeviation); + Assert.AreEqual(inputParameters.DampingFactorExit.Mean, properties.DampingFactorExit.Mean); + Assert.AreEqual(inputParameters.DampingFactorExit.StandardDeviation, properties.DampingFactorExit.StandardDeviation); + + LogNormalDistribution thicknessCoverageLayer = DerivedPipingInput.GetThicknessCoverageLayer(inputParameters); + Assert.AreEqual(thicknessCoverageLayer.Mean, properties.ThicknessCoverageLayer.Mean); + Assert.AreEqual(thicknessCoverageLayer.StandardDeviation, properties.ThicknessCoverageLayer.StandardDeviation); + + LogNormalDistribution effectiveThicknessCoverageLayer = DerivedPipingInput.GetEffectiveThicknessCoverageLayer(inputParameters); + Assert.AreEqual(effectiveThicknessCoverageLayer.Mean, properties.EffectiveThicknessCoverageLayer.Mean); + Assert.AreEqual(effectiveThicknessCoverageLayer.StandardDeviation, properties.EffectiveThicknessCoverageLayer.StandardDeviation); + + VariationCoefficientLogNormalDistribution diameterD70 = DerivedPipingInput.GetDiameterD70(inputParameters); + Assert.AreEqual(diameterD70.Mean, properties.Diameter70.Mean); + Assert.AreEqual(diameterD70.CoefficientOfVariation, properties.Diameter70.CoefficientOfVariation); + + VariationCoefficientLogNormalDistribution darcyPermeability = DerivedPipingInput.GetDarcyPermeability(inputParameters); + Assert.AreEqual(darcyPermeability.Mean, properties.DarcyPermeability.Mean); + Assert.AreEqual(darcyPermeability.CoefficientOfVariation, properties.DarcyPermeability.CoefficientOfVariation); + + LogNormalDistribution thicknessAquiferLayer = DerivedPipingInput.GetThicknessAquiferLayer(inputParameters); + Assert.AreEqual(thicknessAquiferLayer.Mean, properties.ThicknessAquiferLayer.Mean); + Assert.AreEqual(thicknessAquiferLayer.StandardDeviation, properties.ThicknessAquiferLayer.StandardDeviation); + + LogNormalDistribution saturatedVolumicWeightOfCoverageLayer = DerivedPipingInput.GetSaturatedVolumicWeightOfCoverageLayer(inputParameters); + Assert.AreEqual(saturatedVolumicWeightOfCoverageLayer.Mean, + properties.SaturatedVolumicWeightOfCoverageLayer.Mean); + Assert.AreEqual(saturatedVolumicWeightOfCoverageLayer.StandardDeviation, + properties.SaturatedVolumicWeightOfCoverageLayer.StandardDeviation); + Assert.AreEqual(saturatedVolumicWeightOfCoverageLayer.Shift, + properties.SaturatedVolumicWeightOfCoverageLayer.Shift); + + RoundedDouble expectedAssessmentLevel = useManualAssessmentLevelInput + ? inputParameters.AssessmentLevel + : AssessmentSectionTestHelper.GetTestAssessmentLevel(); + + Assert.AreEqual(DerivedPipingInput.GetPiezometricHeadExit(inputParameters, expectedAssessmentLevel), properties.PiezometricHeadExit); + + Assert.AreEqual(DerivedPipingInput.GetSeepageLength(inputParameters).Mean, properties.SeepageLength.Mean); + Assert.AreEqual(DerivedPipingInput.GetSeepageLength(inputParameters).CoefficientOfVariation, properties.SeepageLength.CoefficientOfVariation); + Assert.AreEqual(DerivedPipingInput.GetSeepageLength(inputParameters).Mean, properties.ExitPointL - properties.EntryPointL); + Assert.AreEqual(inputParameters.ExitPointL, properties.ExitPointL); + + Assert.AreSame(surfaceLine, properties.SurfaceLine); + Assert.AreSame(stochasticSoilProfile, properties.StochasticSoilProfile); + Assert.AreSame(stochasticSoilModel, properties.StochasticSoilModel); + + Assert.AreSame(hydraulicBoundaryLocation, properties.SelectedHydraulicBoundaryLocation.HydraulicBoundaryLocation); + Assert.AreEqual(expectedAssessmentLevel, properties.AssessmentLevel); + Assert.AreEqual(inputParameters.UseAssessmentLevelManualInput, properties.UseAssessmentLevelManualInput); + + mocks.VerifyAll(); + } + + [Test] + public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() + { + // Given + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + const double assessmentLevel = 0.36; + const double entryPointL = 0.12; + const double exitPointL = 0.44; + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingStochasticSoilModel soilModel = ValidStochasticSoilModel(0.0, 4.0); + PipingStochasticSoilProfile soilProfile = soilModel.StochasticSoilProfiles.First(); + var dampingFactorExit = new LogNormalDistributionDesignVariable( + new LogNormalDistribution(3) + { + Mean = (RoundedDouble) 1.55, + StandardDeviation = (RoundedDouble) 0.22 + }); + var phreaticLevelExit = new NormalDistributionDesignVariable( + new NormalDistribution(3) + { + Mean = (RoundedDouble) 1.55, + StandardDeviation = (RoundedDouble) 0.22 + }); + + // When + properties.AssessmentLevel = (RoundedDouble) assessmentLevel; + properties.SurfaceLine = surfaceLine; + properties.EntryPointL = (RoundedDouble) entryPointL; + properties.ExitPointL = (RoundedDouble) exitPointL; + properties.StochasticSoilModel = soilModel; + properties.StochasticSoilProfile = soilProfile; + properties.DampingFactorExit.Mean = dampingFactorExit.Distribution.Mean; + properties.DampingFactorExit.StandardDeviation = dampingFactorExit.Distribution.StandardDeviation; + properties.PhreaticLevelExit.Mean = phreaticLevelExit.Distribution.Mean; + properties.PhreaticLevelExit.StandardDeviation = phreaticLevelExit.Distribution.StandardDeviation; + + // Then + Assert.AreEqual(assessmentLevel, inputParameters.AssessmentLevel, + inputParameters.AssessmentLevel.GetAccuracy()); + Assert.AreEqual(entryPointL, inputParameters.EntryPointL, + inputParameters.EntryPointL.GetAccuracy()); + Assert.AreEqual(exitPointL, inputParameters.ExitPointL, + inputParameters.ExitPointL.GetAccuracy()); + Assert.AreSame(surfaceLine, inputParameters.SurfaceLine); + Assert.AreSame(soilModel, inputParameters.StochasticSoilModel); + Assert.AreSame(soilProfile, inputParameters.StochasticSoilProfile); + DistributionAssert.AreEqual(dampingFactorExit.Distribution, inputParameters.DampingFactorExit); + DistributionAssert.AreEqual(phreaticLevelExit.Distribution, inputParameters.PhreaticLevelExit); + mocks.VerifyAll(); + } + + [Test] + public void SurfaceLine_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + PipingSurfaceLine newSurfaceLine = ValidSurfaceLine(0.0, 4.0); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(p => p.SurfaceLine = newSurfaceLine, calculation); + } + + [Test] + public void StochasticSoilModel_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + PipingStochasticSoilModel newSoilModel = ValidStochasticSoilModel(0.0, 4.0); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.StochasticSoilModel = newSoilModel, calculation); + } + + [Test] + public void StochasticSoilProfile_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + PipingStochasticSoilProfile newSoilProfile = ValidStochasticSoilModel(0.0, 4.0).StochasticSoilProfiles.First(); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.StochasticSoilProfile = newSoilProfile, calculation); + } + + [Test] + public void AssessmentLevel_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + RoundedDouble newAssessmentLevel = new Random(21).NextRoundedDouble(); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.AssessmentLevel = newAssessmentLevel, calculation); + } + + [Test] + public void DampingFactorExitMean_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var mean = new RoundedDouble(2, 2); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.DampingFactorExit.Mean = mean, calculation); + } + + [Test] + public void DampingFactorExitStandardDeviation_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var standardDeviation = new RoundedDouble(2, 2); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.DampingFactorExit.StandardDeviation = standardDeviation, calculation); + } + + [Test] + public void PhreaticLevelExitMean_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var mean = new RoundedDouble(2, 2); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.PhreaticLevelExit.Mean = mean, calculation); + } + + [Test] + public void PhreaticLevelExitStandardDeviation_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var standardDeviation = new RoundedDouble(2, 2); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.PhreaticLevelExit.StandardDeviation = standardDeviation, calculation); + } + + [Test] + public void EntryPointL_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + RoundedDouble newEntryPointL = new Random(21).NextRoundedDouble(); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.EntryPointL = newEntryPointL, calculation); + } + + [Test] + public void ExitPointL_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + RoundedDouble newExitPointL = new Random(21).NextRoundedDouble(); + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.ExitPointL = newExitPointL, calculation); + } + + [Test] + public void UseAssessmentLevelManualInput_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.UseAssessmentLevelManualInput = true, + calculation); + } + + [Test] + public void SelectedHydraulicBoundaryLocation_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + + // Call & Assert + SetPropertyAndVerifyNotificationsForCalculation(properties => properties.SelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation(new TestHydraulicBoundaryLocation(), null), + calculation); + } + + [Test] + [TestCase(0, 3, 3)] + [TestCase(2, 4, 2)] + [TestCase(1e-2, 4, 4 - 1e-2)] + [TestCase(1e-2, 3, 3 - 1e-2)] + [TestCase(1, 1 + 1e-2, 1e-2)] + public void SeepageLength_ExitPointAndEntryPointSet_ExpectedValue(double entryPoint, double exitPoint, double seepageLength) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var inputObserver = mocks.StrictMock(); + const int numberOfChangedProperties = 2; + inputObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + mocks.ReplayAll(); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + inputParameters.SurfaceLine = surfaceLine; + inputParameters.Attach(inputObserver); + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler) + { + ExitPointL = (RoundedDouble) exitPoint, + EntryPointL = (RoundedDouble) entryPoint + }; + + // Assert + Assert.AreEqual(seepageLength, properties.SeepageLength.Mean, 1e-6); + Assert.AreEqual(inputParameters.ExitPointL, properties.ExitPointL); + + mocks.VerifyAll(); + } + + [Test] + public void SeepageLength_EntryPointAndThenExitPointSet_ExpectedValue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var inputObserver = mocks.StrictMock(); + const int numberOfChangedProperties = 2; + inputObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); + mocks.ReplayAll(); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()); + var failureMechanism = new PipingFailureMechanism(); + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + inputParameters.SurfaceLine = surfaceLine; + inputParameters.Attach(inputObserver); + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); + + // Call + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler) + { + EntryPointL = (RoundedDouble) 0.5, + ExitPointL = (RoundedDouble) 2 + }; + + // Assert + Assert.AreEqual(1.5, properties.SeepageLength.Mean.Value); + Assert.AreEqual(inputParameters.ExitPointL, properties.ExitPointL); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(2.0)] + [TestCase(-5.0)] + public void ExitPointL_InvalidValue_ThrowsArgumentOutOfRangeException(double newExitPoint) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observable = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = surfaceLine, + EntryPointL = (RoundedDouble) 2.0 + } + }; + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var newExitPointL = (RoundedDouble) newExitPoint; + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + TestDelegate call = () => properties.ExitPointL = newExitPointL; + + // Assert + const string expectedMessage = "Het uittredepunt moet landwaarts van het intredepunt liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + mocks.VerifyAll(); // No observer notified + } + + [Test] + [TestCase(2.0)] + [TestCase(5.0)] + public void EntryPointL_InvalidValue_ThrowsArgumentOutOfRangeException(double newEntryPoint) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observable = mocks.StrictMock(); + mocks.ReplayAll(); + + var entryPoint = (RoundedDouble) newEntryPoint; + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = surfaceLine, + ExitPointL = (RoundedDouble) 2.0 + } + }; + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + TestDelegate call = () => properties.EntryPointL = entryPoint; + + // Assert + const string expectedMessage = "Het uittredepunt moet landwaarts van het intredepunt liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + Assert.IsTrue(handler.Called); + mocks.VerifyAll(); // No observer notified + } + + [Test] + [SetCulture("nl-NL")] + public void EntryPointL_NotOnSurfaceLine_ThrowsArgumentOutOfRangeException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observable = mocks.StrictMock(); + mocks.ReplayAll(); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = surfaceLine, + ExitPointL = (RoundedDouble) 2.0 + } + }; + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var entryPointL = (RoundedDouble) (-15.0); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + TestDelegate call = () => properties.EntryPointL = entryPointL; + + // Assert + const string expectedMessage = "Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 4,0])."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + mocks.VerifyAll(); // No observer notified + } + + [Test] + [SetCulture("nl-NL")] + public void ExitPointL_NotOnSurfaceLine_ThrowsArgumentOutOfRangeException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observable = mocks.StrictMock(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = ValidSurfaceLine(0.0, 4.0), + EntryPointL = (RoundedDouble) 2.0 + } + }; + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var exitPointL = (RoundedDouble) 10.0; + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + TestDelegate call = () => properties.ExitPointL = exitPointL; + + // Assert + const string expectedMessage = "Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 4,0])."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + mocks.VerifyAll(); // No observer notified + } + + [Test] + public void SurfaceLine_NewSurfaceLine_StochasticSoilModelAndSoilProfileSetToNull() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = ValidSurfaceLine(0.0, 4.0) + } + }; + var failureMechanism = new PipingFailureMechanism(); + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + PipingSurfaceLine newSurfaceLine = ValidSurfaceLine(0, 2); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + inputParameters.StochasticSoilProfile = new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + + // Call + properties.SurfaceLine = newSurfaceLine; + + // Assert + Assert.IsNull(inputParameters.StochasticSoilModel); + Assert.IsNull(inputParameters.StochasticSoilProfile); + mocks.VerifyAll(); + } + + [Test] + public void SurfaceLine_SameSurfaceLine_SoilProfileUnchanged() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + PipingSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName", new[] + { + stochasticSoilProfile + }); + + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = testSurfaceLine, + StochasticSoilModel = stochasticSoilModel, + StochasticSoilProfile = stochasticSoilProfile + } + }; + var failureMechanism = new PipingFailureMechanism(); + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + new[] + { + stochasticSoilModel + }, + failureMechanism, + assessmentSection); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + properties.SurfaceLine = testSurfaceLine; + + // Assert + Assert.AreSame(stochasticSoilModel, inputParameters.StochasticSoilModel); + Assert.AreSame(stochasticSoilProfile, inputParameters.StochasticSoilProfile); + mocks.VerifyAll(); + } + + [Test] + public void SurfaceLine_DifferentSurfaceLine_StochasticSoilModelAndSoilProfileSetToNull() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var stochasticSoilProfile = new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("StochasticSoilModelName", new[] + { + stochasticSoilProfile + }); + var calculationItem = new SemiProbabilisticPipingCalculationScenario(new GeneralPipingInput()) + { + InputParameters = + { + SurfaceLine = ValidSurfaceLine(0, 4), + StochasticSoilModel = stochasticSoilModel, + StochasticSoilProfile = stochasticSoilProfile + } + }; + + SemiProbabilisticPipingInput inputParameters = calculationItem.InputParameters; + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculationItem, + Enumerable.Empty(), + new[] + { + stochasticSoilModel + }, + failureMechanism, + assessmentSection); + + PipingSurfaceLine newSurfaceLine = ValidSurfaceLine(0, 2); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + properties.SurfaceLine = newSurfaceLine; + + // Assert + Assert.IsNull(inputParameters.StochasticSoilModel); + Assert.IsNull(inputParameters.StochasticSoilProfile); + mocks.VerifyAll(); + } + + [Test] + public void GetAvailableSurfaceLines_Always_ReturnAllPipingSurfaceLines() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + IEnumerable surfaceLines = properties.GetAvailableSurfaceLines(); + + // Assert + Assert.AreSame(context.AvailablePipingSurfaceLines, surfaceLines); + mocks.VerifyAll(); + } + + [Test] + public void GetAvailableStochasticSoilModels_NoSurfaceLineAssigned_ReturnAllStochasticSoilModels() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Precondition: + Assert.IsNull(calculation.InputParameters.SurfaceLine); + + // Call + IEnumerable soilModels = properties.GetAvailableStochasticSoilModels(); + + // Assert + Assert.AreSame(context.AvailableStochasticSoilModels, soilModels); + mocks.VerifyAll(); + } + + [Test] + public void GetAvailableStochasticSoilModels_SurfaceLineAssigned_ReturnMatchingSubsetOfStochasticSoilModels() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var surfaceLine = new PipingSurfaceLine(string.Empty); + surfaceLine.SetGeometry(new[] + { + new Point3D(0, 0, 0), + new Point3D(10, 0, 0) + }); + var failureMechanism = new PipingFailureMechanism(); + var soilModels = new[] + { + new PipingStochasticSoilModel("A", new[] + { + new Point2D(2, -1), + new Point2D(2, 1) + }, new[] + { + new PipingStochasticSoilProfile(0.2, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), + new PipingStochasticSoilModel("C", new[] + { + new Point2D(-2, -1), + new Point2D(-2, 1) + }, new[] + { + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }), + new PipingStochasticSoilModel("E", new[] + { + new Point2D(6, -1), + new Point2D(6, 1) + }, new[] + { + new PipingStochasticSoilProfile(0.3, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }) + }; + failureMechanism.StochasticSoilModels.AddRange(soilModels, "path"); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + SurfaceLine = surfaceLine + } + }; + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Precondition: + Assert.IsNotNull(calculation.InputParameters.SurfaceLine); + + // Call + IEnumerable availableStochasticSoilModels = properties.GetAvailableStochasticSoilModels(); + + // Assert + CollectionAssert.AreEqual(new[] + { + failureMechanism.StochasticSoilModels[0], + failureMechanism.StochasticSoilModels[2] + }, availableStochasticSoilModels); + mocks.VerifyAll(); + } + + [Test] + public void GetAvailableStochasticSoilProfiles_NoStochasticSoilModel_ReturnEmpty() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Precondition + Assert.IsNull(calculation.InputParameters.StochasticSoilModel); + + // Call + IEnumerable profiles = properties.GetAvailableStochasticSoilProfiles(); + + // Assert + CollectionAssert.IsEmpty(profiles); + mocks.VerifyAll(); + } + + [Test] + public void GetAvailableStochasticSoilProfiles_StochasticSoilModel_ReturnAssignedSoilModelProfiles() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + PipingStochasticSoilModel model = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A", new[] + { + new PipingStochasticSoilProfile(1.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); + + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + StochasticSoilModel = model + } + }; + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Precondition + Assert.IsNotNull(calculation.InputParameters.StochasticSoilModel); + + // Call + IEnumerable profiles = properties.GetAvailableStochasticSoilProfiles(); + + // Assert + CollectionAssert.AreEqual(model.StochasticSoilProfiles, profiles); + mocks.VerifyAll(); + } + + [Test] + public void SelectedHydraulicBoundaryLocation_InputNoLocation_ReturnsNull() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; + + // Call + TestDelegate call = () => selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; + + // Assert + Assert.DoesNotThrow(call); + Assert.IsNull(selectedHydraulicBoundaryLocation); + mocks.VerifyAll(); + } + + [Test] + public void GivenPropertiesWithSurfaceLineAndLocations_WhenSelectingLocation_ThenSelectedLocationDistanceSameAsLocationItem() + { + // Given + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + var handler = mockRepository.Stub(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 200643.312, 503347.25); + + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(new HydraulicBoundaryDatabase + { + Locations = + { + hydraulicBoundaryLocation + } + }); + + mockRepository.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + PipingStochasticSoilModel soilModel = ValidStochasticSoilModel(0.0, 4.0); + PipingStochasticSoilProfile soilProfile = soilModel.StochasticSoilProfiles.First(); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + SurfaceLine = ValidSurfaceLine(0, 4.0), + StochasticSoilModel = soilModel, + StochasticSoilProfile = soilProfile + } + }; + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // When + IEnumerable availableHydraulicBoundaryLocations = + properties.GetSelectableHydraulicBoundaryLocations(); + SelectableHydraulicBoundaryLocation selectedLocation = properties.SelectedHydraulicBoundaryLocation; + + // Then + SelectableHydraulicBoundaryLocation hydraulicBoundaryLocationItem = availableHydraulicBoundaryLocations.ToArray()[0]; + Assert.AreEqual(selectedLocation.Distance, hydraulicBoundaryLocationItem.Distance, + hydraulicBoundaryLocationItem.Distance.GetAccuracy()); + + mockRepository.VerifyAll(); + } + + [Test] + public void GetSelectableHydraulicBoundaryLocations_WithLocationsNoSurfaceLine_ReturnLocationsSortedById() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + new HydraulicBoundaryLocation(1, "A", 0, 1), + new HydraulicBoundaryLocation(4, "C", 0, 2), + new HydraulicBoundaryLocation(3, "D", 0, 3), + new HydraulicBoundaryLocation(2, "B", 0, 4) + } + }; + + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + IEnumerable selectableHydraulicBoundaryLocations = + properties.GetSelectableHydraulicBoundaryLocations(); + + // Assert + IEnumerable expectedList = + hydraulicBoundaryDatabase.Locations.Select(hbl => new SelectableHydraulicBoundaryLocation(hbl, null)) + .OrderBy(hbl => hbl.HydraulicBoundaryLocation.Id); + CollectionAssert.AreEqual(expectedList, selectableHydraulicBoundaryLocations); + mocks.VerifyAll(); + } + + [Test] + public void GetSelectableHydraulicBoundaryLocations_WithLocationsAndSurfaceLine_ReturnLocationsSortedByDistanceThenById() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + new HydraulicBoundaryLocation(1, "A", 0, 10), + new HydraulicBoundaryLocation(4, "E", 0, 500), + new HydraulicBoundaryLocation(6, "F", 0, 100), + new HydraulicBoundaryLocation(5, "D", 0, 200), + new HydraulicBoundaryLocation(3, "C", 0, 200), + new HydraulicBoundaryLocation(2, "B", 0, 200) + } + }; + + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0.0, 0.0); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + SurfaceLine = surfaceLine + } + }; + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + IEnumerable selectableHydraulicBoundaryLocations = + properties.GetSelectableHydraulicBoundaryLocations(); + + // Assert + IEnumerable expectedList = + hydraulicBoundaryDatabase.Locations.Select(hbl => new SelectableHydraulicBoundaryLocation( + hbl, surfaceLine.ReferenceLineIntersectionWorldPoint)) + .OrderBy(hbl => hbl.Distance) + .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Id); + CollectionAssert.AreEqual(expectedList, selectableHydraulicBoundaryLocations); + mocks.VerifyAll(); + } + + [Test] + public void GivenLocationAndReferencePoint_WhenUpdatingSurfaceLine_ThenUpdateSelectableBoundaryLocations() + { + // Given + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observable = mocks.StrictMock(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + new HydraulicBoundaryLocation(1, "A", 0, 10), + new HydraulicBoundaryLocation(4, "E", 0, 500), + new HydraulicBoundaryLocation(6, "F", 0, 100), + new HydraulicBoundaryLocation(5, "D", 0, 200), + new HydraulicBoundaryLocation(3, "C", 0, 200), + new HydraulicBoundaryLocation(2, "B", 0, 200) + } + }; + + observable.Expect(o => o.NotifyObservers()); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + PipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + surfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0, 0); + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + SurfaceLine = surfaceLine + } + }; + + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, + failureMechanism, assessmentSection); + + PipingSurfaceLine newSurfaceLine = ValidSurfaceLine(0.0, 5.0); + newSurfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0, 190); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() + .ToList(); + + // When + properties.SurfaceLine = newSurfaceLine; + + // Then + IEnumerable availableHydraulicBoundaryLocations = + properties.GetSelectableHydraulicBoundaryLocations().ToList(); + CollectionAssert.AreNotEqual(originalList, availableHydraulicBoundaryLocations); + + IEnumerable expectedList = + hydraulicBoundaryDatabase.Locations + .Select(hbl => + new SelectableHydraulicBoundaryLocation(hbl, + properties.SurfaceLine.ReferenceLineIntersectionWorldPoint)) + .OrderBy(hbl => hbl.Distance) + .ThenBy(hbl => hbl.HydraulicBoundaryLocation.Id); + CollectionAssert.AreEqual(expectedList, availableHydraulicBoundaryLocations); + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicReadOnlyValidationMethod_AssessmentLevel_DependsOnUseAssessmentLevelManualInput(bool useAssessmentLevelManualInput) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + UseAssessmentLevelManualInput = useAssessmentLevelManualInput + } + }; + + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, assessmentSection); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + bool result = properties.DynamicReadOnlyValidationMethod("AssessmentLevel"); + + // Assert + Assert.AreNotEqual(useAssessmentLevelManualInput, result); + } + + [Test] + public void DynamicReadOnlyValidationMethod_AnyOtherProperty_ReturnsTrue() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, assessmentSection); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + bool result = properties.DynamicReadOnlyValidationMethod("prop"); + + // Assert + Assert.IsTrue(result); + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_SelectedHydraulicBoundaryLocation_DependsOnUseAssessmentLevelManualInput(bool useAssessmentLevelManualInput) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput) + { + InputParameters = + { + UseAssessmentLevelManualInput = useAssessmentLevelManualInput + } + }; + + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, assessmentSection); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + bool result = properties.DynamicVisibleValidationMethod("SelectedHydraulicBoundaryLocation"); + + // Assert + Assert.AreNotEqual(useAssessmentLevelManualInput, result); + } + + [Test] + public void DynamicVisibleValidationMethod_AnyOtherProperty_ReturnsFalse() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new PipingFailureMechanism(); + + var calculation = new SemiProbabilisticPipingCalculationScenario(failureMechanism.GeneralInput); + + var context = new SemiProbabilisticPipingInputContext(calculation.InputParameters, calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, assessmentSection); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + bool result = properties.DynamicVisibleValidationMethod("prop"); + + // Assert + Assert.IsFalse(result); + } + + private static void SetPropertyAndVerifyNotificationsForCalculation( + Action setProperty, + SemiProbabilisticPipingCalculationScenario calculation) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observable = mocks.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mocks.ReplayAll(); + + SemiProbabilisticPipingInput inputParameters = calculation.InputParameters; + + var failureMechanism = new PipingFailureMechanism(); + + var context = new SemiProbabilisticPipingInputContext(inputParameters, + calculation, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new SemiProbabilisticPipingInputContextProperties(context, + AssessmentSectionTestHelper.GetTestAssessmentLevel, + handler); + + // Call + setProperty(properties); + + // Assert + Assert.IsTrue(handler.Called); + mocks.VerifyAll(); + } + + private static PipingStochasticSoilModel ValidStochasticSoilModel(double xMin, double xMax) + { + return new PipingStochasticSoilModel("StochasticSoilModelName", new[] + { + new Point2D(xMin, 1.0), + new Point2D(xMax, 0.0) + }, new[] + { + new PipingStochasticSoilProfile(0.0, PipingSoilProfileTestFactory.CreatePipingSoilProfile()) + }); + } + + private static PipingSurfaceLine ValidSurfaceLine(double xMin, double xMax) + { + var surfaceLine = new PipingSurfaceLine(string.Empty); + surfaceLine.SetGeometry(new[] + { + new Point3D(xMin, 0.0, 0.0), + new Point3D(xMax, 0.0, 1.0) + }); + return surfaceLine; + } + } +} \ No newline at end of file Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs =================================================================== diff -u -r8eb7384995560912b2fd268726abe51e7b75bfd8 -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs (.../PipingInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 8eb7384995560912b2fd268726abe51e7b75bfd8) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilModelSelectionEditorTest.cs (.../PipingInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -75,7 +75,7 @@ failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties(pipingInputContext, + var properties = new SemiProbabilisticPipingInputContextProperties(pipingInputContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); @@ -145,7 +145,7 @@ failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties(inputParametersContext, + var properties = new SemiProbabilisticPipingInputContextProperties(inputParametersContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs =================================================================== diff -u -r8eb7384995560912b2fd268726abe51e7b75bfd8 -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs (.../PipingInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 8eb7384995560912b2fd268726abe51e7b75bfd8) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextStochasticSoilProfileSelectionEditorTest.cs (.../PipingInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -75,7 +75,7 @@ failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties(pipingInputContext, + var properties = new SemiProbabilisticPipingInputContextProperties(pipingInputContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); @@ -145,7 +145,7 @@ failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties(inputParametersContext, + var properties = new SemiProbabilisticPipingInputContextProperties(inputParametersContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextSurfaceLineSelectionEditorTest.cs =================================================================== diff -u -r8eb7384995560912b2fd268726abe51e7b75bfd8 -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextSurfaceLineSelectionEditorTest.cs (.../PipingInputContextSurfaceLineSelectionEditorTest.cs) (revision 8eb7384995560912b2fd268726abe51e7b75bfd8) +++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/UITypeEditors/PipingInputContextSurfaceLineSelectionEditorTest.cs (.../PipingInputContextSurfaceLineSelectionEditorTest.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -73,7 +73,7 @@ failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties(inputParametersContext, + var properties = new SemiProbabilisticPipingInputContextProperties(inputParametersContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); @@ -130,7 +130,7 @@ failureMechanism, assessmentSection); - var properties = new PipingInputContextProperties(inputParametersContext, + var properties = new SemiProbabilisticPipingInputContextProperties(inputParametersContext, AssessmentSectionTestHelper.GetTestAssessmentLevel, handler); Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs =================================================================== diff -u -r8eb7384995560912b2fd268726abe51e7b75bfd8 -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 8eb7384995560912b2fd268726abe51e7b75bfd8) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PipingPluginTest.cs (.../PipingPluginTest.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -83,7 +83,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(SemiProbabilisticPipingInputContext), - typeof(PipingInputContextProperties)); + typeof(SemiProbabilisticPipingInputContextProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, Index: Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs =================================================================== diff -u -r8eb7384995560912b2fd268726abe51e7b75bfd8 -r49f74b91e9188a8e74619a59fc7d90ad7c2bb20c --- Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs (.../PipingInputContextPropertyInfoTest.cs) (revision 8eb7384995560912b2fd268726abe51e7b75bfd8) +++ Riskeer/Piping/test/Riskeer.Piping.Plugin.Test/PropertyInfos/PipingInputContextPropertyInfoTest.cs (.../PipingInputContextPropertyInfoTest.cs) (revision 49f74b91e9188a8e74619a59fc7d90ad7c2bb20c) @@ -46,7 +46,7 @@ public void SetUp() { plugin = new PipingPlugin(); - info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(PipingInputContextProperties)); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(SemiProbabilisticPipingInputContextProperties)); } [TearDown] @@ -60,7 +60,7 @@ { // Assert Assert.AreEqual(typeof(SemiProbabilisticPipingInputContext), info.DataType); - Assert.AreEqual(typeof(PipingInputContextProperties), info.PropertyObjectType); + Assert.AreEqual(typeof(SemiProbabilisticPipingInputContextProperties), info.PropertyObjectType); } [Test] @@ -102,11 +102,11 @@ IObjectProperties objectProperties = info.CreateInstance(context); // Assert - Assert.IsInstanceOf(objectProperties); + Assert.IsInstanceOf(objectProperties); Assert.AreSame(context, objectProperties.Data); double expectedAssessmentLevel = assessmentSection.WaterLevelCalculationsForSignalingNorm.ElementAt(0).Output.Result; - Assert.AreEqual(expectedAssessmentLevel, ((PipingInputContextProperties) objectProperties).AssessmentLevel); + Assert.AreEqual(expectedAssessmentLevel, ((SemiProbabilisticPipingInputContextProperties) objectProperties).AssessmentLevel); } [Test] @@ -148,11 +148,11 @@ IObjectProperties objectProperties = info.CreateInstance(context); // Assert - Assert.IsInstanceOf(objectProperties); + Assert.IsInstanceOf(objectProperties); Assert.AreSame(context, objectProperties.Data); double expectedAssessmentLevel = assessmentSection.WaterLevelCalculationsForLowerLimitNorm.ElementAt(0).Output.Result; - Assert.AreEqual(expectedAssessmentLevel, ((PipingInputContextProperties) objectProperties).AssessmentLevel); + Assert.AreEqual(expectedAssessmentLevel, ((SemiProbabilisticPipingInputContextProperties) objectProperties).AssessmentLevel); } } } \ No newline at end of file