Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/CalculationsState/MacroStabilityInwardsFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/CalculationsState/MacroStabilityInwardsFailureMechanismProperties.cs (revision 0) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/CalculationsState/MacroStabilityInwardsFailureMechanismProperties.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,85 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Riskeer.MacroStabilityInwards.Data; +using Riskeer.MacroStabilityInwards.Forms.Properties; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState +{ + /// + /// Calculations state related ViewModel of for properties panel. + /// + public class MacroStabilityInwardsFailureMechanismProperties : MacroStabilityInwardsFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int waterVolumetricWeightPropertyIndex = 3; + private const int modelFactorPropertyIndex = 4; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public MacroStabilityInwardsFailureMechanismProperties(MacroStabilityInwardsFailureMechanism data) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) {} + + #region Model settings + + [PropertyOrder(modelFactorPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.MacroStabilityInwardsFailureMechanismProperties_ModelFactor_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.MacroStabilityInwardsFailureMechanismProperties_ModelFactor_Description))] + public double ModelFactor + { + get + { + return data.GeneralInput.ModelFactor; + } + } + + #endregion + + #region General + + [PropertyOrder(waterVolumetricWeightPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.WaterVolumetricWeight_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.WaterVolumetricWeight_Description))] + public double WaterVolumetricWeight + { + get + { + return data.GeneralInput.WaterVolumetricWeight; + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsCalculationsProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesBase.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesBase.cs (revision 0) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesBase.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,128 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Core.Gui.PropertyBag; +using Riskeer.MacroStabilityInwards.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.MacroStabilityInwards.Forms.PropertyClasses +{ + /// + /// Base ViewModel of for properties panel. + /// + public abstract class MacroStabilityInwardsFailureMechanismPropertiesBase : ObjectProperties + { + private readonly Dictionary propertyIndexLookup; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// The property values required to create an instance of + /// . + /// Thrown when any parameter is null. + protected MacroStabilityInwardsFailureMechanismPropertiesBase(MacroStabilityInwardsFailureMechanism data, + ConstructionProperties constructionProperties) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (constructionProperties == null) + { + throw new ArgumentNullException(nameof(constructionProperties)); + } + + Data = data; + + propertyIndexLookup = new Dictionary + { + { + nameof(Name), constructionProperties.NamePropertyIndex + }, + { + nameof(Code), constructionProperties.CodePropertyIndex + } + }; + } + + [DynamicPropertyOrderEvaluationMethod] + public int DynamicPropertyOrderEvaluationMethod(string propertyName) + { + propertyIndexLookup.TryGetValue(propertyName, out int propertyIndex); + + return propertyIndex; + } + + /// + /// Class holding the various construction parameters for . + /// + public class ConstructionProperties + { + #region General + + /// + /// Gets or sets the property index for . + /// + public int NamePropertyIndex { get; set; } + + /// + /// Gets or sets the property index for . + /// + public int CodePropertyIndex { get; set; } + + #endregion + } + + #region General + + [DynamicPropertyOrder] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_Description))] + public string Name + { + get + { + return data.Name; + } + } + + [DynamicPropertyOrder] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_Description))] + public string Code + { + get + { + return data.Code; + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailurePathProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/RegistrationState/MacroStabilityInwardsFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/RegistrationState/MacroStabilityInwardsFailureMechanismProperties.cs (revision 0) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Forms/PropertyClasses/RegistrationState/MacroStabilityInwardsFailureMechanismProperties.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,177 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Data; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Probability; +using Riskeer.MacroStabilityInwards.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState +{ + /// + /// Registration state related ViewModel of for properties panel. + /// + public class MacroStabilityInwardsFailureMechanismProperties : MacroStabilityInwardsFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int inAssemblyPropertyIndex = 3; + private const int aPropertyIndex = 4; + private const int bPropertyIndex = 5; + private const int sectionLengthPropertyIndex = 6; + private const int nPropertyIndex = 7; + private const int applyLengthEffectInSectionPropertyIndex = 8; + + private readonly IAssessmentSection assessmentSection; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// The assessment section the data belongs to. + /// Thrown when any parameter is null. + public MacroStabilityInwardsFailureMechanismProperties(MacroStabilityInwardsFailureMechanism data, + IAssessmentSection assessmentSection) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + this.assessmentSection = assessmentSection; + } + + #region General + + [PropertyOrder(inAssemblyPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_InAssembly_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_InAssembly_Description))] + public bool InAssembly + { + get + { + return data.InAssembly; + } + } + + #endregion + + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + return data.InAssembly || !ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(propertyName); + } + + private static bool ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(string propertyName) + { + return nameof(A).Equals(propertyName) + || nameof(B).Equals(propertyName) + || nameof(SectionLength).Equals(propertyName) + || nameof(N).Equals(propertyName) + || nameof(ApplyLengthEffectInSection).Equals(propertyName); + } + + #region Length effect parameters + + [DynamicVisible] + [PropertyOrder(aPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_ProbabilityAssessmentInput_A_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_ProbabilityAssessmentInput_A_Description))] + public double A + { + get + { + return data.MacroStabilityInwardsProbabilityAssessmentInput.A; + } + set + { + data.MacroStabilityInwardsProbabilityAssessmentInput.A = value; + data.NotifyObservers(); + } + } + + [DynamicVisible] + [PropertyOrder(bPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_ProbabilityAssessmentInput_B_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_ProbabilityAssessmentInput_B_Description))] + public double B + { + get + { + return data.MacroStabilityInwardsProbabilityAssessmentInput.B; + } + } + + [DynamicVisible] + [PropertyOrder(sectionLengthPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ReferenceLine_Length_Rounded_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ReferenceLine_Length_Rounded_Description))] + public RoundedDouble SectionLength + { + get + { + return new RoundedDouble(2, assessmentSection.ReferenceLine.Length); + } + } + + [DynamicVisible] + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_Description))] + public RoundedDouble N + { + get + { + MacroStabilityInwardsProbabilityAssessmentInput probabilityAssessmentInput = data.MacroStabilityInwardsProbabilityAssessmentInput; + return new RoundedDouble(2, probabilityAssessmentInput.GetN(assessmentSection.ReferenceLine.Length)); + } + } + + [DynamicVisible] + [PropertyOrder(applyLengthEffectInSectionPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_ApplyLengthEffectInSection_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_ApplyLengthEffectInSection_Description))] + public bool ApplyLengthEffectInSection + { + get + { + return data.GeneralInput.ApplyLengthEffectInSection; + } + } + + #endregion + } +} \ No newline at end of file Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs =================================================================== diff -u -r160e88782fbd20958a9ebd55511782b203d141e5 -r28c89f52a156d628eb86a1807d03e6b49de5ba89 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 160e88782fbd20958a9ebd55511782b203d141e5) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -61,6 +61,8 @@ using Riskeer.MacroStabilityInwards.Plugin.Properties; using Riskeer.MacroStabilityInwards.Primitives; using Riskeer.MacroStabilityInwards.Service; +using CalculationsStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState.MacroStabilityInwardsFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState.MacroStabilityInwardsFailureMechanismProperties; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources; @@ -75,19 +77,19 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new MacroStabilityInwardsCalculationsProperties(context.WrappedData) + CreateInstance = context => new CalculationsStateFailureMechanismProperties(context.WrappedData) }; - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new MacroStabilityInwardsFailurePathProperties(context.WrappedData, context.Parent) + CreateInstance = context => new RegistrationStateFailureMechanismProperties(context.WrappedData, context.Parent) }; yield return new PropertyInfo { - CreateInstance = context => new MacroStabilityInwardsInputContextProperties(context, - () => GetNormativeAssessmentLevel(context.AssessmentSection, context.MacroStabilityInwardsCalculation), - new ObservablePropertyChangeHandler(context.MacroStabilityInwardsCalculation, context.WrappedData)) + CreateInstance = context => new MacroStabilityInwardsInputContextProperties( + context, () => GetNormativeAssessmentLevel(context.AssessmentSection, context.MacroStabilityInwardsCalculation), + new ObservablePropertyChangeHandler(context.MacroStabilityInwardsCalculation, context.WrappedData)) }; yield return new PropertyInfo { @@ -113,7 +115,7 @@ yield return new PropertyInfo { CreateInstance = context => new FailureMechanismSectionsProbabilityAssessmentProperties( - (IFailureMechanism) context.WrappedData, ((MacroStabilityInwardsFailureMechanism) context.WrappedData).MacroStabilityInwardsProbabilityAssessmentInput) + context.WrappedData, ((MacroStabilityInwardsFailureMechanism) context.WrappedData).MacroStabilityInwardsProbabilityAssessmentInput) }; } @@ -310,9 +312,9 @@ { GetViewName = (view, context) => RiskeerCommonFormsResources.FailureMechanismSections_DisplayName, CloseForData = RiskeerPluginHelper.ShouldCloseForFailureMechanismView, - CreateInstance = context => new FailureMechanismSectionsProbabilityAssessmentView(context.WrappedData.Sections, - (IFailureMechanism) context.WrappedData, - ((MacroStabilityInwardsFailureMechanism) context.WrappedData).MacroStabilityInwardsProbabilityAssessmentInput), + CreateInstance = context => new FailureMechanismSectionsProbabilityAssessmentView( + context.WrappedData.Sections, context.WrappedData, + ((MacroStabilityInwardsFailureMechanism) context.WrappedData).MacroStabilityInwardsProbabilityAssessmentInput), GetViewData = context => context.WrappedData.Sections }; } @@ -751,10 +753,7 @@ foreach (ICalculationBase item in nodeData.WrappedData.Children) { - var calculation = item as MacroStabilityInwardsCalculationScenario; - var group = item as CalculationGroup; - - if (calculation != null) + if (item is MacroStabilityInwardsCalculationScenario calculation) { childNodeObjects.Add(new MacroStabilityInwardsCalculationScenarioContext(calculation, nodeData.WrappedData, @@ -763,7 +762,7 @@ nodeData.FailureMechanism, nodeData.AssessmentSection)); } - else if (group != null) + else if (item is CalculationGroup @group) { childNodeObjects.Add(new MacroStabilityInwardsCalculationGroupContext(group, nodeData.WrappedData, Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/CalculationsState/MacroStabilityInwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/CalculationsState/MacroStabilityInwardsFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/CalculationsState/MacroStabilityInwardsFailureMechanismPropertiesTest.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,104 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.ComponentModel; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Riskeer.MacroStabilityInwards.Data; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState; + +namespace Riskeer.MacroStabilityInwards.Forms.Test.PropertyClasses.CalculationsState +{ + [TestFixture] + public class MacroStabilityInwardsFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int waterVolumetricWeightPropertyIndex = 2; + private const int modelFactorPropertyIndex = 3; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + // Call + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + + GeneralMacroStabilityInwardsInput generalInput = failureMechanism.GeneralInput; + + Assert.AreEqual(generalInput.WaterVolumetricWeight, properties.WaterVolumetricWeight); + Assert.AreEqual(generalInput.ModelFactor, properties.ModelFactor); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + // Call + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(4, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + const string modelFactorCategory = "Modelinstellingen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor volumicWeightOfWaterProperty = dynamicProperties[waterVolumetricWeightPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(volumicWeightOfWaterProperty, + generalCategory, + "Volumiek gewicht van water [kN/m³]", + "Volumiek gewicht van water.", + true); + + PropertyDescriptor modelFactorProperty = dynamicProperties[modelFactorPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorProperty, + modelFactorCategory, + "Modelfactor [-]", + "Modelfactor die wordt gebruikt bij de berekening van de benaderde faalkans op basis van de berekende stabiliteitsfactor.", + true); + } + } +} \ No newline at end of file Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsCalculationsPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesBaseTest.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesBaseTest.cs (revision 0) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesBaseTest.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,119 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.ComponentModel; +using Core.Gui.PropertyBag; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Riskeer.MacroStabilityInwards.Data; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses; + +namespace Riskeer.MacroStabilityInwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class MacroStabilityInwardsFailureMechanismPropertiesBaseTest + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 0; + + [Test] + public void Constructor_DataNull_ThrowArgumentNullException() + { + // Call + void Call() => new TestMacroStabilityInwardsFailureMechanismProperties( + null, new MacroStabilityInwardsFailureMechanismPropertiesBase.ConstructionProperties()); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("data", exception.ParamName); + } + + [Test] + public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() + { + // Call + void Call() => new TestMacroStabilityInwardsFailureMechanismProperties( + new MacroStabilityInwardsFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("constructionProperties", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + // Call + var properties = new TestMacroStabilityInwardsFailureMechanismProperties( + failureMechanism, new MacroStabilityInwardsFailureMechanismPropertiesBase.ConstructionProperties()); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + // Call + var properties = new TestMacroStabilityInwardsFailureMechanismProperties( + failureMechanism, new MacroStabilityInwardsFailureMechanismPropertiesBase.ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(2, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + } + + private class TestMacroStabilityInwardsFailureMechanismProperties : MacroStabilityInwardsFailureMechanismPropertiesBase + { + public TestMacroStabilityInwardsFailureMechanismProperties(MacroStabilityInwardsFailureMechanism data, ConstructionProperties constructionProperties) + : base(data, constructionProperties) {} + } + } +} \ No newline at end of file Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailurePathPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/RegistrationState/MacroStabilityInwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/RegistrationState/MacroStabilityInwardsFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Forms.Test/PropertyClasses/RegistrationState/MacroStabilityInwardsFailureMechanismPropertiesTest.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,318 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.TestUtil; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Probability; +using Riskeer.Common.Data.TestUtil; +using Riskeer.MacroStabilityInwards.Data; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.MacroStabilityInwards.Forms.Test.PropertyClasses.RegistrationState +{ + public class MacroStabilityInwardsFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int inAssemblyPropertyIndex = 2; + private const int aPropertyIndex = 3; + private const int bPropertyIndex = 4; + private const int sectionLengthPropertyIndex = 5; + private const int nPropertyIndex = 6; + private const int applyLengthEffectInSectionPropertyIndex = 7; + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => new MacroStabilityInwardsFailureMechanismProperties(new MacroStabilityInwardsFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); + mocks.ReplayAll(); + + var random = new Random(21); + var failureMechanism = new MacroStabilityInwardsFailureMechanism + { + InAssembly = random.NextBoolean() + }; + + // Call + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); + + MacroStabilityInwardsProbabilityAssessmentInput probabilityAssessmentInput = failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput; + Assert.AreEqual(probabilityAssessmentInput.A, properties.A); + Assert.AreEqual(probabilityAssessmentInput.B, properties.B); + Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); + Assert.AreEqual(probabilityAssessmentInput.GetN(assessmentSection.ReferenceLine.Length), + properties.N, + properties.N.GetAccuracy()); + Assert.AreEqual(2, properties.SectionLength.NumberOfDecimalPlaces); + Assert.AreEqual(assessmentSection.ReferenceLine.Length, + properties.SectionLength, + properties.SectionLength.GetAccuracy()); + Assert.AreEqual(failureMechanism.GeneralInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); + + mocks.VerifyAll(); + } + + [Test] + public void Constructor_InAssemblyTrue_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism + { + InAssembly = true + }; + + // Call + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism, assessmentSection); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(8, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + const string lengthEffectCategory = "Lengte-effect"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor inAssemblyProperty = dynamicProperties[inAssemblyPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(inAssemblyProperty, + generalCategory, + "In assemblage", + "Geeft aan of dit faalmechanisme wordt meegenomen in de assemblage.", + true); + + PropertyDescriptor aProperty = dynamicProperties[aPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(aProperty, + lengthEffectCategory, + "a [-]", + "De parameter 'a' die gebruikt wordt voor het lengte-effect in berekening van de maximaal toelaatbare faalkans."); + + PropertyDescriptor bProperty = dynamicProperties[bPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bProperty, + lengthEffectCategory, + "b [m]", + "De parameter 'b' die gebruikt wordt voor het lengte-effect in berekening van de maximaal toelaatbare faalkans.", + true); + + PropertyDescriptor sectionLengthProperty = dynamicProperties[sectionLengthPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionLengthProperty, + lengthEffectCategory, + "Lengte* [m]", + "Totale lengte van het traject in meters (afgerond).", + true); + + PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, + lengthEffectCategory, + "N* [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling (afgerond).", + true); + + PropertyDescriptor applySectionLengthInSectionProperty = dynamicProperties[applyLengthEffectInSectionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(applySectionLengthInSectionProperty, + lengthEffectCategory, + "Toepassen lengte-effect binnen vak", + "Geeft aan of het lengte-effect binnen een vak toegepast wordt.", + true); + + mocks.VerifyAll(); + } + + [Test] + public void Constructor_InAssemblyFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism + { + InAssembly = false + }; + + // Call + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism, assessmentSection); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor inAssemblyProperty = dynamicProperties[inAssemblyPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(inAssemblyProperty, + generalCategory, + "In assemblage", + "Geeft aan of dit faalmechanisme wordt meegenomen in de assemblage.", + true); + + mocks.VerifyAll(); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(-1)] + [TestCase(-0.1)] + [TestCase(1.1)] + [TestCase(8)] + public void A_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double value) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism, assessmentSection); + + // Call + void Call() => properties.A = value; + + // Assert + const string expectedMessage = "De waarde voor 'a' moet in het bereik [0,0, 1,0] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(0)] + [TestCase(0.1)] + [TestCase(1)] + [TestCase(0.0000001)] + [TestCase(0.9999999)] + public void A_SetValidValue_SetsValueAndUpdatesObservers(double value) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism, assessmentSection); + + // Call + properties.A = value; + + // Assert + Assert.AreEqual(value, failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.A); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var pipingFailureMechanism = new MacroStabilityInwardsFailureMechanism + { + InAssembly = inAssembly + }; + + var properties = new MacroStabilityInwardsFailureMechanismProperties(pipingFailureMechanism, assessmentSection); + + // Assert + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.InAssembly))); + + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.A))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.B))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.SectionLength))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.N))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/MacroStabilityInwardsPluginTest.cs =================================================================== diff -u -r21c3c3cc07b1a3932e322ec6cec98bf4c81c0641 -r28c89f52a156d628eb86a1807d03e6b49de5ba89 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/MacroStabilityInwardsPluginTest.cs (.../MacroStabilityInwardsPluginTest.cs) (revision 21c3c3cc07b1a3932e322ec6cec98bf4c81c0641) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/MacroStabilityInwardsPluginTest.cs (.../MacroStabilityInwardsPluginTest.cs) (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -41,6 +41,8 @@ using Riskeer.MacroStabilityInwards.Forms.PropertyClasses; using Riskeer.MacroStabilityInwards.Forms.Views; using Riskeer.MacroStabilityInwards.Primitives; +using CalculationsStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState.MacroStabilityInwardsFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState.MacroStabilityInwardsFailureMechanismProperties; namespace Riskeer.MacroStabilityInwards.Plugin.Test { @@ -73,12 +75,12 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(MacroStabilityInwardsCalculationsContext), - typeof(MacroStabilityInwardsCalculationsProperties)); + typeof(CalculationsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(MacroStabilityInwardsFailurePathContext), - typeof(MacroStabilityInwardsFailurePathProperties)); + typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/CalculationsState/MacroStabilityInwardsFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/CalculationsState/MacroStabilityInwardsFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/CalculationsState/MacroStabilityInwardsFailureMechanismPropertyInfoTest.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.MacroStabilityInwards.Data; +using Riskeer.MacroStabilityInwards.Forms.PresentationObjects; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses.CalculationsState; + +namespace Riskeer.MacroStabilityInwards.Plugin.Test.PropertyInfos.CalculationsState +{ + [TestFixture] + public class MacroStabilityInwardsFailureMechanismPropertyInfoTest + { + private MacroStabilityInwardsPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new MacroStabilityInwardsPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(MacroStabilityInwardsFailureMechanismProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(MacroStabilityInwardsCalculationsContext), info.DataType); + Assert.AreEqual(typeof(MacroStabilityInwardsFailureMechanismProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var context = new MacroStabilityInwardsCalculationsContext(failureMechanism, assessmentSection); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/MacroStabilityInwardsCalculationsPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 28c89f52a156d628eb86a1807d03e6b49de5ba89 refers to a dead (removed) revision in file `Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/MacroStabilityInwardsFailurePathPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/RegistrationState/MacroStabilityInwardsFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/RegistrationState/MacroStabilityInwardsFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Plugin.Test/PropertyInfos/RegistrationState/MacroStabilityInwardsFailureMechanismPropertyInfoTest.cs (revision 28c89f52a156d628eb86a1807d03e6b49de5ba89) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.MacroStabilityInwards.Data; +using Riskeer.MacroStabilityInwards.Forms.PresentationObjects; +using Riskeer.MacroStabilityInwards.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.MacroStabilityInwards.Plugin.Test.PropertyInfos.RegistrationState +{ + [TestFixture] + public class MacroStabilityInwardsFailureMechanismPropertyInfoTest + { + private MacroStabilityInwardsPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new MacroStabilityInwardsPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(MacroStabilityInwardsFailureMechanismProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(MacroStabilityInwardsFailurePathContext), info.DataType); + Assert.AreEqual(typeof(MacroStabilityInwardsFailureMechanismProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var context = new MacroStabilityInwardsFailurePathContext(failureMechanism, assessmentSection); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + mocks.VerifyAll(); + } + } +} \ No newline at end of file