Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresDataSynchronizationServiceTest.cs =================================================================== diff -u -rc537cb34ea1958407d7713522b548a62b1796aa1 -r1051f838aebbd5977351542027ce6330583b0d43 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresDataSynchronizationServiceTest.cs (.../HeightStructuresDataSynchronizationServiceTest.cs) (revision c537cb34ea1958407d7713522b548a62b1796aa1) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Service.Test/HeightStructuresDataSynchronizationServiceTest.cs (.../HeightStructuresDataSynchronizationServiceTest.cs) (revision 1051f838aebbd5977351542027ce6330583b0d43) @@ -19,10 +19,12 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Linq; using NUnit.Framework; using Ringtoets.Common.Data.Probability; using Ringtoets.HeightStructures.Data; +using Ringtoets.HydraRing.Data; namespace Ringtoets.HeightStructures.Service.Test { @@ -56,5 +58,68 @@ Assert.IsNull(calculation.Output); } } + + [Test] + public void ClearCalculationOutput_CalculationNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => HeightStructuresDataSynchronizationService.ClearCalculationOutput(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("calculation", exception.ParamName); + } + + [Test] + public void ClearCalculationOutput_WithCalculation_ClearsOutput() + { + // Setup + HeightStructuresCalculation calculation = new HeightStructuresCalculation + { + Output = new ProbabilityAssessmentOutput(0, 0, 0, 0, 0) + }; + + // Call + HeightStructuresDataSynchronizationService.ClearCalculationOutput(calculation); + + // Assert + Assert.IsNull(calculation.Output); + } + + [Test] + public void ClearHydraulicBoundaryLocations_WithHydraulicBoundaryLocation_ClearsHydraulicBoundaryLocation() + { + // Setup + HeightStructuresFailureMechanism failureMechanism = new HeightStructuresFailureMechanism(); + HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0); + + HeightStructuresCalculation calculation1 = new HeightStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation + } + }; + + HeightStructuresCalculation calculation2 = new HeightStructuresCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation + } + }; + + failureMechanism.CalculationsGroup.Children.Add(calculation1); + failureMechanism.CalculationsGroup.Children.Add(calculation2); + + // Call + HeightStructuresDataSynchronizationService.ClearHydraulicBoundaryLocations(failureMechanism); + + // Assert + foreach (HeightStructuresCalculation calculation in failureMechanism.CalculationsGroup.Children.Cast()) + { + Assert.IsNull(calculation.InputParameters.HydraulicBoundaryLocation); + } + } } } \ No newline at end of file