Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/CalculationsState/HeightStructuresFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/CalculationsState/HeightStructuresFailureMechanismProperties.cs (revision 0) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/CalculationsState/HeightStructuresFailureMechanismProperties.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -0,0 +1,102 @@ +// 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.Data; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Riskeer.Common.Forms.PropertyClasses; +using Riskeer.HeightStructures.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState +{ + /// + /// Calculations state related ViewModel of for properties panel. + /// + public class HeightStructuresFailureMechanismProperties : HeightStructuresFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int gravitationalAccelerationPropertyIndex = 3; + private const int modelFactorOvertoppingFlowPropertyIndex = 4; + private const int modelFactorStorageVolumePropertyIndex = 5; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public HeightStructuresFailureMechanismProperties(HeightStructuresFailureMechanism data) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) {} + + #region General + + [PropertyOrder(gravitationalAccelerationPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.GravitationalAcceleration_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.GravitationalAcceleration_Description))] + public RoundedDouble GravitationalAcceleration + { + get + { + return data.GeneralInput.GravitationalAcceleration; + } + } + + #endregion + + #region Model settings + + [PropertyOrder(modelFactorOvertoppingFlowPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.StructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.StructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_Description))] + public LogNormalDistributionProperties ModelFactorOvertoppingFlow + { + get + { + return new LogNormalDistributionProperties(data.GeneralInput.ModelFactorOvertoppingFlow); + } + } + + [PropertyOrder(modelFactorStorageVolumePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.StructuresInputFailureMechanismContext_ModelFactorStorageVolume_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.StructuresInputFailureMechanismContext_ModelFactorStorageVolume_Description))] + public LogNormalDistributionProperties ModelFactorStorageVolume + { + get + { + return new LogNormalDistributionProperties(data.GeneralInput.ModelFactorStorageVolume); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/HeightStructuresCalculationsProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismPropertiesBase.cs =================================================================== diff -u --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismPropertiesBase.cs (revision 0) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismPropertiesBase.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -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.HeightStructures.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.HeightStructures.Forms.PropertyClasses +{ + /// + /// Base ViewModel of for properties panel. + /// + public abstract class HeightStructuresFailureMechanismPropertiesBase : 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 HeightStructuresFailureMechanismPropertiesBase(HeightStructuresFailureMechanism 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 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/HeightStructuresFailurePathProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/RegistrationState/HeightStructuresFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/RegistrationState/HeightStructuresFailureMechanismProperties.cs (revision 0) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PropertyClasses/RegistrationState/HeightStructuresFailureMechanismProperties.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -0,0 +1,117 @@ +// 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.HeightStructures.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState +{ + /// + /// Registration state related ViewModel of for properties panel. + /// + public class HeightStructuresFailureMechanismProperties : HeightStructuresFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int inAssemblyPropertyIndex = 3; + private const int nPropertyIndex = 4; + private const int applyLengthEffectInSectionPropertyIndex = 5; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public HeightStructuresFailureMechanismProperties(HeightStructuresFailureMechanism data) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) {} + + #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(N).Equals(propertyName) + || nameof(ApplyLengthEffectInSection).Equals(propertyName); + } + + #region Length effect parameters + + [DynamicVisible] + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))] + public RoundedDouble N + { + get + { + return data.GeneralInput.N; + } + set + { + data.GeneralInput.N = value; + data.NotifyObservers(); + } + } + + [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/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r160e88782fbd20958a9ebd55511782b203d141e5 -r14174f04f6c78b47f5663373e3b6f9e68847646b --- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 160e88782fbd20958a9ebd55511782b203d141e5) +++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -61,6 +61,8 @@ using Riskeer.HeightStructures.IO.Configurations; using Riskeer.HeightStructures.Plugin.FileImporters; using Riskeer.HeightStructures.Service; +using CalculationsStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState.HeightStructuresFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState.HeightStructuresFailureMechanismProperties; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; using RiskeerCommonIOResources = Riskeer.Common.IO.Properties.Resources; @@ -74,13 +76,13 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new HeightStructuresCalculationsProperties(context.WrappedData) + CreateInstance = context => new CalculationsStateFailureMechanismProperties(context.WrappedData) }; - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new HeightStructuresFailurePathProperties(context.WrappedData) + CreateInstance = context => new RegistrationStateFailureMechanismProperties(context.WrappedData) }; yield return new PropertyInfo(); yield return new PropertyInfo> Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/CalculationsState/HeightStructuresFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/CalculationsState/HeightStructuresFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/CalculationsState/HeightStructuresFailureMechanismPropertiesTest.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -0,0 +1,116 @@ +// 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.PropertyBag; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Riskeer.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState; + +namespace Riskeer.HeightStructures.Forms.Test.PropertyClasses.CalculationsState +{ + [TestFixture] + public class HeightStructuresFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int gravitationalAccelerationPropertyIndex = 2; + private const int modelFactorOvertoppingFlowPropertyIndex = 3; + private const int modelFactorStorageVolumePropertyIndex = 4; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + // Call + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(failureMechanism, properties.Data); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + + GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; + Assert.AreEqual(generalInput.GravitationalAcceleration, properties.GravitationalAcceleration); + + Assert.AreEqual(generalInput.ModelFactorOvertoppingFlow.Mean, properties.ModelFactorOvertoppingFlow.Mean); + Assert.AreEqual(generalInput.ModelFactorOvertoppingFlow.StandardDeviation, properties.ModelFactorOvertoppingFlow.StandardDeviation); + + Assert.AreEqual(generalInput.ModelFactorStorageVolume.Mean, properties.ModelFactorStorageVolume.Mean); + Assert.AreEqual(generalInput.ModelFactorStorageVolume.StandardDeviation, properties.ModelFactorStorageVolume.StandardDeviation); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Call + var properties = new HeightStructuresFailureMechanismProperties(new HeightStructuresFailureMechanism()); + + // Assert + const string generalCategory = "Algemeen"; + const string modelSettingsCategory = "Modelinstellingen"; + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(5, dynamicProperties.Count); + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor gravitationalAccelerationProperty = dynamicProperties[gravitationalAccelerationPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(gravitationalAccelerationProperty, + generalCategory, + "Valversnelling [m/s²]", + "Valversnelling.", + true); + + PropertyDescriptor modelFactorOvertoppingFlowProperty = dynamicProperties[modelFactorOvertoppingFlowPropertyIndex]; + Assert.IsInstanceOf(modelFactorOvertoppingFlowProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorOvertoppingFlowProperty, + modelSettingsCategory, + "Modelfactor overslagdebiet [-]", + "Modelfactor voor het overslagdebiet.", + true); + + PropertyDescriptor modelFactorStorageVolumeProperty = dynamicProperties[modelFactorStorageVolumePropertyIndex]; + Assert.IsInstanceOf(modelFactorStorageVolumeProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorStorageVolumeProperty, + modelSettingsCategory, + "Modelfactor kombergend vermogen [-]", + "Modelfactor kombergend vermogen.", + true); + } + } +} \ No newline at end of file Fisheye: Tag 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresCalculationsPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismPropertiesTest.cs =================================================================== diff -u -raacb3e7cd3ede4162dd10c02a348dbb667b337dc -r14174f04f6c78b47f5663373e3b6f9e68847646b --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismPropertiesTest.cs (.../HeightStructuresFailureMechanismPropertiesTest.cs) (revision aacb3e7cd3ede4162dd10c02a348dbb667b337dc) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismPropertiesTest.cs (.../HeightStructuresFailureMechanismPropertiesTest.cs) (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -38,7 +38,8 @@ public void Constructor_DataNull_ThrowArgumentNullException() { // Call - void Call() => new HeightStructuresFailureMechanismProperties(null, new HeightStructuresFailureMechanismProperties.ConstructionProperties()); + void Call() => new TestHeightStructuresFailureMechanismProperties( + null, new HeightStructuresFailureMechanismPropertiesBase.ConstructionProperties()); // Assert var exception = Assert.Throws(Call); @@ -49,7 +50,8 @@ public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() { // Call - void Call() => new HeightStructuresFailureMechanismProperties(new HeightStructuresFailureMechanism(), null); + void Call() => new TestHeightStructuresFailureMechanismProperties( + new HeightStructuresFailureMechanism(), null); // Assert var exception = Assert.Throws(Call); @@ -63,7 +65,8 @@ var failureMechanism = new HeightStructuresFailureMechanism(); // Call - var properties = new HeightStructuresFailureMechanismProperties(failureMechanism, new HeightStructuresFailureMechanismProperties.ConstructionProperties()); + var properties = new TestHeightStructuresFailureMechanismProperties( + failureMechanism, new HeightStructuresFailureMechanismPropertiesBase.ConstructionProperties()); // Assert Assert.IsInstanceOf>(properties); @@ -78,11 +81,12 @@ var failureMechanism = new HeightStructuresFailureMechanism(); // Call - var properties = new HeightStructuresFailureMechanismProperties(failureMechanism, new HeightStructuresFailureMechanismProperties.ConstructionProperties - { - NamePropertyIndex = namePropertyIndex, - CodePropertyIndex = codePropertyIndex - }); + var properties = new TestHeightStructuresFailureMechanismProperties( + failureMechanism, new HeightStructuresFailureMechanismPropertiesBase.ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -104,5 +108,12 @@ "Het label van het faalmechanisme.", true); } + + private class TestHeightStructuresFailureMechanismProperties : HeightStructuresFailureMechanismPropertiesBase + { + public TestHeightStructuresFailureMechanismProperties(HeightStructuresFailureMechanism data, + ConstructionProperties constructionProperties) + : base(data, constructionProperties) {} + } } } \ No newline at end of file Fisheye: Tag 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailurePathPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/RegistrationState/HeightStructuresFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/RegistrationState/HeightStructuresFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PropertyClasses/RegistrationState/HeightStructuresFailureMechanismPropertiesTest.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -0,0 +1,239 @@ +// 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.Base.Data; +using Core.Common.TestUtil; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.TestUtil; +using Riskeer.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PropertyClasses; +using Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.HeightStructures.Forms.Test.PropertyClasses.RegistrationState +{ + public class HeightStructuresFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int inAssemblyPropertyIndex = 2; + private const int nPropertyIndex = 3; + private const int applyLengthEffectInSectionPropertyIndex = 4; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var random = new Random(21); + var failureMechanism = new HeightStructuresFailureMechanism + { + InAssembly = random.NextBoolean() + }; + + // Call + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); + + GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput; + Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); + Assert.AreEqual(generalInput.N, + properties.N, + properties.N.GetAccuracy()); + Assert.AreEqual(generalInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); + } + + [Test] + public void Constructor_InAssemblyTrue_PropertiesHaveExpectedAttributesValues() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + // Call + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(5, 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 nProperty = dynamicProperties[nPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, + lengthEffectCategory, + "N [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); + + 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); + } + + [Test] + public void Constructor_InAssemblyFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism + { + InAssembly = false + }; + + // Call + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // 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); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-20.0)] + public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // Call + void Call() => properties.N = (RoundedDouble) newN; + + // Assert + const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(20.0)] + public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // Call + properties.N = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism + { + InAssembly = inAssembly + }; + var properties = new HeightStructuresFailureMechanismProperties(failureMechanism); + + // Call & 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.N))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + } + } +} \ No newline at end of file Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r8ba64004e28058fce306a424a0cfe9d6b17c814e -r14174f04f6c78b47f5663373e3b6f9e68847646b --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 8ba64004e28058fce306a424a0cfe9d6b17c814e) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -38,6 +38,8 @@ using Riskeer.HeightStructures.Forms.PresentationObjects; using Riskeer.HeightStructures.Forms.PropertyClasses; using Riskeer.HeightStructures.Forms.Views; +using CalculationsStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState.HeightStructuresFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState.HeightStructuresFailureMechanismProperties; namespace Riskeer.HeightStructures.Plugin.Test { @@ -70,12 +72,12 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(HeightStructuresCalculationsContext), - typeof(HeightStructuresCalculationsProperties)); + typeof(CalculationsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(HeightStructuresFailurePathContext), - typeof(HeightStructuresFailurePathProperties)); + typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/CalculationsState/HeightStructuresFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/CalculationsState/HeightStructuresFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/CalculationsState/HeightStructuresFailureMechanismPropertyInfoTest.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -0,0 +1,82 @@ +// 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.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PropertyClasses.CalculationsState; + +namespace Riskeer.HeightStructures.Plugin.Test.PropertyInfos.CalculationsState +{ + [TestFixture] + public class HeightStructuresFailureMechanismPropertyInfoTest + { + private HeightStructuresPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new HeightStructuresPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(HeightStructuresFailureMechanismProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HeightStructuresCalculationsContext), info.DataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresCalculationsContext(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 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/HeightStructuresCalculationsPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 14174f04f6c78b47f5663373e3b6f9e68847646b refers to a dead (removed) revision in file `Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/HeightStructuresFailurePathPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/RegistrationState/HeightStructuresFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/RegistrationState/HeightStructuresFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/PropertyInfos/RegistrationState/HeightStructuresFailureMechanismPropertyInfoTest.cs (revision 14174f04f6c78b47f5663373e3b6f9e68847646b) @@ -0,0 +1,82 @@ +// 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.HeightStructures.Data; +using Riskeer.HeightStructures.Forms.PresentationObjects; +using Riskeer.HeightStructures.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.HeightStructures.Plugin.Test.PropertyInfos.RegistrationState +{ + [TestFixture] + public class HeightStructuresFailureMechanismPropertyInfoTest + { + private HeightStructuresPlugin plugin; + private PropertyInfo info; + + [SetUp] + public void SetUp() + { + plugin = new HeightStructuresPlugin(); + info = plugin.GetPropertyInfos().First(tni => tni.PropertyObjectType == typeof(HeightStructuresFailureMechanismProperties)); + } + + [TearDown] + public void TearDown() + { + plugin.Dispose(); + } + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Assert + Assert.AreEqual(typeof(HeightStructuresFailurePathContext), info.DataType); + Assert.AreEqual(typeof(HeightStructuresFailureMechanismProperties), info.PropertyObjectType); + } + + [Test] + public void CreateInstance_WithContext_NewPropertiesWithFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + var context = new HeightStructuresFailurePathContext(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