Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r790d12a1b8f6bb77d03a9fb4ef48892f71d7f778 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 790d12a1b8f6bb77d03a9fb4ef48892f71d7f778) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -22,7 +22,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -82,6 +82,42 @@ } /// + /// Looks up a localized string similar to De parameter 'C' die gebruikt wordt om het lengte-effect te berekenen.. + /// + public static string ClosingStructureFailureMechanismContextProperties_C_Description { + get { + return ResourceManager.GetString("ClosingStructureFailureMechanismContextProperties_C_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to C [-]. + /// + public static string ClosingStructureFailureMechanismContextProperties_C_DisplayName { + get { + return ResourceManager.GetString("ClosingStructureFailureMechanismContextProperties_C_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De parameter '2NA' die gebruikt wordt om het lengte-effect te berekenen.. + /// + public static string ClosingStructureFailureMechanismContextProperties_N2A_Description { + get { + return ResourceManager.GetString("ClosingStructureFailureMechanismContextProperties_N2A_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 2NA [-]. + /// + public static string ClosingStructureFailureMechanismContextProperties_N2A_DisplayName { + get { + return ResourceManager.GetString("ClosingStructureFailureMechanismContextProperties_N2A_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Instroommodel van het kunstwerk.. /// public static string ClosingStructureInflowModelType_Description { Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Properties/Resources.resx =================================================================== diff -u -r790d12a1b8f6bb77d03a9fb4ef48892f71d7f778 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision 790d12a1b8f6bb77d03a9fb4ef48892f71d7f778) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -153,4 +153,16 @@ Faalkans herstel van gefaalde situatie [1/jaar] + + De parameter 'C' die gebruikt wordt om het lengte-effect te berekenen. + + + C [-] + + + De parameter '2NA' die gebruikt wordt om het lengte-effect te berekenen. + + + 2NA [-] + \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructureFailureMechanismProperties.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructureFailureMechanismProperties.cs (revision 0) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructureFailureMechanismProperties.cs (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -0,0 +1,207 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.ComponentModel; +using Core.Common.Base.Data; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Forms.PresentationObjects; +using Ringtoets.ClosingStructures.Forms.Properties; +using Ringtoets.Common.Forms.PropertyClasses; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.ClosingStructures.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class ClosingStructureFailureMechanismProperties : ObjectProperties + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int gravitationalAccelerationPropertyIndex = 3; + + private const int cPropertyIndex = 4; + private const int n2aPropertyIndex = 5; + private const int lengthEffectPropertyIndex = 6; + + private const int modelFactorOvertoppingFlowPropertyIndex = 7; + private const int modelFactorStorageVolumePropertyIndex = 8; + private const int modelFactorSubCriticalFlowPropertyIndex = 9; + private const int modelFactorInflowVolumePropertyIndex = 10; + + #region Length effect parameters + + [PropertyOrder(cPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_LengthEffect")] + [ResourcesDisplayName(typeof(Resources), "ClosingStructureFailureMechanismContextProperties_C_DisplayName")] + [ResourcesDescription(typeof(Resources), "ClosingStructureFailureMechanismContextProperties_C_Description")] + public RoundedDouble C + { + get + { + return data.GeneralInput.C; + } + set + { + data.GeneralInput.C = value; + data.NotifyObservers(); + } + } + + [PropertyOrder(n2aPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_LengthEffect")] + [ResourcesDisplayName(typeof(Resources), "ClosingStructureFailureMechanismContextProperties_N2A_DisplayName")] + [ResourcesDescription(typeof(Resources), "ClosingStructureFailureMechanismContextProperties_N2A_Description")] + public int N2A + { + get + { + return data.GeneralInput.N2A; + } + set + { + data.GeneralInput.N2A = value; + data.NotifyObservers(); + } + } + + [PropertyOrder(lengthEffectPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_LengthEffect")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "FailureMechanism_N_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "FailureMechanism_N_Description")] + public RoundedDouble LengthEffect + { + get + { + return data.GeneralInput.N; + } + } + + #endregion + + #region General + + [PropertyOrder(namePropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Name_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Name_Description")] + public string Name + { + get + { + return data.Name; + } + } + + [PropertyOrder(codePropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Code_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Code_Description")] + public string Code + { + get + { + return data.Code; + } + } + + [PropertyOrder(gravitationalAccelerationPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "GravitationalAcceleration_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "GravitationalAcceleration_Description")] + public RoundedDouble GravitationalAcceleration + { + get + { + return data.GeneralInput.GravitationalAcceleration; + } + } + + #endregion + + #region Model settings + + [PropertyOrder(modelFactorOvertoppingFlowPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_Description")] + public LogNormalDistributionProperties ModelFactorOvertoppingFlow + { + get + { + return new LogNormalDistributionProperties + { + Data = data.GeneralInput.ModelFactorOvertoppingFlow + }; + } + } + + [PropertyOrder(modelFactorStorageVolumePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorStorageVolume_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorStorageVolume_Description")] + public LogNormalDistributionProperties ModelFactorStorageVolume + { + get + { + return new LogNormalDistributionProperties + { + Data = data.GeneralInput.ModelFactorStorageVolume + }; + } + } + + [PropertyOrder(modelFactorSubCriticalFlowPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorSubCriticalFlow_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorSubCriticalFlow_Description")] + public VariationCoefficientNormalDistributionProperties ModelFactorSubCriticalFlow + { + get + { + return new VariationCoefficientNormalDistributionProperties + { + Data = data.GeneralInput.ModelFactorSubCriticalFlow + }; + } + } + + [PropertyOrder(modelFactorInflowVolumePropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorInflowVolume_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorInflowVolume_Description")] + public RoundedDouble ModelFactorInflowVolume + { + get + { + return data.GeneralInput.ModelFactorInflowVolume; + } + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Ringtoets.ClosingStructures.Forms.csproj =================================================================== diff -u -r2b2da37541708b8ad95286e731010dd9d27d5070 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Ringtoets.ClosingStructures.Forms.csproj (.../Ringtoets.ClosingStructures.Forms.csproj) (revision 2b2da37541708b8ad95286e731010dd9d27d5070) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Ringtoets.ClosingStructures.Forms.csproj (.../Ringtoets.ClosingStructures.Forms.csproj) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -41,6 +41,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r2b2da37541708b8ad95286e731010dd9d27d5070 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 2b2da37541708b8ad95286e731010dd9d27d5070) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -54,6 +54,10 @@ public override IEnumerable GetPropertyInfos() { yield return new PropertyInfo(); + yield return new PropertyInfo + { + GetObjectPropertiesData = context => context.WrappedData + }; } public override IEnumerable GetViewInfos() Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructureFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructureFailureMechanismPropertiesTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructureFailureMechanismPropertiesTest.cs (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -0,0 +1,207 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.ClosingStructures.Data; +using Ringtoets.ClosingStructures.Forms.PropertyClasses; +using ClosingStructuresDataResources = Ringtoets.ClosingStructures.Data.Properties.Resources; + +namespace Ringtoets.ClosingStructures.Forms.Test.PropertyClasses +{ + [TestFixture] + public class ClosingStructureFailureMechanismPropertiesTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + + // Call + var properties = new ClosingStructureFailureMechanismProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void Data_SetNewFailureMechanismContext_ReturnCorrectPropertyValues() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + var properties = new ClosingStructureFailureMechanismProperties(); + + // Call + properties.Data = failureMechanism; + + // Assert + Assert.AreEqual(ClosingStructuresDataResources.ClosingStructuresFailureMechanism_DisplayName, + properties.Name); + Assert.AreEqual(ClosingStructuresDataResources.ClosingStructuresFailureMechanism_Code, + properties.Code); + + GeneralClosingStructuresInput generalInput = failureMechanism.GeneralInput; + Assert.AreEqual(generalInput.GravitationalAcceleration.Value, + properties.GravitationalAcceleration.Value); + + Assert.AreEqual(generalInput.C.Value, properties.C.Value); + Assert.AreEqual(generalInput.N2A, properties.N2A); + Assert.AreEqual(generalInput.N.Value, properties.LengthEffect.Value); + + 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); + Assert.AreEqual(generalInput.ModelFactorSubCriticalFlow.Mean, properties.ModelFactorSubCriticalFlow.Mean); + Assert.AreEqual(generalInput.ModelFactorSubCriticalFlow.CoefficientOfVariation, properties.ModelFactorSubCriticalFlow.CoefficientOfVariation); + Assert.AreEqual(generalInput.ModelFactorInflowVolume.Value, properties.ModelFactorInflowVolume.Value); + } + + [Test] + public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + const int numberProperties = 2; + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberProperties); + mockRepository.ReplayAll(); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + failureMechanism.Attach(observerMock); + var properties = new ClosingStructureFailureMechanismProperties + { + Data = failureMechanism + }; + + RoundedDouble newC = (RoundedDouble) 2.1; + const int newN2A = 10; + + // Call + properties.C = newC; + properties.N2A = newN2A; + + // Assert + Assert.AreEqual(newC, failureMechanism.GeneralInput.C); + Assert.AreEqual(newN2A, failureMechanism.GeneralInput.N2A); + mockRepository.VerifyAll(); + } + + [Test] + public void PropertyAttributes_ReturnExpectedValues() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + + // Call + var properties = new ClosingStructureFailureMechanismProperties + { + Data = failureMechanism + }; + + // Assert + var generalCategory = "Algemeen"; + var lengthEffectCategory = "Lengte-effect parameters"; + var modelSettingsCategory = "Modelinstellingen"; + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(10, dynamicProperties.Count); + + PropertyDescriptor nameProperty = dynamicProperties[0]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[1]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + generalCategory, + "Label", + "Het label van het toetsspoor.", + true); + + PropertyDescriptor gravitationalAccelerationProperty = dynamicProperties[2]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(gravitationalAccelerationProperty, + generalCategory, + "Valversnelling [m/s²]", + "Valversnelling.", + true); + + PropertyDescriptor cProperty = dynamicProperties[3]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(cProperty, + lengthEffectCategory, + "C [-]", + "De parameter 'C' die gebruikt wordt om het lengte-effect te berekenen."); + + PropertyDescriptor n2aProperty = dynamicProperties[4]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(n2aProperty, + lengthEffectCategory, + "2NA [-]", + "De parameter '2NA' die gebruikt wordt om het lengte-effect te berekenen."); + + PropertyDescriptor lengthEffectProperty = dynamicProperties[5]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthEffectProperty, + lengthEffectCategory, + "N [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in een semi-probabilistische beoordeling.", + true); + + PropertyDescriptor modelFactorOvertoppingFlowProperty = dynamicProperties[6]; + Assert.IsInstanceOf(modelFactorOvertoppingFlowProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorOvertoppingFlowProperty, + modelSettingsCategory, + "Modelfactor overslagdebiet [-]", + "Modelfactor voor het overslagdebiet.", + true); + + PropertyDescriptor modelFactorStorageVolumeProperty = dynamicProperties[7]; + Assert.IsInstanceOf(modelFactorStorageVolumeProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorStorageVolumeProperty, + modelSettingsCategory, + "Modelfactor kombergend vermogen [-]", + "Modelfactor kombergend vermogen.", + true); + + PropertyDescriptor modelFactorSubCriticalFlowProperty = dynamicProperties[8]; + Assert.IsInstanceOf(modelFactorSubCriticalFlowProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorSubCriticalFlowProperty, + modelSettingsCategory, + "Modelfactor voor onvolkomen stroming [-]", + "Modelfactor voor onvolkomen stroming.", + true); + + PropertyDescriptor modelFactorInflowVolumeProperty = dynamicProperties[9]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(modelFactorInflowVolumeProperty, + modelSettingsCategory, + "Modelfactor instromend volume [-]", + "Modelfactor instromend volume.", + true); + } + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj =================================================================== diff -u -rf9e4f420b403e6417f5dc2ba6d7beab9424baf89 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision f9e4f420b403e6417f5dc2ba6d7beab9424baf89) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -69,6 +69,7 @@ + Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs =================================================================== diff -u -r5efc7525e9ab2125a64b2e9b207b064c643f6514 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision 5efc7525e9ab2125a64b2e9b207b064c643f6514) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Plugin.Test/ClosingStructuresPluginTest.cs (.../ClosingStructuresPluginTest.cs) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -26,10 +26,12 @@ using Core.Common.Gui.TestUtil; using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Forms.PropertyClasses; using Ringtoets.ClosingStructures.Forms.Views; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PresentationObjects; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -53,21 +55,36 @@ public void GetPropertyInfos_ReturnsSupportedPropertyClassesWithExpectedValues() { // setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + using (var plugin = new ClosingStructuresPlugin()) { // call PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // assert - Assert.AreEqual(1, propertyInfos.Length); + Assert.AreEqual(2, propertyInfos.Length); PropertyInfo closingStructureProperties = PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(ClosingStructure), typeof(ClosingStructureProperties)); Assert.IsNull(closingStructureProperties.AdditionalDataCheck); Assert.IsNull(closingStructureProperties.GetObjectPropertiesData); Assert.IsNull(closingStructureProperties.AfterCreate); + + var failureMechanism = new ClosingStructuresFailureMechanism(); + var failureMechanismContext = new ClosingStructuresFailureMechanismContext(failureMechanism, assessmentSection); + PropertyInfo closingStructureFailureMechanismProperties = PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, + typeof(ClosingStructuresFailureMechanismContext), + typeof(ClosingStructureFailureMechanismProperties)); + Assert.AreSame(failureMechanism, closingStructureFailureMechanismProperties.GetObjectPropertiesData(failureMechanismContext)); + Assert.IsNull(closingStructureFailureMechanismProperties.AdditionalDataCheck); + Assert.IsNull(closingStructureFailureMechanismProperties.AfterCreate); } + mocks.VerifyAll(); } [Test] Fisheye: Tag 0764f95727a4586e2b566d1e66c989a6327f3e2b refers to a dead (removed) revision in file `Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismContextProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismProperties.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismProperties.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismProperties.cs (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -0,0 +1,143 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.ComponentModel; +using Core.Common.Base.Data; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HeightStructures.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class HeightStructuresFailureMechanismProperties : ObjectProperties + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int gravitationalAccelerationPropertyIndex = 3; + private const int lengthEffectPropertyIndex = 4; + private const int modelFactorOvertoppingFlowPropertyIndex = 5; + private const int modelFactorStorageVolumePropertyIndex = 6; + + #region Length effect parameters + + [PropertyOrder(lengthEffectPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_LengthEffect")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "FailureMechanism_N_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "FailureMechanism_N_Description")] + public int LengthEffect + { + get + { + return data.GeneralInput.N; + } + set + { + data.GeneralInput.N = value; + data.NotifyObservers(); + } + } + + #endregion + + #region General + + [PropertyOrder(namePropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Name_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Name_Description")] + public string Name + { + get + { + return data.Name; + } + } + + [PropertyOrder(codePropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Code_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "FailureMechanism_Code_Description")] + public string Code + { + get + { + return data.Code; + } + } + + [PropertyOrder(gravitationalAccelerationPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "GravitationalAcceleration_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "GravitationalAcceleration_Description")] + public RoundedDouble GravitationalAcceleration + { + get + { + return data.GeneralInput.GravitationalAcceleration; + } + } + + #endregion + + #region Model settings + + [PropertyOrder(modelFactorOvertoppingFlowPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_Description")] + public LogNormalDistributionProperties ModelFactorOvertoppingFlow + { + get + { + return new LogNormalDistributionProperties + { + Data = data.GeneralInput.ModelFactorOvertoppingFlow + }; + } + } + + [PropertyOrder(modelFactorStorageVolumePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_ModelSettings")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorStorageVolume_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "StructuresInputFailureMechanismContext_ModelFactorStorageVolume_Description")] + public LogNormalDistributionProperties ModelFactorStorageVolume + { + get + { + return new LogNormalDistributionProperties + { + Data = data.GeneralInput.ModelFactorStorageVolume + }; + } + } + + #endregion + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -r04e2ad28172dab2091ef18840dfc0ba77c6c0c7d -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 04e2ad28172dab2091ef18840dfc0ba77c6c0c7d) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -55,7 +55,7 @@ Resources.resx - + Form Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -rba2eefab3569d05ed59629b5d02dc8420bc1163a -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision ba2eefab3569d05ed59629b5d02dc8420bc1163a) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -61,7 +61,10 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo(); + yield return new PropertyInfo + { + GetObjectPropertiesData = context => context.WrappedData + }; yield return new PropertyInfo(); yield return new PropertyInfo(); } Fisheye: Tag 0764f95727a4586e2b566d1e66c989a6327f3e2b refers to a dead (removed) revision in file `Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismContextPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismPropertiesTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresFailureMechanismPropertiesTest.cs (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -0,0 +1,169 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Data.Properties; +using Ringtoets.HeightStructures.Forms.PropertyClasses; + +namespace Ringtoets.HeightStructures.Forms.Test.PropertyClasses +{ + [TestFixture] + public class HeightStructuresFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int gravitationalAccelerationPropertyIndex = 2; + private const int lengthEffectPropertyIndex = 3; + private const int modelFactorOvertoppingFlowPropertyIndex = 4; + private const int modelFactorStorageVolumePropertyIndex = 5; + + [Test] + public void Constructor_ExpectedValues() + { + // Call + var properties = new HeightStructuresFailureMechanismProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void Data_SetNewFailureMechanismContextInstance_ReturnCorrectPropertyValues() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + var properties = new HeightStructuresFailureMechanismProperties(); + + // Call + properties.Data = failureMechanism; + + // Assert + Assert.AreEqual(Resources.HeightStructuresFailureMechanism_DisplayName, properties.Name); + Assert.AreEqual(Resources.HeightStructuresFailureMechanism_Code, properties.Code); + Assert.AreEqual(2, properties.LengthEffect); + + 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 SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + const int numberProperties = 1; + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberProperties); + mockRepository.ReplayAll(); + + var failureMechanism = new HeightStructuresFailureMechanism(); + failureMechanism.Attach(observerMock); + var properties = new HeightStructuresFailureMechanismProperties + { + Data = failureMechanism + }; + const int newLengthEffect = 10; + + // Call + properties.LengthEffect = newLengthEffect; + + // Assert + Assert.AreEqual(newLengthEffect, failureMechanism.GeneralInput.N); + mockRepository.VerifyAll(); + } + + [Test] + public void PropertyAttributes_ReturnExpectedValues() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + + // Call + var properties = new HeightStructuresFailureMechanismProperties + { + Data = failureMechanism + }; + + // Assert + var generalCategory = "Algemeen"; + var lengthEffectCategory = "Lengte-effect parameters"; + var modelSettingsCategory = "Modelinstellingen"; + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(6, dynamicProperties.Count); + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + generalCategory, + "Label", + "Het label van het toetsspoor.", + true); + + PropertyDescriptor gravitationalAccelerationProperty = dynamicProperties[gravitationalAccelerationPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(gravitationalAccelerationProperty, + generalCategory, + "Valversnelling [m/s²]", + "Valversnelling.", + true); + + PropertyDescriptor lengthEffectProperty = dynamicProperties[lengthEffectPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthEffectProperty, + lengthEffectCategory, + "N [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in een semi-probabilistische beoordeling."); + + 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 Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r32fd9cdfad8d18f18c340b5e05cb6c550853bff9 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 32fd9cdfad8d18f18c340b5e05cb6c550853bff9) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -69,7 +69,7 @@ - + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs =================================================================== diff -u -r70ea116c3be1432b17de4b44e0c7b13902b8baf9 -r0764f95727a4586e2b566d1e66c989a6327f3e2b --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 70ea116c3be1432b17de4b44e0c7b13902b8baf9) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Plugin.Test/HeightStructuresPluginTest.cs (.../HeightStructuresPluginTest.cs) (revision 0764f95727a4586e2b566d1e66c989a6327f3e2b) @@ -27,6 +27,7 @@ using Core.Common.Gui.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.HeightStructures.Data; using Ringtoets.HeightStructures.Forms.PresentationObjects; @@ -53,20 +54,27 @@ public void GetPropertyInfos_ReturnsSupportedPropertyClassesWithExpectedValues() { // setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + using (var plugin = new HeightStructuresPlugin()) { // call PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // assert Assert.AreEqual(3, propertyInfos.Length); - PropertyInfo failureMechanismContextProperties = PluginTestHelper.AssertPropertyInfoDefined( + + var failureMechanism = new HeightStructuresFailureMechanism(); + var failureMechanismContext = new HeightStructuresFailureMechanismContext(failureMechanism, assessmentSection); + PropertyInfo failureMechanismProperties = PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(HeightStructuresFailureMechanismContext), - typeof(HeightStructuresFailureMechanismContextProperties)); - Assert.IsNull(failureMechanismContextProperties.AdditionalDataCheck); - Assert.IsNull(failureMechanismContextProperties.GetObjectPropertiesData); - Assert.IsNull(failureMechanismContextProperties.AfterCreate); + typeof(HeightStructuresFailureMechanismProperties)); + Assert.AreSame(failureMechanism, failureMechanismProperties.GetObjectPropertiesData(failureMechanismContext)); + Assert.IsNull(failureMechanismProperties.AdditionalDataCheck); + Assert.IsNull(failureMechanismProperties.AfterCreate); PropertyInfo heightStructuresInputContextProperties = PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, @@ -84,6 +92,7 @@ Assert.IsNull(heightStructureProperties.GetObjectPropertiesData); Assert.IsNull(heightStructureProperties.AfterCreate); } + mocks.VerifyAll(); } [Test]