Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/DikeProfileProperties.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/DikeProfileProperties.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/DikeProfileProperties.cs (revision c6d76d895c5b2f5ae99d3cc29775831f1c7a8593) @@ -0,0 +1,111 @@ +// 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 Core.Common.Base.Data; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class DikeProfileProperties : ObjectProperties + { + private const int orientationPropertyIndex = 1; + private const int breakWaterPropertyIndex = 2; + private const int foreshorePropertyIndex = 3; + private const int dikeGeometryPropertyIndex = 4; + private const int dikeHeightPropertyIndex = 5; + + [PropertyOrder(orientationPropertyIndex)] + [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] + [ResourcesDisplayName(typeof(Resources), "Orientation_DisplayName")] + [ResourcesDescription(typeof(Resources), "Orientation_Description")] + public RoundedDouble Orientation + { + get + { + return data.Orientation; + } + } + + [PropertyOrder(breakWaterPropertyIndex)] + [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] + [ResourcesDisplayName(typeof(Resources), "BreakWaterProperties_DisplayName")] + [ResourcesDescription(typeof(Resources), "BreakWaterProperties_Description")] + public DikeProfileBreakWaterProperties BreakWater + { + get + { + return new DikeProfileBreakWaterProperties + { + Data = data + }; + } + } + + [PropertyOrder(foreshorePropertyIndex)] + [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] + [ResourcesDisplayName(typeof(Resources), "ForeshoreProperties_DisplayName")] + [ResourcesDescription(typeof(Resources), "ForeshoreProperties_Description")] + public DikeProfileForeshoreProperties Foreshore + { + get + { + return new DikeProfileForeshoreProperties + { + Data = data + }; + } + } + + [PropertyOrder(dikeGeometryPropertyIndex)] + [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] + [ResourcesDisplayName(typeof(Resources), "DikeGeometryProperties_DisplayName")] + [ResourcesDescription(typeof(Resources), "DikeGeometryProperties_Description")] + public DikeProfileDikeGeometryProperties DikeGeometry + { + get + { + return new DikeProfileDikeGeometryProperties + { + Data = data + }; + } + } + + [PropertyOrder(dikeHeightPropertyIndex)] + [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] + [ResourcesDisplayName(typeof(Resources), "DikeHeight_DisplayName")] + [ResourcesDescription(typeof(Resources), "DikeHeight_Description")] + public RoundedDouble CrestLevel + { + get + { + return data.CrestLevel; + } + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj =================================================================== diff -u -r94f0e9153131295bf39021c7f0e3f948c64441f3 -rc6d76d895c5b2f5ae99d3cc29775831f1c7a8593 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 94f0e9153131295bf39021c7f0e3f948c64441f3) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision c6d76d895c5b2f5ae99d3cc29775831f1c7a8593) @@ -53,6 +53,7 @@ True Resources.resx + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/DikeProfilePropertiesTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/DikeProfilePropertiesTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/DikeProfilePropertiesTest.cs (revision c6d76d895c5b2f5ae99d3cc29775831f1c7a8593) @@ -0,0 +1,126 @@ +// 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.Geometry; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class DikeProfilePropertiesTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var properties = new DikeProfileProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void Data_SetNewDikeProfileInstance_ReturnCorrectPropertyValues() + { + // Setup + var dikeProfile = new DikeProfile(new Point2D(0, 0)); + + // Call + var properties = new DikeProfileProperties + { + Data = dikeProfile + }; + + // Assert + Assert.AreEqual(2, properties.Orientation.NumberOfDecimalPlaces); + Assert.AreEqual(0.0, properties.Orientation.Value); + Assert.AreSame(dikeProfile, properties.BreakWater.Data); + Assert.AreSame(dikeProfile, properties.Foreshore.Data); + Assert.AreSame(dikeProfile, properties.DikeGeometry.Data); + Assert.AreEqual(2, properties.CrestLevel.NumberOfDecimalPlaces); + Assert.AreEqual(0.0, properties.CrestLevel.Value); + } + + [Test] + public void PropertyAttributes_ReturnExpectedValues() + { + // Setup + var dikeProfile = new DikeProfile(new Point2D(0, 0)); + + // Call + var properties = new DikeProfileProperties + { + Data = dikeProfile + }; + + // Assert + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); + Assert.AreEqual(6, dynamicProperties.Count); + + PropertyDescriptor orientationProperty = dynamicProperties[orientationPropertyIndex]; + Assert.IsNotNull(orientationProperty); + Assert.IsTrue(orientationProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", orientationProperty.Category); + Assert.AreEqual("Oriëntatie [°]", orientationProperty.DisplayName); + Assert.AreEqual("Oriëntatie van de dijk.", orientationProperty.Description); + + PropertyDescriptor breakWaterProperty = dynamicProperties[breakWaterPropertyIndex]; + Assert.IsNotNull(breakWaterProperty); + Assert.IsTrue(breakWaterProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", breakWaterProperty.Category); + Assert.AreEqual("Dam", breakWaterProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de dam.", breakWaterProperty.Description); + + PropertyDescriptor foreshoreProperty = dynamicProperties[foreshorePropertyIndex]; + Assert.IsNotNull(foreshoreProperty); + Assert.IsTrue(foreshoreProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", foreshoreProperty.Category); + Assert.AreEqual("Voorlandgeometrie", foreshoreProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", foreshoreProperty.Description); + + PropertyDescriptor dikeGeometryProperty = dynamicProperties[dikeGeometryPropertyIndex]; + Assert.IsNotNull(dikeGeometryProperty); + Assert.IsTrue(dikeGeometryProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", dikeGeometryProperty.Category); + Assert.AreEqual("Dijkgeometrie", dikeGeometryProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de dijkgeometrie.", dikeGeometryProperty.Description); + + PropertyDescriptor dikeHeightProperty = dynamicProperties[dikeHeightPropertyIndex]; + Assert.IsNotNull(dikeHeightProperty); + Assert.IsTrue(dikeHeightProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", dikeHeightProperty.Category); + Assert.AreEqual("Dijkhoogte [m+NAP]", dikeHeightProperty.DisplayName); + Assert.AreEqual("De hoogte van de dijk [m+NAP].", dikeHeightProperty.Description); + } + + private const int orientationPropertyIndex = 0; + private const int breakWaterPropertyIndex = 1; + private const int foreshorePropertyIndex = 2; + private const int dikeGeometryPropertyIndex = 3; + private const int dikeHeightPropertyIndex = 4; + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs =================================================================== diff -u -re5cf2b83dc6e3e2626552bd0b402e7740c548565 -rc6d76d895c5b2f5ae99d3cc29775831f1c7a8593 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision e5cf2b83dc6e3e2626552bd0b402e7740c548565) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision c6d76d895c5b2f5ae99d3cc29775831f1c7a8593) @@ -65,41 +65,22 @@ mockRepository.ReplayAll(); var input = new GrassCoverErosionInwardsInput(); - - var properties = new GrassCoverErosionInwardsInputContextProperties(); - - // Call var inputContext = new GrassCoverErosionInwardsInputContext(input, calculationMock, failureMechanismMock, assessmentSectionMock); - properties.Data = inputContext; - // Assert - var dikeGeometryProperties = new GrassCoverErosionInwardsInputContextDikeGeometryProperties + // Call + var properties = new GrassCoverErosionInwardsInputContextProperties { Data = inputContext }; - Assert.AreEqual(dikeGeometryProperties.Coordinates, properties.DikeGeometry.Coordinates); - Assert.AreEqual(dikeGeometryProperties.Roughness, properties.DikeGeometry.Roughness); - Assert.AreEqual(2, properties.DikeHeight.NumberOfDecimalPlaces); - Assert.AreEqual(0.00, properties.DikeHeight.Value); - - var foreshoreProperties = new GrassCoverErosionInwardsInputContextForeshoreProperties - { - Data = inputContext - }; - Assert.AreEqual(foreshoreProperties.UseForeshore, properties.Foreshore.UseForeshore); - Assert.AreEqual(foreshoreProperties.Coordinates, properties.Foreshore.Coordinates); - + // Assert Assert.AreEqual(2, properties.Orientation.NumberOfDecimalPlaces); - Assert.AreEqual(0.00, properties.Orientation.Value); - - var breakWaterProperties = new GrassCoverErosionInwardsInputContextBreakWaterProperties - { - Data = inputContext - }; - Assert.AreEqual(breakWaterProperties.UseBreakWater, properties.BreakWater.UseBreakWater); - Assert.AreEqual(breakWaterProperties.BreakWaterHeight, properties.BreakWater.BreakWaterHeight); - Assert.AreEqual(breakWaterProperties.BreakWaterType, properties.BreakWater.BreakWaterType); + Assert.AreEqual(0.0, properties.Orientation.Value); + Assert.AreSame(inputContext, properties.BreakWater.Data); + Assert.AreSame(inputContext, properties.Foreshore.Data); + Assert.AreSame(inputContext, properties.DikeGeometry.Data); + Assert.AreEqual(2, properties.DikeHeight.NumberOfDecimalPlaces); + Assert.AreEqual(0.0, properties.DikeHeight.Value); Assert.AreEqual(input.CriticalFlowRate.Mean, properties.CriticalFlowRate.Mean); Assert.AreEqual(input.CriticalFlowRate.StandardDeviation, properties.CriticalFlowRate.StandardDeviation); Assert.AreEqual(input.HydraulicBoundaryLocation, properties.HydraulicBoundaryLocation); @@ -132,13 +113,13 @@ var newOrientation = new RoundedDouble(2, 5); // Call - properties.DikeHeight = newDikeHeight; properties.Orientation = newOrientation; + properties.DikeHeight = newDikeHeight; properties.HydraulicBoundaryLocation = hydraulicBoundaryLocation; // Assert - Assert.AreEqual(newDikeHeight, input.DikeHeight); Assert.AreEqual(newOrientation, input.Orientation); + Assert.AreEqual(newDikeHeight, input.DikeHeight); Assert.AreEqual(hydraulicBoundaryLocation, input.HydraulicBoundaryLocation); mockRepository.VerifyAll(); } @@ -164,27 +145,6 @@ PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); Assert.AreEqual(8, dynamicProperties.Count); - PropertyDescriptor dikeGeometryProperty = dynamicProperties[dikeGeometryPropertyIndex]; - Assert.IsNotNull(dikeGeometryProperty); - Assert.IsTrue(dikeGeometryProperty.IsReadOnly); - Assert.AreEqual("Schematisatie", dikeGeometryProperty.Category); - Assert.AreEqual("Dijkgeometrie", dikeGeometryProperty.DisplayName); - Assert.AreEqual("Eigenschappen van de dijkgeometrie.", dikeGeometryProperty.Description); - - PropertyDescriptor dikeHeightProperty = dynamicProperties[dikeHeightPropertyIndex]; - Assert.IsNotNull(dikeHeightProperty); - Assert.IsFalse(dikeHeightProperty.IsReadOnly); - Assert.AreEqual("Schematisatie", dikeHeightProperty.Category); - Assert.AreEqual("Dijkhoogte [m+NAP]", dikeHeightProperty.DisplayName); - Assert.AreEqual("De hoogte van de dijk [m+NAP].", dikeHeightProperty.Description); - - PropertyDescriptor foreshoreProperty = dynamicProperties[foreshorePropertyIndex]; - Assert.IsNotNull(foreshoreProperty); - Assert.IsTrue(foreshoreProperty.IsReadOnly); - Assert.AreEqual("Schematisatie", foreshoreProperty.Category); - Assert.AreEqual("Voorlandgeometrie", foreshoreProperty.DisplayName); - Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", foreshoreProperty.Description); - PropertyDescriptor orientationProperty = dynamicProperties[orientationPropertyIndex]; Assert.IsNotNull(orientationProperty); Assert.IsFalse(orientationProperty.IsReadOnly); @@ -199,6 +159,27 @@ Assert.AreEqual("Dam", breakWaterProperty.DisplayName); Assert.AreEqual("Eigenschappen van de dam.", breakWaterProperty.Description); + PropertyDescriptor foreshoreProperty = dynamicProperties[foreshorePropertyIndex]; + Assert.IsNotNull(foreshoreProperty); + Assert.IsTrue(foreshoreProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", foreshoreProperty.Category); + Assert.AreEqual("Voorlandgeometrie", foreshoreProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", foreshoreProperty.Description); + + PropertyDescriptor dikeGeometryProperty = dynamicProperties[dikeGeometryPropertyIndex]; + Assert.IsNotNull(dikeGeometryProperty); + Assert.IsTrue(dikeGeometryProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", dikeGeometryProperty.Category); + Assert.AreEqual("Dijkgeometrie", dikeGeometryProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de dijkgeometrie.", dikeGeometryProperty.Description); + + PropertyDescriptor dikeHeightProperty = dynamicProperties[dikeHeightPropertyIndex]; + Assert.IsNotNull(dikeHeightProperty); + Assert.IsFalse(dikeHeightProperty.IsReadOnly); + Assert.AreEqual("Schematisatie", dikeHeightProperty.Category); + Assert.AreEqual("Dijkhoogte [m+NAP]", dikeHeightProperty.DisplayName); + Assert.AreEqual("De hoogte van de dijk [m+NAP].", dikeHeightProperty.Description); + PropertyDescriptor criticalFlowRateProperty = dynamicProperties[criticalFlowRatePropertyIndex]; Assert.IsNotNull(criticalFlowRateProperty); Assert.IsTrue(criticalFlowRateProperty.IsReadOnly); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj =================================================================== diff -u -r94f0e9153131295bf39021c7f0e3f948c64441f3 -rc6d76d895c5b2f5ae99d3cc29775831f1c7a8593 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 94f0e9153131295bf39021c7f0e3f948c64441f3) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision c6d76d895c5b2f5ae99d3cc29775831f1c7a8593) @@ -64,6 +64,7 @@ True Resources.resx +