Index: Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs =================================================================== diff -u -re2197d5a4596fc769d89bd2f661d657490017d76 -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs (.../StructureBase.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) +++ Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs (.../StructureBase.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -72,5 +72,10 @@ /// Gets the location of the structure. /// public Point2D Location { get; private set; } + + public override string ToString() + { + return Name; + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ForeshoreGeometryProperties.cs =================================================================== diff -u -rd2b9feaf8aceaa9a96d0e6e19fd6fbbee8987ca6 -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ForeshoreGeometryProperties.cs (.../ForeshoreGeometryProperties.cs) (revision d2b9feaf8aceaa9a96d0e6e19fd6fbbee8987ca6) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ForeshoreGeometryProperties.cs (.../ForeshoreGeometryProperties.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -19,8 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; @@ -42,13 +44,20 @@ { get { - return data.Geometry.ToArray(); + return GetFormattedCoordinates().ToArray(); } } public override string ToString() { return string.Empty; } + + private IEnumerable GetFormattedCoordinates() + { + return data.Geometry.Select(geometry => new Point2D( + new RoundedDouble(0, geometry.X), + new RoundedDouble(0, geometry.Y))); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs =================================================================== diff -u -re2197d5a4596fc769d89bd2f661d657490017d76 -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs (.../StructureBaseTest.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs (.../StructureBaseTest.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -80,6 +80,7 @@ Assert.AreEqual("anId", structure.Id); Assert.AreEqual(location.X, structure.Location.X); Assert.AreEqual(location.Y, structure.Location.Y); + Assert.AreEqual("aName", structure.ToString()); } private class TestStructure : StructureBase Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -0,0 +1,152 @@ +// 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; +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Forms.PropertyClasses; + +namespace Ringtoets.Common.Forms.Test.PropertyClasses +{ + [TestFixture] + public class UseBreakWaterPropertiesTest + { + [Test] + public void Constructor_IBreakWaterNullThrowsArgumentNullException() + { + // Setup & Call + TestDelegate test = () => new UseBreakWaterProperties(null, () => true); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("useBreakWaterData", paramName); + } + + [Test] + public void Constructor_UseBreakWaterEnabledNullThrowsArgumentNullException() + { + // Setup + var useBreakWaterData = new TestUseBreakWater(); + + // Call + TestDelegate test = () => new UseBreakWaterProperties(useBreakWaterData, null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("useBreakWaterEnabled", paramName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var useBreakWaterData = new TestUseBreakWater(); + + // Call + var properties = new UseBreakWaterProperties(useBreakWaterData, () => true); + + // Assert + Assert.IsFalse(properties.UseBreakWater); + Assert.AreEqual(BreakWaterType.Dam, properties.BreakWaterType); + Assert.AreEqual((RoundedDouble)double.NaN,properties.BreakWaterHeight); + Assert.AreEqual(string.Empty, properties.ToString()); + } + + [Test] + public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(3); + mockRepository.ReplayAll(); + + var breakWater = new BreakWater(BreakWaterType.Caisson, 2.2); + var testUseBreakWater = new TestUseBreakWater + { + BreakWater = breakWater + }; + var properties = new UseBreakWaterProperties(testUseBreakWater, ()=>true); + + testUseBreakWater.Attach(observerMock); + + // Call + properties.UseBreakWater = true; + properties.BreakWaterType = BreakWaterType.Dam; + properties.BreakWaterHeight=(RoundedDouble)1.1; + + // Assert + Assert.IsTrue(properties.UseBreakWater); + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(true, true)] + [TestCase(true, false)] + [TestCase(false, true)] + [TestCase(false, false)] + public void PropertyAttributes_UseBreakWater_ReturnExpectedValues(bool useBreakWater, bool useBreakWaterEnabled) + { + // Setup + var testUseBreakWater = new TestUseBreakWater { UseBreakWater = useBreakWater }; + + // Call + var properties = new UseBreakWaterProperties(testUseBreakWater, () => useBreakWaterEnabled); + + // Assert + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(3, dynamicProperties.Count); + + PropertyDescriptor useBreakWaterProperty = dynamicProperties[0]; + Assert.IsNotNull(useBreakWaterProperty); + Assert.AreEqual(!useBreakWaterEnabled, useBreakWaterProperty.IsReadOnly); + Assert.AreEqual("Gebruik", useBreakWaterProperty.DisplayName); + Assert.AreEqual("Moet de dam worden gebruikt tijdens de berekening?", useBreakWaterProperty.Description); + + PropertyDescriptor breakWaterTypeProperty = dynamicProperties[1]; + Assert.IsNotNull(breakWaterTypeProperty); + Assert.AreEqual(!useBreakWaterEnabled || !useBreakWater, breakWaterTypeProperty.IsReadOnly); + Assert.AreEqual("Type", breakWaterTypeProperty.DisplayName); + Assert.AreEqual("Het type van de dam.", breakWaterTypeProperty.Description); + + PropertyDescriptor breakWaterHeightProperty = dynamicProperties[2]; + Assert.IsNotNull(breakWaterHeightProperty); + Assert.AreEqual(!useBreakWaterEnabled || !useBreakWater, breakWaterHeightProperty.IsReadOnly); + Assert.AreEqual("Hoogte [m+NAP]", breakWaterHeightProperty.DisplayName); + Assert.AreEqual("De hoogte van de dam.", breakWaterHeightProperty.Description); + } + + private class TestUseBreakWater : Observable, IUseBreakWater + { + public bool UseBreakWater { get; set; } + public BreakWater BreakWater { get; set; } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseForeshorePropertiesTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseForeshorePropertiesTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseForeshorePropertiesTest.cs (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -0,0 +1,151 @@ +// 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; +using System.ComponentModel; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Forms.PropertyClasses; + +namespace Ringtoets.Common.Forms.Test.PropertyClasses +{ + [TestFixture] + public class UseForeshorePropertiesTest + { + [Test] + public void Constructor_IUseForeshoreNullThrowsArgumentNullException() + { + // Setup & Call + TestDelegate test = () => new UseForeshoreProperties(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("useForshoreData", paramName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var useForshoreData = new TestUseForeshore(); + + // Call + var properties = new UseForeshoreProperties(useForshoreData); + + // Assert + Assert.IsFalse(properties.UseForeshore); + Assert.IsEmpty(properties.Coordinates); + Assert.AreEqual(string.Empty, properties.ToString()); + } + + [Test] + public void GetProperties_ValidUseForeshore_ExpectedValues() + { + // Setup + var geometry = new[] + { + new Point2D(1, 1) + }; + var useForshoreData = new TestUseForeshore + { + ForeshoreGeometry = new RoundedPoint2DCollection(2, geometry), + UseForeshore = true + }; + + // Call + var properties = new UseForeshoreProperties(useForshoreData); + + // Assert + Assert.IsTrue(properties.UseForeshore); + Assert.AreEqual(geometry,properties.Coordinates); + } + + [Test] + public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + { + // Setup + var mockRepository = new MockRepository(); + var observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + mockRepository.ReplayAll(); + + var useForshoreData = new TestUseForeshore(); + var properties = new UseForeshoreProperties(useForshoreData); + + useForshoreData.Attach(observerMock); + + // Call + properties.UseForeshore = true; + + // Assert + Assert.IsTrue(properties.UseForeshore); + mockRepository.VerifyAll(); + } + + [TestCase(0, false)] + [TestCase(1, false)] + [TestCase(2, true)] + public void PropertyAttributes_VariousNumberOfElements_ReturnExpectedValues(int numberOfPoint2D, bool isEnabled) + { + // Setup + var useForshoreData = new TestUseForeshore + { + ForeshoreGeometry = new RoundedPoint2DCollection( + 0, Enumerable.Repeat(new Point2D(0, 0), numberOfPoint2D).ToArray()) + }; + + // Call + var properties = new UseForeshoreProperties(useForshoreData); + + // Assert + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(2, dynamicProperties.Count); + + PropertyDescriptor useForeshoreProperty = dynamicProperties[0]; + Assert.IsNotNull(useForeshoreProperty); + Assert.AreEqual(!isEnabled, useForeshoreProperty.IsReadOnly); + Assert.AreEqual("Gebruik", useForeshoreProperty.DisplayName); + Assert.AreEqual("Moet de voorlandgeometrie worden gebruikt tijdens de berekening?", useForeshoreProperty.Description); + + PropertyDescriptor coordinatesProperty = dynamicProperties[1]; + Assert.IsNotNull(coordinatesProperty); + Assert.IsTrue(coordinatesProperty.IsReadOnly); + Assert.AreEqual("Coördinaten [m]", coordinatesProperty.DisplayName); + Assert.AreEqual("Lijst met punten in lokale coördinaten.", coordinatesProperty.Description); + } + + private class TestUseForeshore : Observable, IUseForeshore + { + public bool UseForeshore { get; set; } + public RoundedPoint2DCollection ForeshoreGeometry { get; set; } + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -rd7e204007a0a9e73fdfec7e570a397d4c41a463b -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision d7e204007a0a9e73fdfec7e570a397d4c41a463b) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -79,6 +79,8 @@ + + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/UITypeEditors/GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditorTest.cs =================================================================== diff -u -rd1cbcc57f088a905c4f8573cf334d77936ecd7ef -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/UITypeEditors/GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditorTest.cs (.../GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditorTest.cs) (revision d1cbcc57f088a905c4f8573cf334d77936ecd7ef) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/UITypeEditors/GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditorTest.cs (.../GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditorTest.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -56,10 +56,8 @@ var grassCoverErosionInwardsInput = new GrassCoverErosionInwardsInput(); var grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); - var assessmentSectionMock = mockRepository.StrictMock(); - assessmentSectionMock.Expect(asm => asm.HydraulicBoundaryDatabase) - .Return(hydraulicBoundaryDatabase) - .Repeat.AtLeastOnce(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var inputContext = new GrassCoverErosionInwardsInputContext(grassCoverErosionInwardsInput, grassCoverErosionInwardsCalculation, failureMechanism, @@ -72,12 +70,11 @@ var editor = new GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditor(); var propertyBag = new DynamicPropertyBag(properties); - var serviceProviderMock = mockRepository.StrictMock(); - var serviceMock = mockRepository.StrictMock(); - var descriptorContextMock = mockRepository.StrictMock(); - serviceProviderMock.Expect(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); - serviceMock.Expect(s => s.DropDownControl(null)).IgnoreArguments(); - descriptorContextMock.Expect(c => c.Instance).Return(propertyBag).Repeat.Twice(); + var serviceProviderMock = mockRepository.Stub(); + var serviceMock = mockRepository.Stub(); + var descriptorContextMock = mockRepository.Stub(); + serviceProviderMock.Stub(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); + descriptorContextMock.Stub(c => c.Instance).Return(propertyBag); mockRepository.ReplayAll(); var someValue = new object(); @@ -106,10 +103,8 @@ }; var grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); - var assessmentSectionMock = mockRepository.StrictMock(); - assessmentSectionMock.Expect(asm => asm.HydraulicBoundaryDatabase) - .Return(hydraulicBoundaryDatabase) - .Repeat.AtLeastOnce(); + var assessmentSectionMock = mockRepository.Stub(); + assessmentSectionMock.HydraulicBoundaryDatabase = hydraulicBoundaryDatabase; var inputContext = new GrassCoverErosionInwardsInputContext(grassCoverErosionInwardsInput, grassCoverErosionInwardsCalculation, failureMechanism, @@ -122,13 +117,11 @@ var editor = new GrassCoverErosionInwardsInputContextHydraulicBoundaryLocationEditor(); var propertyBag = new DynamicPropertyBag(properties); - var serviceProviderMock = mockRepository.StrictMock(); - var serviceMock = mockRepository.StrictMock(); - var descriptorContextMock = mockRepository.StrictMock(); - serviceProviderMock.Expect(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); - serviceMock.Expect(s => s.DropDownControl(null)).IgnoreArguments(); - serviceMock.Expect(s => s.CloseDropDown()).IgnoreArguments(); - descriptorContextMock.Expect(c => c.Instance).Return(propertyBag).Repeat.Twice(); + var serviceProviderMock = mockRepository.Stub(); + var serviceMock = mockRepository.Stub(); + var descriptorContextMock = mockRepository.Stub(); + serviceProviderMock.Stub(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); + descriptorContextMock.Stub(c => c.Instance).Return(propertyBag); mockRepository.ReplayAll(); var someValue = new object(); Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs =================================================================== diff -u -r0d12e759b6e46290d83d04a6a5760fe467b339ab -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision 0d12e759b6e46290d83d04a6a5760fe467b339ab) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -20,9 +20,12 @@ // All rights reserved. using System; +using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.HydraRing.Data; using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources; @@ -32,7 +35,7 @@ /// /// Class that holds all height structures calculation specific input parameters. /// - public class HeightStructuresInput : Observable, ICalculationInput + public class HeightStructuresInput : Observable, ICalculationInput, IUseBreakWater, IUseForeshore { private readonly NormalDistribution levelCrestStructure; private readonly NormalDistribution modelFactorSuperCriticalFlow; @@ -45,6 +48,8 @@ private RoundedDouble structureNormalOrientation; private RoundedDouble deviationWaveDirection; private double failureProbabilityStructureWithErosion; + private ForeshoreProfile foreshoreProfile; + private HeightStructure heightStructure; /// /// Creates a new instance of the class. @@ -102,6 +107,9 @@ Mean = (RoundedDouble) 6.0 }; stormDuration.SetStandardDeviationFromVariationCoefficient(0.25); + + UpdateHeightStructureProperties(); + UpdateForeshoreProperties(); } #region Model Factors @@ -324,6 +332,94 @@ } } + /// + /// Gets or sets the height structure. + /// + public HeightStructure HeightStructure + { + get + { + return heightStructure; + } + set + { + heightStructure = value; + UpdateHeightStructureProperties(); + } + } + + /// + /// Gets or sets the foreshore profile. + /// + public ForeshoreProfile ForeshoreProfile + { + get + { + return foreshoreProfile; + } + set + { + foreshoreProfile = value; + UpdateForeshoreProperties(); + } + } + + public bool UseBreakWater { get; set; } + + + public bool UseForeshore { get; set; } + + public RoundedPoint2DCollection ForeshoreGeometry + { + get + { + return foreshoreProfile != null + ? foreshoreProfile.Geometry + : new RoundedPoint2DCollection(2, Enumerable.Empty()); + } + } + + + public BreakWater BreakWater { get; private set; } + + private void UpdateHeightStructureProperties() + { + if (heightStructure != null) + { + StructureNormalOrientation = heightStructure.StructureNormalOrientation; + LevelCrestStructure = heightStructure.LevelCrestStructure; + FlowWidthAtBottomProtection = heightStructure.FlowWidthAtBottomProtection; + CriticalOvertoppingDischarge = heightStructure.CriticalOvertoppingDischarge; + WidthFlowApertures = heightStructure.WidthFlowApertures; + FailureProbabilityStructureWithErosion = heightStructure.FailureProbabilityStructureWithErosion; + StorageStructureArea = heightStructure.StorageStructureArea; + AllowedLevelIncreaseStorage = heightStructure.AllowedLevelIncreaseStorage; + } + } + + private void UpdateForeshoreProperties() + { + if (foreshoreProfile == null) + { + UseForeshore = false; + UseBreakWater = false; + BreakWater = GetDefaultBreakWater(); + } + else + { + UseForeshore = foreshoreProfile.Geometry.Count() > 1; + UseBreakWater = foreshoreProfile.HasBreakWater; + BreakWater = foreshoreProfile.HasBreakWater ? + new BreakWater(foreshoreProfile.BreakWater.Type, foreshoreProfile.BreakWater.Height) : + GetDefaultBreakWater(); + } + } + + private static BreakWater GetDefaultBreakWater() + { + return new BreakWater(BreakWaterType.Dam, 0.0); + } + #endregion } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r438a524144f283209902ae89f058a134380c9538 -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 438a524144f283209902ae89f058a134380c9538) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -181,6 +181,24 @@ } /// + /// Looks up a localized string similar to De schematisatie van het voorlandprofiel.. + /// + public static string ForeshoreProfile_Description { + get { + return ResourceManager.GetString("ForeshoreProfile_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Voorlandprofiel. + /// + public static string ForeshoreProfile_DisplayName { + get { + return ResourceManager.GetString("ForeshoreProfile_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.. /// public static string HeightStructure_Location_Description { @@ -376,6 +394,24 @@ } /// + /// Looks up a localized string similar to Het kunstwerk wat gebruikt wordt in de berekening.. + /// + public static string Structure_Description { + get { + return ResourceManager.GetString("Structure_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Kunstwerk. + /// + public static string Structure_DisplayName { + get { + return ResourceManager.GetString("Structure_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De breedte van de kruin van het kunstwerk.. /// public static string WidthFlowApertures_Description { Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx =================================================================== diff -u -r438a524144f283209902ae89f058a134380c9538 -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision 438a524144f283209902ae89f058a134380c9538) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Properties/Resources.resx (.../Resources.resx) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -219,4 +219,16 @@ Naam + + Het kunstwerk wat gebruikt wordt in de berekening. + + + Kunstwerk + + + De schematisatie van het voorlandprofiel. + + + Voorlandprofiel + \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructureProperties.cs =================================================================== diff -u -r0d12e759b6e46290d83d04a6a5760fe467b339ab -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructureProperties.cs (.../HeightStructureProperties.cs) (revision 0d12e759b6e46290d83d04a6a5760fe467b339ab) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructureProperties.cs (.../HeightStructureProperties.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -57,7 +57,8 @@ { get { - return data.Location; + return new Point2D(new RoundedDouble(0, data.Location.X), + new RoundedDouble(0, data.Location.Y)); } } Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -r0d12e759b6e46290d83d04a6a5760fe467b339ab -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 0d12e759b6e46290d83d04a6a5760fe467b339ab) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -24,9 +24,11 @@ using System.ComponentModel; using System.Drawing.Design; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; +using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.HeightStructures.Data; @@ -44,17 +46,22 @@ /// public class HeightStructuresInputContextProperties : ObjectProperties { - private const int structureNormalOrientationPropertyIndex = 1; - private const int levelCrestStructurePropertyIndex = 2; - private const int allowedLevelIncreaseStoragePropertyIndex = 3; - private const int storageStructureAreaPropertyIndex = 4; - private const int flowWidthAtBottomProtectionPropertyIndex = 5; - private const int widthFlowAperturesPropertyIndex = 6; - private const int criticalOvertoppingDischargePropertyIndex = 7; - private const int failureProbabilityStructureWithErosionPropertyIndex = 8; - private const int modelFactorSuperCriticalFlowPropertyIndex = 9; - private const int hydraulicBoundaryLocationPropertyIndex = 10; - private const int stormDurationPropertyIndex = 11; + private const int heightStructurePropertyIndex = 1; + private const int heightStructureLocationPropertyIndex = 2; + private const int structureNormalOrientationPropertyIndex = 3; + private const int levelCrestStructurePropertyIndex = 4; + private const int allowedLevelIncreaseStoragePropertyIndex = 5; + private const int storageStructureAreaPropertyIndex = 6; + private const int flowWidthAtBottomProtectionPropertyIndex = 7; + private const int widthFlowAperturesPropertyIndex = 8; + private const int criticalOvertoppingDischargePropertyIndex = 9; + private const int failureProbabilityStructureWithErosionPropertyIndex = 10; + private const int foreshoreProfilePropertyIndex = 11; + private const int breakWaterPropertyIndex = 12; + private const int foreshoreGeometryPropertyIndex = 13; + private const int modelFactorSuperCriticalFlowPropertyIndex = 14; + private const int hydraulicBoundaryLocationPropertyIndex = 15; + private const int stormDurationPropertyIndex = 16; #region Model settings @@ -78,15 +85,69 @@ /// /// Returns the available hydraulic boundary locations in order for the user to select one to - /// set . + /// set . + /// /// The available hydraulic boundary locations. public IEnumerable GetAvailableHydraulicBoundaryLocations() { return data.AvailableHydraulicBoundaryLocations; } + /// + /// Returns the available height structures in order for the user to select one to + /// set . + /// + /// The available height structures. + public IEnumerable GetAvailableHeightStructures() + { + return data.FailureMechanism.HeightStructures; + } + + /// + /// Returns the available foreshore profiles in order for the user to select one to + /// set . + /// + /// The available foreshore profiles. + public IEnumerable GetAvailableForeshoreProfiles() + { + return data.FailureMechanism.ForeshoreProfiles; + } + #region Schematisation + [PropertyOrder(heightStructurePropertyIndex)] + [Editor(typeof(HeightStructuresInputContextStructureEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] + [ResourcesDisplayName(typeof(Resources), "Structure_DisplayName")] + [ResourcesDescription(typeof(Resources), "Structure_Description")] + public HeightStructure HeightStructure + { + get + { + return data.WrappedData.HeightStructure; + } + set + { + data.WrappedData.HeightStructure = value; + data.WrappedData.NotifyObservers(); + } + } + + [PropertyOrder(heightStructureLocationPropertyIndex)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] + [ResourcesDisplayName(typeof(Resources), "HeightStructure_Location_DisplayName")] + [ResourcesDescription(typeof(Resources), "HeightStructure_Location_Description")] + public Point2D HeightStructureLocation + { + get + { + return data.WrappedData.HeightStructure == null ? null : + new Point2D( + new RoundedDouble(0, data.WrappedData.HeightStructure.Location.X), + new RoundedDouble(0, data.WrappedData.HeightStructure.Location.Y)); + } + } + [PropertyOrder(structureNormalOrientationPropertyIndex)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] [ResourcesDisplayName(typeof(Resources), "StructureNormalOrientation_DisplayName")] @@ -232,6 +293,55 @@ } } + [PropertyOrder(foreshoreProfilePropertyIndex)] + [Editor(typeof(HeightStructuresInputContextForeshoreProfileEditor), typeof(UITypeEditor))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] + [ResourcesDisplayName(typeof(Resources), "ForeshoreProfile_DisplayName")] + [ResourcesDescription(typeof(Resources), "ForeshoreProfile_Description")] + public ForeshoreProfile ForeshoreProfile + { + get + { + return data.WrappedData.ForeshoreProfile; + } + set + { + data.WrappedData.ForeshoreProfile = value; + data.WrappedData.NotifyObservers(); + } + } + + [PropertyOrder(breakWaterPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "BreakWaterProperties_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "BreakWaterProperties_Description")] + public UseBreakWaterProperties BreakWater + { + get + { + return new UseBreakWaterProperties(data.WrappedData, UseBreakWaterEnabled); + } + } + + private bool UseBreakWaterEnabled() + { + return data.WrappedData.ForeshoreProfile != null; + } + + [PropertyOrder(foreshoreGeometryPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Schematization")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "ForeshoreProperties_DisplayName")] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), "ForeshoreProperties_Description")] + public UseForeshoreProperties ForeshoreGeometry + { + get + { + return new UseForeshoreProperties(data.WrappedData); + } + } + #endregion #region Hydraulic data Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj =================================================================== diff -u -rd499bba7f0abdb8481bfe1ffc619414116a13121 -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision d499bba7f0abdb8481bfe1ffc619414116a13121) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Ringtoets.HeightStructures.Forms.csproj (.../Ringtoets.HeightStructures.Forms.csproj) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -56,7 +56,9 @@ + + UserControl Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/UITypeEditors/HeightStructuresInputContextForeshoreProfileEditor.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/UITypeEditors/HeightStructuresInputContextForeshoreProfileEditor.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/UITypeEditors/HeightStructuresInputContextForeshoreProfileEditor.cs (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -0,0 +1,56 @@ +// 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.Collections.Generic; +using System.ComponentModel; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Forms.UITypeEditors; +using Ringtoets.HeightStructures.Forms.PropertyClasses; + +namespace Ringtoets.HeightStructures.Forms.UITypeEditors +{ + /// + /// This class defines a drop down list edit-control from which the user can select a + /// from a collection. + /// + public class HeightStructuresInputContextForeshoreProfileEditor + : SelectionEditor + { + /// + /// Creates a new instance of . + /// + public HeightStructuresInputContextForeshoreProfileEditor() + { + DisplayMember = TypeUtils.GetMemberName(fp => fp.Name); + } + + protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) + { + return GetPropertiesObject(context).GetAvailableForeshoreProfiles(); + } + + protected override ForeshoreProfile GetCurrentOption(ITypeDescriptorContext context) + { + return GetPropertiesObject(context).ForeshoreProfile; + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/UITypeEditors/HeightStructuresInputContextStructureEditor.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/UITypeEditors/HeightStructuresInputContextStructureEditor.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/UITypeEditors/HeightStructuresInputContextStructureEditor.cs (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -0,0 +1,56 @@ +// 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.Collections.Generic; +using System.ComponentModel; +using Core.Common.Utils.Reflection; +using Ringtoets.Common.Forms.UITypeEditors; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PropertyClasses; + +namespace Ringtoets.HeightStructures.Forms.UITypeEditors +{ + /// + /// This class defines a drop down list edit-control from which the user can select a + /// from a collection. + /// + public class HeightStructuresInputContextStructureEditor : + SelectionEditor + { + /// + /// Creates a new instance of . + /// + public HeightStructuresInputContextStructureEditor() + { + DisplayMember = TypeUtils.GetMemberName(hs => hs.Name); + } + + protected override IEnumerable GetAvailableOptions(ITypeDescriptorContext context) + { + return GetPropertiesObject(context).GetAvailableHeightStructures(); + } + + protected override HeightStructure GetCurrentOption(ITypeDescriptorContext context) + { + return GetPropertiesObject(context).HeightStructure; + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r0d12e759b6e46290d83d04a6a5760fe467b339ab -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 0d12e759b6e46290d83d04a6a5760fe467b339ab) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -22,13 +22,16 @@ using System; using System.ComponentModel; using System.Globalization; +using System.Linq; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.HeightStructures.Data; @@ -43,17 +46,23 @@ [TestFixture] public class HeightStructuresInputContextPropertiesTest { - private const int structureNormalOrientationPropertyIndex = 0; - private const int levelCrestStructurePropertyIndex = 1; - private const int allowedLevelIncreaseStoragePropertyIndex = 2; - private const int storageStructureAreaPropertyIndex = 3; - private const int flowWidthAtBottomProtectionPropertyIndex = 4; - private const int widthFlowAperturesPropertyIndex = 5; - private const int criticalOvertoppingDischargePropertyIndex = 6; - private const int failureProbabilityStructureWithErosionPropertyIndex = 7; - private const int modelFactorSuperCriticalFlowPropertyIndex = 8; - private const int hydraulicBoundaryLocationPropertyIndex = 9; - private const int stormDurationPropertyIndex = 10; + private const int heightStructurePropertyIndex = 0; + private const int heightStructureLocationPropertyIndex = 1; + private const int structureNormalOrientationPropertyIndex = 2; + private const int levelCrestStructurePropertyIndex = 3; + private const int allowedLevelIncreaseStoragePropertyIndex = 4; + private const int storageStructureAreaPropertyIndex = 5; + private const int flowWidthAtBottomProtectionPropertyIndex = 6; + private const int widthFlowAperturesPropertyIndex = 7; + private const int criticalOvertoppingDischargePropertyIndex = 8; + private const int failureProbabilityStructureWithErosionPropertyIndex = 9; + private const int foreshoreProfilePropertyIndex = 10; + private const int breakWaterPropertyIndex = 11; + private const int foreshoreGeometryPropertyIndex = 12; + private const int modelFactorSuperCriticalFlowPropertyIndex = 13; + private const int hydraulicBoundaryLocationPropertyIndex = 14; + private const int stormDurationPropertyIndex = 15; + private MockRepository mockRepository; [SetUp] @@ -90,6 +99,10 @@ properties.Data = inputContext; // Assert + Assert.IsNull(properties.HeightStructure); + + Assert.IsNull(properties.HeightStructureLocation); + var modelFactorSuperCriticalFlowProperties = new NormalDistributionProperties { Data = input.ModelFactorSuperCriticalFlow @@ -134,6 +147,12 @@ }; AssertLogNormalDistributionVariationProperties(criticalOvertoppingDischargeProperties, properties.CriticalOvertoppingDischarge); + Assert.IsNull(properties.ForeshoreProfile); + + Assert.IsInstanceOf(properties.BreakWater); + + Assert.IsInstanceOf(properties.ForeshoreGeometry); + var expectedFailureProbabilityStructureWithErosion = ProbabilityFormattingHelper.Format(input.FailureProbabilityStructureWithErosion); Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, properties.FailureProbabilityStructureWithErosion); @@ -149,14 +168,106 @@ } [Test] + public void Data_SetNewInputContextInstanceWithData_ReturnCorrectPropertyValues() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var input = new HeightStructuresInput + { + HeightStructure = CreateValidHeightStructure(), + HydraulicBoundaryLocation = CreateValidHydraulicBoundaryLocation(), + ForeshoreProfile = CreateValidForeshoreProfile() + }; + var inputContext = new HeightStructuresInputContext(input, + new HeightStructuresFailureMechanism(), + assessmentSectionMock); + + var properties = new HeightStructuresInputContextProperties(); + + // Call + properties.Data = inputContext; + + // Assert + Assert.AreSame(input.HeightStructure, properties.HeightStructure); + + var expectedHeightStructureLocation = new Point2D(new RoundedDouble(0, input.HeightStructure.Location.X), new RoundedDouble(0, input.HeightStructure.Location.Y)); + Assert.AreEqual(expectedHeightStructureLocation, properties.HeightStructureLocation); + + Assert.AreEqual(input.HeightStructure.StructureNormalOrientation, properties.StructureNormalOrientation); + + var levelCrestStructureProperties = new NormalDistributionProperties + { + Data = input.LevelCrestStructure + }; + AssertDistributionProperties(levelCrestStructureProperties, properties.LevelCrestStructure); + + var allowedLevelIncreaseStorageProperties = new LogNormalDistributionProperties + { + Data = input.AllowedLevelIncreaseStorage + }; + AssertDistributionProperties(allowedLevelIncreaseStorageProperties, properties.AllowedLevelIncreaseStorage); + + var storageStructureAreaProperties = new LogNormalDistributionVariationProperties + { + Data = input.StorageStructureArea + }; + AssertLogNormalDistributionVariationProperties(storageStructureAreaProperties, properties.StorageStructureArea); + + var flowWidthAtBottomProtectionProperties = new LogNormalDistributionProperties + { + Data = input.FlowWidthAtBottomProtection + }; + AssertDistributionProperties(flowWidthAtBottomProtectionProperties, properties.FlowWidthAtBottomProtection); + + var widthFlowAperturesProperties = new NormalDistributionVariationProperties + { + Data = input.WidthFlowApertures + }; + AssertDistributionProperties(widthFlowAperturesProperties, properties.WidthFlowApertures); + + var criticalOvertoppingDischargeProperties = new LogNormalDistributionVariationProperties + { + Data = input.CriticalOvertoppingDischarge + }; + AssertLogNormalDistributionVariationProperties(criticalOvertoppingDischargeProperties, properties.CriticalOvertoppingDischarge); + + var expectedFailureProbabilityStructureWithErosion = ProbabilityFormattingHelper.Format(input.FailureProbabilityStructureWithErosion); + Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, properties.FailureProbabilityStructureWithErosion); + + Assert.AreSame(input.ForeshoreProfile, properties.ForeshoreProfile); + + Assert.IsInstanceOf(properties.BreakWater); + + Assert.IsInstanceOf(properties.ForeshoreGeometry); + + var modelFactorSuperCriticalFlowProperties = new NormalDistributionProperties + { + Data = input.ModelFactorSuperCriticalFlow + }; + AssertDistributionProperties(modelFactorSuperCriticalFlowProperties, properties.ModelFactorSuperCriticalFlow); + + Assert.AreSame(input.HydraulicBoundaryLocation, properties.HydraulicBoundaryLocation); + + var stormDurationProperties = new LogNormalDistributionVariationProperties + { + Data = input.StormDuration + }; + AssertLogNormalDistributionVariationProperties(stormDurationProperties, properties.StormDuration); + + mockRepository.VerifyAll(); + } + + [Test] public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() { // Setup var observerMock = mockRepository.StrictMock(); const int numberProperties = 3; observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberProperties); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "name", 0.0, 1.1); - var assessmentSectionMock = mockRepository.StrictMock(); + var hydraulicBoundaryLocation = CreateValidHydraulicBoundaryLocation(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -191,7 +302,7 @@ public void SetFailureProbabilityStructureWithErosion_InvalidValues_ThrowsArgumentException(double newValue) { // Setup - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -219,7 +330,7 @@ public void SetFailureProbabilityStructureWithErosion_ValuesUnableToParse_ThrowsArgumentException(string newValue) { // Setup - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -242,10 +353,10 @@ } [Test] - public void SetFailureProbabilityStructureWithErosion_NullValue_ThrowsArgumentException() + public void SetFailureProbabilityStructureWithErosion_NullValue_ThrowsArgumentNullException() { // Setup - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -271,7 +382,7 @@ public void PropertyAttributes_ReturnExpectedValues() { // Setup - var assessmentSectionMock = mockRepository.StrictMock(); + var assessmentSectionMock = mockRepository.Stub(); mockRepository.ReplayAll(); var failureMechanism = new HeightStructuresFailureMechanism(); @@ -285,13 +396,28 @@ }; // Assert - var schematizationCategory = "Schematisatie"; - var modelSettingsCategory = "Modelinstellingen"; + const string schematizationCategory = "Schematisatie"; + const string modelSettingsCategory = "Modelinstellingen"; var dynamicPropertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); - Assert.AreEqual(12, dynamicProperties.Count); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(16, dynamicProperties.Count); + PropertyDescriptor heightStructureProperty = dynamicProperties[heightStructurePropertyIndex]; + Assert.IsFalse(heightStructureProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, heightStructureProperty.Category); + Assert.AreEqual("Kunstwerk", heightStructureProperty.DisplayName); + Assert.AreEqual("Het kunstwerk wat gebruikt wordt in de berekening.", heightStructureProperty.Description); + + PropertyDescriptor heightStructureLocationProperty = dynamicProperties[heightStructureLocationPropertyIndex]; + Assert.IsTrue(heightStructureLocationProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, heightStructureLocationProperty.Category); + Assert.AreEqual("Locatie (RD) [m]", heightStructureLocationProperty.DisplayName); + Assert.AreEqual("De coördinaten van de locatie van het kunstwerk in het Rijksdriehoeksstelsel.", heightStructureLocationProperty.Description); + PropertyDescriptor structureNormalOrientationProperty = dynamicProperties[structureNormalOrientationPropertyIndex]; Assert.IsFalse(structureNormalOrientationProperty.IsReadOnly); Assert.AreEqual(schematizationCategory, structureNormalOrientationProperty.Category); @@ -346,6 +472,26 @@ Assert.AreEqual("Modelfactor van overloopdebiet bij superkritische stroming [-]", modelFactorSuperCriticalFlowProperty.DisplayName); Assert.AreEqual("Het modelfactor van overloopdebiet bij superkritische stroming.", modelFactorSuperCriticalFlowProperty.Description); + PropertyDescriptor foreshoreProfileProperty = dynamicProperties[foreshoreProfilePropertyIndex]; + Assert.IsFalse(foreshoreProfileProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, foreshoreProfileProperty.Category); + Assert.AreEqual("Voorlandprofiel", foreshoreProfileProperty.DisplayName); + Assert.AreEqual("De schematisatie van het voorlandprofiel.", foreshoreProfileProperty.Description); + + PropertyDescriptor breakWaterProperty = dynamicProperties[breakWaterPropertyIndex]; + Assert.IsInstanceOf(breakWaterProperty.Converter); + Assert.IsTrue(breakWaterProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, breakWaterProperty.Category); + Assert.AreEqual("Dam", breakWaterProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de dam.", breakWaterProperty.Description); + + PropertyDescriptor foreshoreGeometryProperty = dynamicProperties[foreshoreGeometryPropertyIndex]; + Assert.IsInstanceOf(foreshoreGeometryProperty.Converter); + Assert.IsTrue(foreshoreGeometryProperty.IsReadOnly); + Assert.AreEqual(schematizationCategory, foreshoreGeometryProperty.Category); + Assert.AreEqual("Voorlandgeometrie", foreshoreGeometryProperty.DisplayName); + Assert.AreEqual("Eigenschappen van de voorlandgeometrie.", foreshoreGeometryProperty.Description); + PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[hydraulicBoundaryLocationPropertyIndex]; Assert.IsFalse(hydraulicBoundaryLocationProperty.IsReadOnly); Assert.AreEqual("Hydraulische gegevens", hydraulicBoundaryLocationProperty.Category); @@ -361,6 +507,29 @@ mockRepository.VerifyAll(); } + private static ForeshoreProfile CreateValidForeshoreProfile() + { + return new ForeshoreProfile(new Point2D(0, 0), Enumerable.Empty(), new BreakWater(BreakWaterType.Caisson, 0), new ForeshoreProfile.ConstructionProperties()); + } + + private static HydraulicBoundaryLocation CreateValidHydraulicBoundaryLocation() + { + return new HydraulicBoundaryLocation(0, "name", 0.0, 1.1); + } + + private static HeightStructure CreateValidHeightStructure() + { + return new HeightStructure("aName", "anId", new Point2D(1, 1), + 0.12345, + 234.567, 0.23456, + 345.678, 0.34567, + 456.789, 0.45678, + 567.890, 0.56789, + 0.67890, + 112.223, 0.11222, + 225.336, 0.22533); + } + private static void AssertDistributionProperties(DistributionProperties expected, DistributionProperties actual) { Assert.AreEqual(expected.DistributionType, actual.DistributionType); Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r6b9fda141298524c0910937dd090d82be420c52b -r0a6fd2fa18908a63fc029833ea3735709ebd5829 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 6b9fda141298524c0910937dd090d82be420c52b) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -78,7 +78,9 @@ + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/UITypeEditors/HeightStructuresInputContextForeshoreProfileEditorTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/UITypeEditors/HeightStructuresInputContextForeshoreProfileEditorTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/UITypeEditors/HeightStructuresInputContextForeshoreProfileEditorTest.cs (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -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; +using System.ComponentModel; +using System.Linq; +using System.Windows.Forms.Design; +using Core.Common.Base.Geometry; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Forms.PropertyClasses; +using Ringtoets.HeightStructures.Forms.UITypeEditors; + +namespace Ringtoets.HeightStructures.Forms.Test.UITypeEditors +{ + [TestFixture] + public class HeightStructuresInputContextForeshoreProfileEditorTest + { + private MockRepository mockRepository; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + } + + [Test] + public void EditValue_NoCurrentItemInAvailableItems_ReturnsOriginalValue() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + var foreshoreProfile = new TestForeshoreProfile(); + var inputContext = new HeightStructuresInputContext( + new HeightStructuresInput(), + new HeightStructuresFailureMechanism + { + ForeshoreProfiles = + { + foreshoreProfile + } + }, + assessmentSectionMock); + + var properties = new HeightStructuresInputContextProperties + { + Data = inputContext + }; + + var propertyBag = new DynamicPropertyBag(properties); + + var serviceProviderMock = mockRepository.Stub(); + var serviceMock = mockRepository.Stub(); + var descriptorContextMock = mockRepository.Stub(); + serviceProviderMock.Stub(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); + descriptorContextMock.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + var editor = new HeightStructuresInputContextForeshoreProfileEditor(); + var someValue = new object(); + + // Call + var result = editor.EditValue(descriptorContextMock, serviceProviderMock, someValue); + + // Assert + Assert.AreSame(someValue, result); + mockRepository.VerifyAll(); + } + + [Test] + public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + var foreshoreProfile = new TestForeshoreProfile(); + var inputContext = new HeightStructuresInputContext( + new HeightStructuresInput + { + ForeshoreProfile = foreshoreProfile + }, + new HeightStructuresFailureMechanism + { + ForeshoreProfiles = + { + foreshoreProfile + } + }, + assessmentSectionMock); + + var properties = new HeightStructuresInputContextProperties + { + Data = inputContext + }; + + var propertyBag = new DynamicPropertyBag(properties); + + var serviceProviderMock = mockRepository.Stub(); + var serviceMock = mockRepository.Stub(); + var descriptorContextMock = mockRepository.Stub(); + serviceProviderMock.Stub(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); + descriptorContextMock.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + var editor = new HeightStructuresInputContextForeshoreProfileEditor(); + var someValue = new object(); + + // Call + var result = editor.EditValue(descriptorContextMock, serviceProviderMock, someValue); + + // Assert + Assert.AreSame(foreshoreProfile, result); + mockRepository.VerifyAll(); + } + + private class TestForeshoreProfile : ForeshoreProfile + { + public TestForeshoreProfile() : base(new Point2D(0, 0), Enumerable.Empty(), + null, new ConstructionProperties()) {} + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/UITypeEditors/HeightStructuresInputContextStructureEditorTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/UITypeEditors/HeightStructuresInputContextStructureEditorTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/UITypeEditors/HeightStructuresInputContextStructureEditorTest.cs (revision 0a6fd2fa18908a63fc029833ea3735709ebd5829) @@ -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; +using System.ComponentModel; +using System.Windows.Forms.Design; +using Core.Common.Base.Geometry; +using Core.Common.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Forms.PresentationObjects; +using Ringtoets.HeightStructures.Forms.PropertyClasses; +using Ringtoets.HeightStructures.Forms.UITypeEditors; + +namespace Ringtoets.HeightStructures.Forms.Test.UITypeEditors +{ + [TestFixture] + public class HeightStructuresInputContextStructureEditorTest + { + private MockRepository mockRepository; + + [SetUp] + public void SetUp() + { + mockRepository = new MockRepository(); + } + + [Test] + public void EditValue_NoCurrentItemInAvailableItems_ReturnsOriginalValue() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + var heightStructure = new TestHeightStructure(); + var inputContext = new HeightStructuresInputContext( + new HeightStructuresInput(), + new HeightStructuresFailureMechanism + { + HeightStructures = + { + heightStructure + } + }, + assessmentSectionMock); + + var properties = new HeightStructuresInputContextProperties + { + Data = inputContext + }; + + var propertyBag = new DynamicPropertyBag(properties); + + var serviceProviderMock = mockRepository.Stub(); + var serviceMock = mockRepository.Stub(); + var descriptorContextMock = mockRepository.Stub(); + serviceProviderMock.Stub(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); + descriptorContextMock.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + var editor = new HeightStructuresInputContextStructureEditor(); + var someValue = new object(); + + // Call + var result = editor.EditValue(descriptorContextMock, serviceProviderMock, someValue); + + // Assert + Assert.AreSame(someValue, result); + mockRepository.VerifyAll(); + } + + [Test] + public void EditValue_WithCurrentItemInAvailableItems_ReturnsCurrentItem() + { + // Setup + var assessmentSectionMock = mockRepository.Stub(); + var heightStructure = new TestHeightStructure(); + var inputContext = new HeightStructuresInputContext( + new HeightStructuresInput + { + HeightStructure = heightStructure + }, + new HeightStructuresFailureMechanism + { + HeightStructures = + { + heightStructure + } + }, + assessmentSectionMock); + + var properties = new HeightStructuresInputContextProperties + { + Data = inputContext + }; + + var propertyBag = new DynamicPropertyBag(properties); + + var serviceProviderMock = mockRepository.Stub(); + var serviceMock = mockRepository.Stub(); + var descriptorContextMock = mockRepository.Stub(); + serviceProviderMock.Stub(p => p.GetService(null)).IgnoreArguments().Return(serviceMock); + descriptorContextMock.Stub(c => c.Instance).Return(propertyBag); + mockRepository.ReplayAll(); + + var editor = new HeightStructuresInputContextStructureEditor(); + var someValue = new object(); + + // Call + var result = editor.EditValue(descriptorContextMock, serviceProviderMock, someValue); + + // Assert + Assert.AreSame(heightStructure, result); + mockRepository.VerifyAll(); + } + + private class TestHeightStructure : HeightStructure + { + public TestHeightStructure() + : base("Test", "Id", new Point2D(0, 0), 0.12345, 234.567, 0.23456, + 345.678, 0.34567, 456.789, 0.45678, 567.890, 0.56789, + 0.67890, 112.223, 0.11222, 225.336, 0.22533) {} + } + } +} \ No newline at end of file