Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightCalculationsProperties.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightCalculationsProperties.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightCalculationsProperties.cs (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -0,0 +1,61 @@ +// Copyright (C) Stichting Deltares 2017. 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.Gui.Converters; +using Core.Common.Util.Attributes; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Forms.Properties; +using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.GrassCoverErosionOutwards.Data; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.PropertyClasses +{ + /// + /// ViewModel of an enumeration of with a wave height + /// calculation result for properties panel of the . + /// + public class GrassCoverErosionOutwardsWaveHeightCalculationsProperties : HydraulicBoundaryLocationsProperties + { + /// + /// Creates a new instance of . + /// + /// The hydraulic boundary location calculations to set as data. + /// Thrown when is null. + public GrassCoverErosionOutwardsWaveHeightCalculationsProperties(ObservableList hydraulicBoundaryLocationCalculations) + : base(hydraulicBoundaryLocationCalculations) {} + + [TypeConverter(typeof(ExpandableArrayConverter))] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.HydraulicBoundaryDatabase_Locations_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.HydraulicBoundaryDatabase_Locations_Description))] + public GrassCoverErosionOutwardsWaveHeightCalculationProperties[] Calculations + { + get + { + return data.Select(calculation => new GrassCoverErosionOutwardsWaveHeightCalculationProperties(calculation)).ToArray(); + } + } + } +} \ No newline at end of file Fisheye: Tag 1808e62474dba5945462ff310b654d485008c3d6 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj =================================================================== diff -u -r429466635b648004a162569fcd2f48ac582e7c65 -r1808e62474dba5945462ff310b654d485008c3d6 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 429466635b648004a162569fcd2f48ac582e7c65) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -39,7 +39,7 @@ - + UserControl Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r598ccbb13f529c772dbeeb14eac2d5403c5480c4 -r1808e62474dba5945462ff310b654d485008c3d6 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 598ccbb13f529c772dbeeb14eac2d5403c5480c4) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -90,15 +90,15 @@ return new GrassCoverErosionOutwardsDesignWaterLevelLocationsProperties(hydraulicBoundaryLocationCalculations); } }; - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => { var hydraulicBoundaryLocationCalculations = new ObservableList(); hydraulicBoundaryLocationCalculations.AddRange(context.WrappedData.Select(loc => loc.DesignWaterLevelCalculation1)); - return new GrassCoverErosionOutwardsWaveHeightLocationsProperties(hydraulicBoundaryLocationCalculations); + return new GrassCoverErosionOutwardsWaveHeightCalculationsProperties(hydraulicBoundaryLocationCalculations); } }; Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightCalculationsPropertiesTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightCalculationsPropertiesTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightCalculationsPropertiesTest.cs (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -0,0 +1,126 @@ +// Copyright (C) Stichting Deltares 2017. 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 System.Linq; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class GrassCoverErosionOutwardsWaveHeightCalculationsPropertiesTest + { + private const int requiredLocationsPropertyIndex = 0; + + [Test] + public void Constructor_WithLocations_ExpectedValues() + { + // Setup + var hydraulicBoundaryLocationCalculations = new ObservableList(); + + // Call + var properties = new GrassCoverErosionOutwardsWaveHeightCalculationsProperties(hydraulicBoundaryLocationCalculations); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreSame(hydraulicBoundaryLocationCalculations, properties.Data); + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + const string expectedLocationsDisplayName = "Locaties"; + const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase."; + const string expectedLocationsCategory = "Algemeen"; + TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); + + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); + PropertyDescriptor locationsProperty = dynamicProperties.Find("Locations", false); + + Assert.IsInstanceOf(classTypeConverter); + Assert.IsNotNull(locationsProperty); + Assert.IsInstanceOf(locationsProperty.Converter); + Assert.IsTrue(locationsProperty.IsReadOnly); + Assert.IsTrue(locationsProperty.IsBrowsable); + Assert.AreEqual(expectedLocationsDisplayName, locationsProperty.DisplayName); + Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description); + Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + { + // Call + var properties = new GrassCoverErosionOutwardsWaveHeightCalculationsProperties(new ObservableList()); + + // Assert + TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); + Assert.IsInstanceOf(classTypeConverter); + + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(1, dynamicProperties.Count); + + PropertyDescriptor locationsProperty = dynamicProperties[requiredLocationsPropertyIndex]; + Assert.IsInstanceOf(locationsProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(locationsProperty, + "Algemeen", + "Locaties", + "Locaties uit de hydraulische randvoorwaardendatabase.", + true); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocationCalculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation) + { + Output = new TestHydraulicBoundaryLocationOutput(1.5, CalculationConvergence.CalculatedConverged) + }; + + // Call + var properties = new GrassCoverErosionOutwardsWaveHeightCalculationsProperties(new ObservableList + { + hydraulicBoundaryLocationCalculation + }); + + // Assert + Assert.AreEqual(1, properties.Calculations.Length); + TestHelper.AssertTypeConverter( + nameof(GrassCoverErosionOutwardsWaveHeightCalculationsProperties.Calculations)); + GrassCoverErosionOutwardsWaveHeightCalculationProperties calculationProperties = properties.Calculations.First(); + Assert.AreEqual(hydraulicBoundaryLocation.Name, calculationProperties.Name); + Assert.AreEqual(hydraulicBoundaryLocation.Id, calculationProperties.Id); + Assert.AreEqual(hydraulicBoundaryLocation.Location, calculationProperties.Location); + + RoundedDouble waveHeight = hydraulicBoundaryLocationCalculation.Output.Result; + Assert.AreEqual(waveHeight, calculationProperties.WaveHeight, waveHeight.GetAccuracy()); + Assert.AreEqual("Ja", calculationProperties.Convergence); + } + } +} \ No newline at end of file Fisheye: Tag 1808e62474dba5945462ff310b654d485008c3d6 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj =================================================================== diff -u -r429466635b648004a162569fcd2f48ac582e7c65 -r1808e62474dba5945462ff310b654d485008c3d6 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 429466635b648004a162569fcd2f48ac582e7c65) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -44,7 +44,7 @@ - + Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -r598ccbb13f529c772dbeeb14eac2d5403c5480c4 -r1808e62474dba5945462ff310b654d485008c3d6 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 598ccbb13f529c772dbeeb14eac2d5403c5480c4) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -134,7 +134,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(GrassCoverErosionOutwardsWaveHeightLocationsContext), - typeof(GrassCoverErosionOutwardsWaveHeightLocationsProperties)); + typeof(GrassCoverErosionOutwardsWaveHeightCalculationsProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextPropertyInfoTest.cs =================================================================== diff -u -ra5bf4f56dbf07e5cf48d0b874f5d46d7d02f0dba -r1808e62474dba5945462ff310b654d485008c3d6 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextPropertyInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextPropertyInfoTest.cs) (revision a5bf4f56dbf07e5cf48d0b874f5d46d7d02f0dba) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsWaveHeightLocationsContextPropertyInfoTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextPropertyInfoTest.cs) (revision 1808e62474dba5945462ff310b654d485008c3d6) @@ -47,7 +47,7 @@ // Assert Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveHeightLocationsContext), info.DataType); - Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveHeightLocationsProperties), info.PropertyObjectType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsWaveHeightCalculationsProperties), info.PropertyObjectType); } } @@ -72,7 +72,7 @@ IObjectProperties objectProperties = info.CreateInstance(context); // Assert - Assert.IsInstanceOf(objectProperties); + Assert.IsInstanceOf(objectProperties); Assert.AreSame(hydraulicBoundaryLocations, objectProperties.Data); } mockRepository.VerifyAll();