Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightLocationContextProperties.cs =================================================================== diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r057b42b238eac29a114eb9163458021d87382ee2 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightLocationContextProperties.cs (.../WaveHeightLocationContextProperties.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightLocationContextProperties.cs (.../WaveHeightLocationContextProperties.cs) (revision 057b42b238eac29a114eb9163458021d87382ee2) @@ -26,6 +26,7 @@ using Core.Common.Utils; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Integration.Forms.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -65,7 +66,7 @@ } [PropertyOrder(4)] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Result")] [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryDatabase_Location_WaveHeight_DisplayName")] [ResourcesDescription(typeof(Resources), "HydraulicBoundaryDatabase_Location_WaveHeight_Description")] [TypeConverter(typeof(NoValueRoundedDoubleConverter))] @@ -78,14 +79,77 @@ } [PropertyOrder(5)] - [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")] - [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryDatabase_Convergence_DisplayName")] - [ResourcesDescription(typeof(Resources), "HydraulicBoundaryDatabase_Convergence_WaveHeight_Description")] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Result")] + [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryLocationOutput_TargetProbability_DisplayName")] + [ResourcesDescription(typeof(Resources), "HydraulicBoundaryLocationOutput_TargetProbability_Description")] + public string TargetProbability + { + get + { + HydraulicBoundaryLocationOutput output = data.HydraulicBoundaryLocation.WaveHeightOutput; + return ProbabilityFormattingHelper.Format(output != null + ? output.TargetProbability + : double.NaN); + } + } + + [PropertyOrder(6)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Result")] + [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryLocationOutput_TargetReliability_DisplayName")] + [ResourcesDescription(typeof(Resources), "HydraulicBoundaryLocationOutput_TargetReliability_Description")] + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble TargetReliability + { + get + { + HydraulicBoundaryLocationOutput output = data.HydraulicBoundaryLocation.WaveHeightOutput; + return output != null + ? output.TargetReliability + : (RoundedDouble)double.NaN; + } + } + + [PropertyOrder(7)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Result")] + [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryLocationOutput_CalculatedProbability_DisplayName")] + [ResourcesDescription(typeof(Resources), "HydraulicBoundaryLocationOutput_CalculatedProbability_Description")] + public string CalculatedProbability + { + get + { + HydraulicBoundaryLocationOutput output = data.HydraulicBoundaryLocation.WaveHeightOutput; + return ProbabilityFormattingHelper.Format(output != null + ? output.CalculatedProbability + : double.NaN); + } + } + + [PropertyOrder(8)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Result")] + [ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryLocationOutput_CalculatedReliability_DisplayName")] + [ResourcesDescription(typeof(Resources), "HydraulicBoundaryLocationOutput_CalculatedReliability_Description")] + [TypeConverter(typeof(NoValueRoundedDoubleConverter))] + public RoundedDouble CalculatedReliability + { + get + { + HydraulicBoundaryLocationOutput output = data.HydraulicBoundaryLocation.WaveHeightOutput; + return output != null ? output.CalculatedReliability : (RoundedDouble)double.NaN; + } + } + + [PropertyOrder(9)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_Result")] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryDatabase_Convergence_DisplayName")] + [ResourcesDescription(typeof(Resources), "HydraulicBoundaryDatabase_Convergence_DesignWaterLevel_Description")] public string Convergence { get { - return new EnumDisplayWrapper(data.HydraulicBoundaryLocation.WaveHeightCalculationConvergence).DisplayName; + HydraulicBoundaryLocationOutput output = data.HydraulicBoundaryLocation.WaveHeightOutput; + return new EnumDisplayWrapper(output != null + ? output.CalculationConvergence + : CalculationConvergence.NotCalculated).DisplayName; } } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationContextPropertiesTest.cs =================================================================== diff -u -r0981b22c56801334d3f71343f1a861070a404e3e -r057b42b238eac29a114eb9163458021d87382ee2 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationContextPropertiesTest.cs (.../DesignWaterLevelLocationContextPropertiesTest.cs) (revision 0981b22c56801334d3f71343f1a861070a404e3e) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationContextPropertiesTest.cs (.../DesignWaterLevelLocationContextPropertiesTest.cs) (revision 057b42b238eac29a114eb9163458021d87382ee2) @@ -98,16 +98,15 @@ const double y = 890.0; const string name = ""; - double result = random.NextDouble(); double targetProbability = random.NextDouble(); double targetReliability = random.NextDouble(); double calculatedProbability = random.NextDouble(); double calculatedReliability = random.NextDouble(); - RoundedDouble designWaterLevel = (RoundedDouble) result; + double designWaterLevel = random.NextDouble(); - HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, name, x, y) + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, name, x, y) { - DesignWaterLevelOutput = new HydraulicBoundaryLocationOutput(result, targetProbability, + DesignWaterLevelOutput = new HydraulicBoundaryLocationOutput(designWaterLevel, targetProbability, targetReliability, calculatedProbability, calculatedReliability, @@ -122,8 +121,7 @@ }; // Call - DesignWaterLevelLocationContextProperties properties = - new DesignWaterLevelLocationContextProperties + var properties = new DesignWaterLevelLocationContextProperties { Data = new DesignWaterLevelLocationContext(hydraulicBoundaryDatabase, hydraulicBoundaryLocation) }; Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationContextPropertiesTest.cs =================================================================== diff -u -r0981b22c56801334d3f71343f1a861070a404e3e -r057b42b238eac29a114eb9163458021d87382ee2 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationContextPropertiesTest.cs (.../WaveHeightLocationContextPropertiesTest.cs) (revision 0981b22c56801334d3f71343f1a861070a404e3e) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationContextPropertiesTest.cs (.../WaveHeightLocationContextPropertiesTest.cs) (revision 057b42b238eac29a114eb9163458021d87382ee2) @@ -19,15 +19,15 @@ // 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.Data; using Core.Common.Base.Geometry; -using Core.Common.Gui.Attributes; 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.Helpers; using Ringtoets.Integration.Forms.PresentationObjects; using Ringtoets.Integration.Forms.PropertyClasses; @@ -36,6 +36,16 @@ [TestFixture] public class WaveHeightLocationContextPropertiesTest { + private const int idPropertyIndex = 0; + private const int namePropertyIndex = 1; + private const int coordinatesPropertyIndex = 2; + private const int waveHeightPropertyIndex = 3; + private const int targetProbabilityPropertyIndex = 4; + private const int targetReliabilityPropertyIndex = 5; + private const int calculatedProbabilityPropertyIndex = 6; + private const int calculatedReliabilityPropertyIndex = 7; + private const int convergencePropertyIndex = 8; + [Test] public void GetProperties_ValidData_ReturnsExpectedValues() { @@ -61,19 +71,49 @@ Point2D coordinates = new Point2D(x, y); Assert.AreEqual(coordinates, properties.Location); Assert.IsNaN(properties.WaveHeight); + Assert.AreEqual(ProbabilityFormattingHelper.Format(double.NaN), properties.TargetProbability); + Assert.IsNaN(properties.TargetReliability); + Assert.AreEqual(ProbabilityFormattingHelper.Format(double.NaN), properties.CalculatedProbability); + Assert.IsNaN(properties.CalculatedReliability); Assert.AreEqual(string.Empty, properties.Convergence); } [Test] - public void GetProperties_ValidWaveHeight_ReturnsExpectedValues() + [TestCase(CalculationConvergence.CalculatedNotConverged, "Nee")] + [TestCase(CalculationConvergence.CalculatedConverged, "Ja")] + [TestCase(CalculationConvergence.NotCalculated, "")] + public void GetProperties_ValidWaveHeight_ReturnsExpectedValues(CalculationConvergence convergence, + string expectedConvergedText) { // Setup - RoundedDouble waveHeight = (RoundedDouble) 0.123456; - HydraulicBoundaryLocation hydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateWaveHeightCalculated(waveHeight); + var random = new Random(); + const long id = 1234L; + const double x = 567.0; + const double y = 890.0; + const string name = ""; - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); + double targetProbability = random.NextDouble(); + double targetReliability = random.NextDouble(); + double calculatedProbability = random.NextDouble(); + double calculatedReliability = random.NextDouble(); + double waveHeight = random.NextDouble(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, name, x, y) + { + WaveHeightOutput = new HydraulicBoundaryLocationOutput(waveHeight, targetProbability, + targetReliability, + calculatedProbability, + calculatedReliability, + convergence) + }; + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + hydraulicBoundaryLocation + } + }; + // Call var properties = new WaveHeightLocationContextProperties { @@ -85,16 +125,26 @@ Assert.AreEqual(hydraulicBoundaryLocation.Name, properties.Name); Assert.AreEqual(hydraulicBoundaryLocation.Location, properties.Location); Assert.AreEqual(waveHeight, properties.WaveHeight, hydraulicBoundaryLocation.WaveHeight.GetAccuracy()); - Assert.AreEqual(string.Empty, properties.Convergence); + + Assert.AreEqual(ProbabilityFormattingHelper.Format(targetProbability), properties.TargetProbability); + Assert.AreEqual(targetReliability, properties.TargetReliability, properties.TargetReliability.GetAccuracy()); + Assert.AreEqual(ProbabilityFormattingHelper.Format(calculatedProbability), properties.CalculatedProbability); + Assert.AreEqual(calculatedReliability, properties.CalculatedReliability, properties.CalculatedReliability.GetAccuracy()); + Assert.AreEqual(expectedConvergedText, properties.Convergence); } [Test] public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "", 0.0, 0.0); - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); - hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryLocation); + HydraulicBoundaryLocation hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + hydraulicBoundaryLocation + } + }; // Call var properties = new WaveHeightLocationContextProperties @@ -104,67 +154,87 @@ // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); - var dynamicPropertyBag = new DynamicPropertyBag(properties); - const string expectedCategory = "Algemeen"; - const string expectedIdDisplayName = "ID"; - const string expectedNameDisplayName = "Naam"; - const string expectedLocationDisplayName = "Coördinaten [m]"; - const string expectedWaveHeightDisplayName = "Hs [m]"; - const string expectedConvergenceDisplayName = "Convergentie"; - const string expectedIdDescription = "ID van de hydraulische randvoorwaardenlocatie in de database."; - const string expectedNameDescription = "Naam van de hydraulische randvoorwaardenlocatie."; - const string expectedLocationDescription = "Coördinaten van de hydraulische randvoorwaardenlocatie."; - const string expectedWaveHeightDescription = "Berekende golfhoogte."; - const string expectedConvergenceDisplayDescription = "Is convergentie bereikt in de golfhoogte berekening?"; + var propertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); - PropertyDescriptor idProperty = dynamicProperties.Find("Id", false); - PropertyDescriptor nameProperty = dynamicProperties.Find("Name", false); - PropertyDescriptor locationProperty = dynamicProperties.Find("Location", false); - PropertyDescriptor waveHeightProperty = dynamicProperties.Find("WaveHeight", false); - PropertyDescriptor convergenceProperty = dynamicProperties.Find("Convergence", false); + PropertyDescriptorCollection dynamicProperties = propertyBag.GetProperties(new Attribute[] + { + new BrowsableAttribute(true) + }); + Assert.AreEqual(9, dynamicProperties.Count); Assert.IsInstanceOf(classTypeConverter); + PropertyDescriptor idProperty = dynamicProperties[idPropertyIndex]; Assert.IsNotNull(idProperty); - Assert.IsTrue(idProperty.IsReadOnly); - Assert.IsTrue(idProperty.IsBrowsable); - Assert.AreEqual(expectedCategory, idProperty.Category); - Assert.AreEqual(expectedIdDisplayName, idProperty.DisplayName); - Assert.AreEqual(expectedIdDescription, idProperty.Description); - Assert.AreEqual(1, idProperty.Attributes.OfType().First().Order); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(idProperty, + "Algemeen", + "ID", + "ID van de hydraulische randvoorwaardenlocatie in de database.", + true); + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; Assert.IsNotNull(nameProperty); - Assert.IsTrue(nameProperty.IsReadOnly); - Assert.IsTrue(nameProperty.IsBrowsable); - Assert.AreEqual(expectedCategory, nameProperty.Category); - Assert.AreEqual(expectedNameDisplayName, nameProperty.DisplayName); - Assert.AreEqual(expectedNameDescription, nameProperty.Description); - Assert.AreEqual(2, nameProperty.Attributes.OfType().First().Order); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + "Algemeen", + "Naam", + "Naam van de hydraulische randvoorwaardenlocatie.", + true); - Assert.IsNotNull(locationProperty); - Assert.IsTrue(locationProperty.IsReadOnly); - Assert.IsTrue(locationProperty.IsBrowsable); - Assert.AreEqual(expectedCategory, locationProperty.Category); - Assert.AreEqual(expectedLocationDisplayName, locationProperty.DisplayName); - Assert.AreEqual(expectedLocationDescription, locationProperty.Description); - Assert.AreEqual(3, locationProperty.Attributes.OfType().First().Order); + PropertyDescriptor coordinatesProperty = dynamicProperties[coordinatesPropertyIndex]; + Assert.IsNotNull(coordinatesProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(coordinatesProperty, + "Algemeen", + "Coördinaten [m]", + "Coördinaten van de hydraulische randvoorwaardenlocatie.", + true); + PropertyDescriptor waveHeightProperty = dynamicProperties[waveHeightPropertyIndex]; Assert.IsNotNull(waveHeightProperty); - Assert.IsTrue(waveHeightProperty.IsReadOnly); - Assert.IsTrue(waveHeightProperty.IsBrowsable); - Assert.AreEqual(expectedCategory, waveHeightProperty.Category); - Assert.AreEqual(expectedWaveHeightDisplayName, waveHeightProperty.DisplayName); - Assert.AreEqual(expectedWaveHeightDescription, waveHeightProperty.Description); - Assert.AreEqual(4, waveHeightProperty.Attributes.OfType().First().Order); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveHeightProperty, + "Resultaat", + "Hs [m]", + "Berekende golfhoogte.", + true); + PropertyDescriptor targetProbabilityProperty = dynamicProperties[targetProbabilityPropertyIndex]; + Assert.IsNotNull(targetProbabilityProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetProbabilityProperty, + "Resultaat", + "Doelkans [1/jaar]", + "De ingevoerde kans waarvoor het resultaat moet worden berekend.", + true); + + PropertyDescriptor targetReliabilityProperty = dynamicProperties[targetReliabilityPropertyIndex]; + Assert.IsNotNull(targetReliabilityProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(targetReliabilityProperty, + "Resultaat", + "Betrouwbaarheidsindex doelkans [-]", + "Betrouwbaarheidsindex van de ingevoerde kans waarvoor het resultaat moet worden berekend.", + true); + + PropertyDescriptor calculatedProbabilityProperty = dynamicProperties[calculatedProbabilityPropertyIndex]; + Assert.IsNotNull(calculatedProbabilityProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedProbabilityProperty, + "Resultaat", + "Berekende kans [1/jaar]", + "De berekende kans van voorkomen van het berekende resultaat.", + true); + + PropertyDescriptor calculatedReliabilityProperty = dynamicProperties[calculatedReliabilityPropertyIndex]; + Assert.IsNotNull(calculatedReliabilityProperty); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(calculatedReliabilityProperty, + "Resultaat", + "Betrouwbaarheidsindex berekende kans [-]", + "Betrouwbaarheidsindex van de berekende kans van voorkomen van het berekende resultaat.", + true); + + PropertyDescriptor convergenceProperty = dynamicProperties[convergencePropertyIndex]; Assert.IsNotNull(convergenceProperty); - Assert.IsTrue(convergenceProperty.IsReadOnly); - Assert.IsTrue(convergenceProperty.IsBrowsable); - Assert.AreEqual(expectedCategory, convergenceProperty.Category); - Assert.AreEqual(expectedConvergenceDisplayName, convergenceProperty.DisplayName); - Assert.AreEqual(expectedConvergenceDisplayDescription, convergenceProperty.Description); - Assert.AreEqual(5, convergenceProperty.Attributes.OfType().First().Order); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(convergenceProperty, + "Resultaat", + "Convergentie", + "Is convergentie bereikt in de toetspeil berekening?", + true); } } } \ No newline at end of file