Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationRowTest.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -ra2ec0ef5dc52d01dc15b281ab5c9c46542e83006 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationRowTest.cs (.../HydraulicBoundaryLocationRowTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/HydraulicBoundaryLocationRowTest.cs (.../HydraulicBoundaryLocationRowTest.cs) (revision a2ec0ef5dc52d01dc15b281ab5c9c46542e83006) @@ -19,9 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Views; namespace Ringtoets.Common.Forms.Test.Views @@ -30,32 +32,88 @@ public class HydraulicBoundaryLocationRowTest { [Test] - public void Constructor_WithHydraulicBoundaryLocationContext_PropertiesFromHydraulicBoundaryLocation() + public void Constructor_HydraulicBoundaryLocationCalculationNull_ThrowsArgumentNullException() { // Setup + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + + // Call + TestDelegate call = () => new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("hydraulicBoundaryLocationCalculation", paramName); + } + + [Test] + public void Constructor_WithHydraulicBoundaryLocation_PropertiesFromHydraulicBoundaryLocation() + { + // Setup const int id = 1; const string locationname = "LocationName"; const double coordinateX = 1.0; const double coordinateY = 2.0; var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, locationname, coordinateX, coordinateY); + var calculation = new HydraulicBoundaryLocationCalculation(); // Call - var row = new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation); + var row = new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation, + calculation); // Assert Assert.IsInstanceOf>(row); Assert.AreEqual(id, row.Id); Assert.AreEqual(locationname, row.Name); var expectedPoint2D = new Point2D(coordinateX, coordinateY); Assert.AreEqual(expectedPoint2D, row.Location); + Assert.IsNaN(row.Result); + Assert.AreSame(hydraulicBoundaryLocation, row.CalculatableObject); Assert.IsFalse(row.ShouldCalculate); } + [Test] + public void IncludeIllustrationPoints_NewValue_SetsProperties( + [Values(true, false)] bool setIllustrationPoints) + { + // Setup + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var calculation = new HydraulicBoundaryLocationCalculation(); + var row = new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation, + calculation); + + // Call + row.IncludeIllustrationPoints = setIllustrationPoints; + + // Assert + Assert.AreEqual(setIllustrationPoints, row.IncludeIllustrationPoints); + Assert.AreEqual(setIllustrationPoints, calculation.InputParameters.ShouldIllustrationPointsBeCalculated); + } + + [Test] + public void Result_WithCalculationOutput_ReturnsResult() + { + // Setup + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var calculation = new HydraulicBoundaryLocationCalculation(); + var row = new TestHydraulicBoundaryLocationRow(hydraulicBoundaryLocation, + calculation); + + var random = new Random(432); + var locationOutput = new TestHydraulicBoundaryLocationOutput(random.NextDouble()); + + // Call + calculation.Output = locationOutput; + + // Assert + Assert.AreEqual(locationOutput.Result, row.Result); + } + private class TestHydraulicBoundaryLocationRow : HydraulicBoundaryLocationRow { - public TestHydraulicBoundaryLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation) - : base(hydraulicBoundaryLocation) {} + public TestHydraulicBoundaryLocationRow(HydraulicBoundaryLocation hydraulicBoundaryLocation, + HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation) + : base(hydraulicBoundaryLocation, hydraulicBoundaryLocationCalculation) {} } } } \ No newline at end of file