Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/OvertoppingRateOutputProperties.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/OvertoppingRateOutputProperties.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/OvertoppingRateOutputProperties.cs (revision c778f3be881fdcedc6d3bda8d02aa535499e33ac) @@ -0,0 +1,117 @@ +// 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 Core.Common.Base.Data; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils; +using Core.Common.Utils.Attributes; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class OvertoppingRateOutputProperties : ObjectProperties + { + [PropertyOrder(1)] + [ResourcesCategory(typeof(Resources), nameof(Resources.OvertoppingRate_DisplayName), 3, 3)] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionInwardsOutput_OvertoppingRate_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionInwardsOutput_OvertoppingRate_Description))] + public RoundedDouble OvertoppingRate + { + get + { + return new RoundedDouble(2, data.OvertoppingRate * 1000); + } + } + + [PropertyOrder(2)] + [ResourcesCategory(typeof(Resources), nameof(Resources.OvertoppingRate_DisplayName), 3, 3)] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_TargetProbability_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_TargetProbability_Description))] + [TypeConverter(typeof(NoProbabilityValueDoubleConverter))] + public double OvertoppingRateTargetProbability + { + get + { + return data.TargetProbability; + } + } + + [PropertyOrder(3)] + [ResourcesCategory(typeof(Resources), nameof(Resources.OvertoppingRate_DisplayName), 3, 3)] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_TargetReliability_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_TargetReliability_Description))] + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble OvertoppingRateTargetReliability + { + get + { + return data.TargetReliability; + } + } + + [PropertyOrder(4)] + [ResourcesCategory(typeof(Resources), nameof(Resources.OvertoppingRate_DisplayName), 3, 3)] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedProbability_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedProbability_Description))] + [TypeConverter(typeof(NoProbabilityValueDoubleConverter))] + public double OvertoppingRateCalculatedProbability + { + get + { + return data.CalculatedProbability; + } + } + + [PropertyOrder(5)] + [ResourcesCategory(typeof(Resources), nameof(Resources.OvertoppingRate_DisplayName), 3, 3)] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedReliability_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_CalculatedReliability_Description))] + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble OvertoppingRateCalculatedReliability + { + get + { + return data.CalculatedReliability; + } + } + + [PropertyOrder(6)] + [ResourcesCategory(typeof(Resources), nameof(Resources.OvertoppingRate_DisplayName), 3, 3)] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.CalculationOutput_Convergence_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.OvertoppingRateOutput_Convergence_Description))] + public string OvertoppingRateConvergence + { + get + { + return new EnumDisplayWrapper(data.CalculationConvergence).DisplayName; + } + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj =================================================================== diff -u -r78c98e27e738de793573412374041021a1264758 -rc778f3be881fdcedc6d3bda8d02aa535499e33ac --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 78c98e27e738de793573412374041021a1264758) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision c778f3be881fdcedc6d3bda8d02aa535499e33ac) @@ -69,6 +69,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/OvertoppingRateOutputPropertiesTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/OvertoppingRateOutputPropertiesTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/OvertoppingRateOutputPropertiesTest.cs (revision c778f3be881fdcedc6d3bda8d02aa535499e33ac) @@ -0,0 +1,163 @@ +// 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 Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using Core.Common.Utils; +using NUnit.Framework; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TypeConverters; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; +using Ringtoets.GrassCoverErosionInwards.Forms.PropertyClasses; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class OvertoppingRateOutputPropertiesTest + { + private const int overtoppingRatePropertyIndex = 0; + private const int targetProbabilityPropertyIndex = 1; + private const int targetReliabilityPropertyIndex = 2; + private const int calculatedProbabilityPropertyIndex = 3; + private const int calculatedReliabilityPropertyIndex = 4; + private const int convergencePropertyIndex = 5; + + [Test] + public void Constructor_ExpectedValues() + { + // Call + var properties = new OvertoppingRateOutputProperties(); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.IsNull(properties.Data); + } + + [Test] + public void Data_SetNewInputContextInstance_ReturnCorrectPropertyValues() + { + // Setup + var random = new Random(); + double overtoppingRate = random.NextDouble(); + double overtoppingRateTargetProbability = random.NextDouble(); + double overtoppingRateTargetReliability = random.NextDouble(); + double overtoppingRateCalculatedProbability = random.NextDouble(); + double overtoppingRateCalculatedReliability = random.NextDouble(); + var overtoppingRateConvergence = random.NextEnumValue(); + + var output = new OvertoppingRateOutput(overtoppingRate, + overtoppingRateTargetProbability, + overtoppingRateTargetReliability, + overtoppingRateCalculatedProbability, + overtoppingRateCalculatedReliability, + overtoppingRateConvergence); + + // Call + var properties = new OvertoppingRateOutputProperties + { + Data = output + }; + + // Assert + Assert.AreEqual(2, properties.OvertoppingRate.NumberOfDecimalPlaces); + Assert.AreEqual(overtoppingRate * 1000, properties.OvertoppingRate, properties.OvertoppingRate.GetAccuracy()); + Assert.AreEqual(overtoppingRateTargetProbability, properties.OvertoppingRateTargetProbability); + TestHelper.AssertTypeConverter( + nameof(GrassCoverErosionInwardsOutputProperties.OvertoppingRateTargetProbability)); + Assert.AreEqual(overtoppingRateTargetReliability, properties.OvertoppingRateTargetReliability, properties.OvertoppingRateTargetReliability.GetAccuracy()); + TestHelper.AssertTypeConverter( + nameof(GrassCoverErosionInwardsOutputProperties.OvertoppingRateTargetReliability)); + Assert.AreEqual(overtoppingRateCalculatedProbability, properties.OvertoppingRateCalculatedProbability); + TestHelper.AssertTypeConverter( + nameof(GrassCoverErosionInwardsOutputProperties.OvertoppingRateCalculatedProbability)); + Assert.AreEqual(overtoppingRateCalculatedReliability, properties.OvertoppingRateCalculatedReliability, properties.OvertoppingRateCalculatedReliability.GetAccuracy()); + TestHelper.AssertTypeConverter( + nameof(GrassCoverErosionInwardsOutputProperties.OvertoppingRateCalculatedReliability)); + + string overtoppingRateConvergenceValue = new EnumDisplayWrapper(overtoppingRateConvergence).DisplayName; + Assert.AreEqual(overtoppingRateConvergenceValue, properties.OvertoppingRateConvergence); + } + + [Test] + public void PropertyAttributes_Always_ReturnExpectedValues() + { + // Setup + var output = new TestOvertoppingRateOutput(10); + + // Call + var properties = new OvertoppingRateOutputProperties + { + Data = output + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(6, dynamicProperties.Count); + + const string overtoppingRateCategory = "Overslagdebiet"; + PropertyDescriptor overtoppingRateProperty = dynamicProperties[overtoppingRatePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(overtoppingRateProperty, + overtoppingRateCategory, + "Overslagdebiet [l/m/s]", + "Het berekende overslagdebiet.", + true); + + PropertyDescriptor overtoppingRateTargetProbability = dynamicProperties[targetProbabilityPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(overtoppingRateTargetProbability, + overtoppingRateCategory, + "Doelkans [1/jaar]", + "De ingevoerde kans waarvoor het resultaat moet worden berekend.", + true); + + PropertyDescriptor overtoppingRateTargetReliability = dynamicProperties[targetReliabilityPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(overtoppingRateTargetReliability, + overtoppingRateCategory, + "Betrouwbaarheidsindex doelkans [-]", + "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.", + true); + + PropertyDescriptor overtoppingRateCalculatedProbability = dynamicProperties[calculatedProbabilityPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(overtoppingRateCalculatedProbability, + overtoppingRateCategory, + "Berekende kans [1/jaar]", + "De berekende kans van voorkomen van het berekende resultaat.", + true); + + PropertyDescriptor overtoppingRateCalculatedReliability = dynamicProperties[calculatedReliabilityPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(overtoppingRateCalculatedReliability, + overtoppingRateCategory, + "Betrouwbaarheidsindex berekende kans [-]", + "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", + true); + + PropertyDescriptor overtoppingRateCalculationConvergence = dynamicProperties[convergencePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(overtoppingRateCalculationConvergence, + overtoppingRateCategory, + "Convergentie", + "Is convergentie bereikt in de overslagdebiet berekening?", + true); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj =================================================================== diff -u -r78c98e27e738de793573412374041021a1264758 -rc778f3be881fdcedc6d3bda8d02aa535499e33ac --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 78c98e27e738de793573412374041021a1264758) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision c778f3be881fdcedc6d3bda8d02aa535499e33ac) @@ -78,6 +78,7 @@ +