Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationProperties.cs =================================================================== diff -u -r397eafbec8987f6aa2e31318745c4e07ed575981 -ra65b035e6c859fc9a6c8e92becb7f9643d18d243 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationProperties.cs (.../DuneLocationProperties.cs) (revision 397eafbec8987f6aa2e31318745c4e07ed575981) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationProperties.cs (.../DuneLocationProperties.cs) (revision a65b035e6c859fc9a6c8e92becb7f9643d18d243) @@ -42,19 +42,28 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class DuneLocationProperties : ObjectProperties { + private readonly DuneLocationCalculation calculation; + /// /// Creates a new instance of . /// - /// The location to create the properties for. - /// Thrown when - /// is null. - public DuneLocationProperties(DuneLocation location) + /// The dune location. + /// The dune location calculation at stake. + /// Thrown when any input parameter is null. + public DuneLocationProperties(DuneLocation location, DuneLocationCalculation calculation) { if (location == null) { throw new ArgumentNullException(nameof(location)); } + if (calculation == null) + { + throw new ArgumentNullException(nameof(calculation)); + } + + this.calculation = calculation; + Data = location; } @@ -123,7 +132,7 @@ { get { - return data.Calculation.Output?.WaterLevel ?? RoundedDouble.NaN; + return calculation.Output?.WaterLevel ?? RoundedDouble.NaN; } } @@ -135,7 +144,7 @@ { get { - return data.Calculation.Output?.WaveHeight ?? RoundedDouble.NaN; + return calculation.Output?.WaveHeight ?? RoundedDouble.NaN; } } @@ -147,7 +156,7 @@ { get { - return data.Calculation.Output?.WavePeriod ?? RoundedDouble.NaN; + return calculation.Output?.WavePeriod ?? RoundedDouble.NaN; } } @@ -171,7 +180,7 @@ { get { - return data.Calculation.Output?.TargetProbability ?? double.NaN; + return calculation.Output?.TargetProbability ?? double.NaN; } } @@ -183,7 +192,7 @@ { get { - return data.Calculation.Output?.TargetReliability ?? RoundedDouble.NaN; + return calculation.Output?.TargetReliability ?? RoundedDouble.NaN; } } @@ -195,7 +204,7 @@ { get { - return data.Calculation.Output?.CalculatedProbability ?? double.NaN; + return calculation.Output?.CalculatedProbability ?? double.NaN; } } @@ -207,7 +216,7 @@ { get { - return data.Calculation.Output?.CalculatedReliability ?? RoundedDouble.NaN; + return calculation.Output?.CalculatedReliability ?? RoundedDouble.NaN; } } @@ -218,7 +227,9 @@ { get { - return new EnumDisplayWrapper(data.CalculationConvergence).DisplayName; + CalculationConvergence convergence = calculation.Output?.CalculationConvergence ?? CalculationConvergence.NotCalculated; + + return new EnumDisplayWrapper(convergence).DisplayName; } } Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs =================================================================== diff -u -ref5144459680cc600c8b6f349fd3774eb4511c24 -ra65b035e6c859fc9a6c8e92becb7f9643d18d243 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs (.../DuneLocationsProperties.cs) (revision ef5144459680cc600c8b6f349fd3774eb4511c24) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/PropertyClasses/DuneLocationsProperties.cs (.../DuneLocationsProperties.cs) (revision a65b035e6c859fc9a6c8e92becb7f9643d18d243) @@ -77,7 +77,7 @@ { get { - return data.Select(loc => new DuneLocationProperties(loc)).ToArray(); + return data.Select(loc => new DuneLocationProperties(loc, loc.Calculation)).ToArray(); } } Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs =================================================================== diff -u -r397eafbec8987f6aa2e31318745c4e07ed575981 -ra65b035e6c859fc9a6c8e92becb7f9643d18d243 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision 397eafbec8987f6aa2e31318745c4e07ed575981) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Plugin/DuneErosionPlugin.cs (.../DuneErosionPlugin.cs) (revision a65b035e6c859fc9a6c8e92becb7f9643d18d243) @@ -67,7 +67,7 @@ yield return new PropertyInfo { - CreateInstance = location => new DuneLocationProperties(location) + CreateInstance = location => new DuneLocationProperties(location, location.Calculation) }; } Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationPropertiesTest.cs =================================================================== diff -u -rb0e228408016f88b94ac63d6896e5bc7668a75c1 -ra65b035e6c859fc9a6c8e92becb7f9643d18d243 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationPropertiesTest.cs (.../DuneLocationPropertiesTest.cs) (revision b0e228408016f88b94ac63d6896e5bc7668a75c1) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/PropertyClasses/DuneLocationPropertiesTest.cs (.../DuneLocationPropertiesTest.cs) (revision a65b035e6c859fc9a6c8e92becb7f9643d18d243) @@ -58,21 +58,33 @@ public void Constructor_DuneLocationNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new DuneLocationProperties(null); + TestDelegate call = () => new DuneLocationProperties(null, new DuneLocationCalculation()); // Assert var exception = Assert.Throws(call); Assert.AreEqual("location", exception.ParamName); } [Test] + public void Constructor_DuneLocationCalculationNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new DuneLocationProperties(new TestDuneLocation(), null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculation", exception.ParamName); + } + + [Test] public void GetProperties_ValidData_ReturnsExpectedValues() { // Setup var duneLocation = new TestDuneLocation(); + var duneLocationCalculation = new DuneLocationCalculation(); // Call - var properties = new DuneLocationProperties(duneLocation); + var properties = new DuneLocationProperties(duneLocation, duneLocationCalculation); // Assert Assert.AreEqual(duneLocation.Id, properties.Id); @@ -138,29 +150,27 @@ CalculatedProbability = calculatedProbability, CalculatedReliability = calculatedReliability }); - var location = new DuneLocation(id, name, new Point2D(x, y), - new DuneLocation.ConstructionProperties - { - CoastalAreaId = coastalAreaId, - Offset = offset, - Orientation = orientation, - D50 = d50 - }) + var duneLocation = new DuneLocation(id, name, new Point2D(x, y), + new DuneLocation.ConstructionProperties + { + CoastalAreaId = coastalAreaId, + Offset = offset, + Orientation = orientation, + D50 = d50 + }); + var duneLocationCalculation = new DuneLocationCalculation { - Calculation = - { - Output = output - } + Output = output }; // Call - var properties = new DuneLocationProperties(location); + var properties = new DuneLocationProperties(duneLocation, duneLocationCalculation); // Assert Assert.AreEqual(id, properties.Id); Assert.AreEqual(name, properties.Name); Assert.AreEqual(coastalAreaId, properties.CoastalAreaId); - Assert.AreEqual(location.Offset.ToString("0.#", CultureInfo.InvariantCulture), properties.Offset); + Assert.AreEqual(duneLocation.Offset.ToString("0.#", CultureInfo.InvariantCulture), properties.Offset); var expectedLocation = new Point2D(x, y); Assert.AreEqual(expectedLocation, properties.Location); @@ -183,9 +193,10 @@ { // Setup var duneLocation = new TestDuneLocation(); + var duneLocationCalculation = new DuneLocationCalculation(); // Call - var properties = new DuneLocationProperties(duneLocation); + var properties = new DuneLocationProperties(duneLocation, duneLocationCalculation); // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); @@ -298,14 +309,15 @@ [TestCase(3.1, "3.1")] public void Offset_Always_FormatToString(double offset, string expectedPropertyValue) { - var location = new DuneLocation(1, "test", new Point2D(0, 0), - new DuneLocation.ConstructionProperties - { - Offset = offset - }); + var duneLocation = new DuneLocation(1, "test", new Point2D(0, 0), + new DuneLocation.ConstructionProperties + { + Offset = offset + }); + var duneLocationCalculation = new DuneLocationCalculation(); // Call - var properties = new DuneLocationProperties(location); + var properties = new DuneLocationProperties(duneLocation, duneLocationCalculation); // Assert Assert.AreEqual(expectedPropertyValue, properties.Offset);