Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs =================================================================== diff -u -re2786bbbad5456a4b42b68e1d0b0f85f732393d7 -ra37adf7a6d10fa2c6a069bc6d423a14c22ead9ea --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision e2786bbbad5456a4b42b68e1d0b0f85f732393d7) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision a37adf7a6d10fa2c6a069bc6d423a14c22ead9ea) @@ -193,24 +193,24 @@ DikeSoilScenario = inputParameters.DikeSoilScenario, WaterLevelRiverAverage = inputParameters.WaterLevelRiverAverage, WaterLevelPolder = inputParameters.WaterLevelPolder, - XCoordinateDrainageConstruction = inputParameters.XCoordinateDrainageConstruction, - ZCoordinateDrainageConstruction = inputParameters.ZCoordinateDrainageConstruction, + DrainageConstructionPresent = inputParameters.DrainageConstructionPresent, + XCoordinateDrainageConstruction = inputParameters.DrainageConstructionPresent ? inputParameters.XCoordinateDrainageConstruction : double.NaN, + ZCoordinateDrainageConstruction = inputParameters.DrainageConstructionPresent ? inputParameters.ZCoordinateDrainageConstruction : double.NaN, MinimumLevelPhreaticLineAtDikeTopRiver = inputParameters.MinimumLevelPhreaticLineAtDikeTopRiver, MinimumLevelPhreaticLineAtDikeTopPolder = inputParameters.MinimumLevelPhreaticLineAtDikeTopPolder, - PhreaticLineOffsetBelowDikeTopAtRiver = inputParameters.PhreaticLineOffsetBelowDikeTopAtRiver, - PhreaticLineOffsetBelowDikeTopAtPolder = inputParameters.PhreaticLineOffsetBelowDikeTopAtPolder, - PhreaticLineOffsetBelowShoulderBaseInside = inputParameters.PhreaticLineOffsetBelowShoulderBaseInside, - PhreaticLineOffsetBelowDikeToeAtPolder = inputParameters.PhreaticLineOffsetBelowDikeToeAtPolder, + UseDefaultOffsets = inputParameters.UseDefaultOffsets, + PhreaticLineOffsetBelowDikeTopAtRiver = !inputParameters.UseDefaultOffsets ? inputParameters.PhreaticLineOffsetBelowDikeTopAtRiver : double.NaN, + PhreaticLineOffsetBelowDikeTopAtPolder = !inputParameters.UseDefaultOffsets ? inputParameters.PhreaticLineOffsetBelowDikeTopAtPolder : double.NaN, + PhreaticLineOffsetBelowShoulderBaseInside = !inputParameters.UseDefaultOffsets ? inputParameters.PhreaticLineOffsetBelowShoulderBaseInside : double.NaN, + PhreaticLineOffsetBelowDikeToeAtPolder = !inputParameters.UseDefaultOffsets ? inputParameters.PhreaticLineOffsetBelowDikeToeAtPolder : double.NaN, LeakageLengthOutwardsPhreaticLine3 = inputParameters.LeakageLengthOutwardsPhreaticLine3, LeakageLengthInwardsPhreaticLine3 = inputParameters.LeakageLengthInwardsPhreaticLine3, LeakageLengthOutwardsPhreaticLine4 = inputParameters.LeakageLengthOutwardsPhreaticLine4, LeakageLengthInwardsPhreaticLine4 = inputParameters.LeakageLengthInwardsPhreaticLine4, PiezometricHeadPhreaticLine2Outwards = inputParameters.PiezometricHeadPhreaticLine2Outwards, PiezometricHeadPhreaticLine2Inwards = inputParameters.PiezometricHeadPhreaticLine2Inwards, PenetrationLength = inputParameters.PenetrationLength, - DrainageConstructionPresent = inputParameters.DrainageConstructionPresent, AdjustPhreaticLine3And4ForUplift = inputParameters.AdjustPhreaticLine3And4ForUplift, - UseDefaultOffsets = inputParameters.UseDefaultOffsets, MoveGrid = inputParameters.MoveGrid, MaximumSliceWidth = inputParameters.MaximumSliceWidth, GridAutomaticDetermined = inputParameters.GridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic, Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs =================================================================== diff -u -re2786bbbad5456a4b42b68e1d0b0f85f732393d7 -ra37adf7a6d10fa2c6a069bc6d423a14c22ead9ea --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision e2786bbbad5456a4b42b68e1d0b0f85f732393d7) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision a37adf7a6d10fa2c6a069bc6d423a14c22ead9ea) @@ -329,6 +329,106 @@ } [Test] + public void Calculate_DrainageConstructionPresentFalse_SetsInputOnCalculator() + { + // Setup + var random = new Random(11); + MacroStabilityInwardsInput inputParameters = testCalculation.InputParameters; + inputParameters.DrainageConstructionPresent = false; + inputParameters.XCoordinateDrainageConstruction = random.NextRoundedDouble(); + inputParameters.ZCoordinateDrainageConstruction = random.NextRoundedDouble(); + + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + MacroStabilityInwardsCalculationService.Calculate(testCalculation); + + // Assert + UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) + .LastCreatedUpliftVanCalculator.Input; + Assert.IsFalse(actualInput.DrainageConstructionPresent); + Assert.IsNaN(actualInput.XCoordinateDrainageConstruction); + Assert.IsNaN(actualInput.ZCoordinateDrainageConstruction); + } + } + + [Test] + public void Calculate_UseDefaultOffsetsTrue_SetsInputOnCalculator() + { + // Setup + var random = new Random(11); + MacroStabilityInwardsInput inputParameters = testCalculation.InputParameters; + inputParameters.UseDefaultOffsets = true; + inputParameters.PhreaticLineOffsetBelowDikeToeAtPolder = random.NextRoundedDouble(); + inputParameters.PhreaticLineOffsetBelowDikeTopAtPolder = random.NextRoundedDouble(); + inputParameters.PhreaticLineOffsetBelowDikeTopAtRiver = random.NextRoundedDouble(); + inputParameters.PhreaticLineOffsetBelowShoulderBaseInside = random.NextRoundedDouble(); + + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + MacroStabilityInwardsCalculationService.Calculate(testCalculation); + + // Assert + UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) + .LastCreatedUpliftVanCalculator.Input; + Assert.IsFalse(actualInput.DrainageConstructionPresent); + Assert.IsNaN(actualInput.PhreaticLineOffsetBelowDikeToeAtPolder); + Assert.IsNaN(actualInput.PhreaticLineOffsetBelowDikeTopAtPolder); + Assert.IsNaN(actualInput.PhreaticLineOffsetBelowDikeTopAtRiver); + Assert.IsNaN(actualInput.PhreaticLineOffsetBelowShoulderBaseInside); + } + } + + [Test] + public void Calculate_GridDeterminationTypeAutomatic_SetsInputOnCalculator() + { + // Setup + var random = new Random(11); + MacroStabilityInwardsInput inputParameters = testCalculation.InputParameters; + inputParameters.GridDeterminationType = MacroStabilityInwardsGridDeterminationType.Automatic; + inputParameters.TangentLineZTop = random.NextRoundedDouble(); + inputParameters.TangentLineZBottom = random.NextRoundedDouble(); + inputParameters.LeftGrid.XLeft = random.NextRoundedDouble(); + inputParameters.LeftGrid.XRight = random.NextRoundedDouble(); + inputParameters.LeftGrid.ZTop = random.NextRoundedDouble(); + inputParameters.LeftGrid.ZBottom = random.NextRoundedDouble(); + inputParameters.LeftGrid.NumberOfHorizontalPoints = random.Next(); + inputParameters.LeftGrid.NumberOfVerticalPoints = random.Next(); + inputParameters.RightGrid.XLeft = random.NextRoundedDouble(); + inputParameters.RightGrid.XRight = random.NextRoundedDouble(); + inputParameters.RightGrid.ZTop = random.NextRoundedDouble(); + inputParameters.RightGrid.ZBottom = random.NextRoundedDouble(); + inputParameters.RightGrid.NumberOfHorizontalPoints = random.Next(); + inputParameters.RightGrid.NumberOfVerticalPoints = random.Next(); + + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + MacroStabilityInwardsCalculationService.Calculate(testCalculation); + + // Assert + UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) + .LastCreatedUpliftVanCalculator.Input; + Assert.IsTrue(actualInput.GridAutomaticDetermined); + Assert.IsNaN(actualInput.TangentLineZTop); + Assert.IsNaN(actualInput.TangentLineZBottom); + Assert.IsNaN(actualInput.LeftGrid.XLeft); + Assert.IsNaN(actualInput.LeftGrid.XRight); + Assert.IsNaN(actualInput.LeftGrid.ZTop); + Assert.IsNaN(actualInput.LeftGrid.ZBottom); + Assert.AreEqual(0, actualInput.LeftGrid.NumberOfHorizontalPoints); + Assert.AreEqual(0, actualInput.LeftGrid.NumberOfVerticalPoints); + Assert.IsNaN(actualInput.RightGrid.XLeft); + Assert.IsNaN(actualInput.RightGrid.XRight); + Assert.IsNaN(actualInput.RightGrid.ZTop); + Assert.IsNaN(actualInput.RightGrid.ZBottom); + Assert.AreEqual(0, actualInput.RightGrid.NumberOfHorizontalPoints); + Assert.AreEqual(0, actualInput.RightGrid.NumberOfVerticalPoints); + } + } + + [Test] public void Calculate_CalculationRan_SetOutput() { // Setup