Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs =================================================================== diff -u -r0e809897e28ca8673b98ec8abb68b42939a3a647 -r89b30f009f98cbbcb68e89f0c03f464e7dfd1af8 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 0e809897e28ca8673b98ec8abb68b42939a3a647) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 89b30f009f98cbbcb68e89f0c03f464e7dfd1af8) @@ -63,7 +63,7 @@ public void Constructor_FactoryNull_ArgumentNullException() { // Call - var input = new UpliftVanCalculatorInput(CreateSimpleConstructionProperties()); + UpliftVanCalculatorInput input = CreateValidCalculatorInput(); TestDelegate call = () => new UpliftVanCalculator(input, null); // Assert @@ -79,7 +79,7 @@ var factory = mocks.Stub(); mocks.ReplayAll(); - var input = new UpliftVanCalculatorInput(CreateSimpleConstructionProperties()); + UpliftVanCalculatorInput input = CreateValidCalculatorInput(); // Call var calculator = new UpliftVanCalculator(input, factory); @@ -89,34 +89,53 @@ } [Test] - public void Calculate_CompleteValidInput_ReturnsResult() + public void Calculate_CalculatorWithCompleteInput_InputCorrectlySetToKernel() { // Setup - var random = new Random(11); + UpliftVanCalculatorInput input = CreateCompleteCalculatorInput(); + var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); - var input = new UpliftVanCalculatorInput(CreateSimpleConstructionProperties()); + UpliftVanKernelStub upliftVanKernel = testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel; + SetValidKernelOutput(upliftVanKernel); + + // Call + new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); + + // Assert + Assert.AreEqual(input.MoveGrid, upliftVanKernel.MoveGrid); + Assert.AreEqual(input.MaximumSliceWidth, upliftVanKernel.MaximumSliceWidth); + Assert.AreEqual(input.GridAutomaticDetermined, upliftVanKernel.GridAutomaticDetermined); + Assert.AreEqual(input.CreateZones, upliftVanKernel.CreateZones); + Assert.AreEqual(input.AutomaticForbiddenZones, upliftVanKernel.AutomaticForbiddenZones); + Assert.AreEqual(input.SlipPlaneMinimumDepth, upliftVanKernel.SlipPlaneMinimumDepth); + Assert.AreEqual(input.SlipPlaneMinimumLength, upliftVanKernel.SlipPlaneMinimumLength); + + Assert.IsTrue(testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel.Calculated); + } + + [Test] + public void Calculate_KernelWithCompleteOutput_OutputCorrectlySetToCalculator() + { + // Setup + UpliftVanCalculatorInput input = CreateValidCalculatorInput(); var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); + UpliftVanKernelStub upliftVanKernel = testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel; - upliftVanKernel.FactorOfStability = random.NextDouble(); - upliftVanKernel.ZValue = random.NextDouble(); - upliftVanKernel.ForbiddenZonesXEntryMax = random.NextDouble(); - upliftVanKernel.ForbiddenZonesXEntryMin = random.NextDouble(); - upliftVanKernel.SlidingCurveResult = SlidingDualCircleTestFactory.Create(); - upliftVanKernel.SlipPlaneResult = SlipPlaneUpliftVanTestFactory.Create(); + SetCompleteKernelOutput(upliftVanKernel); // Call - UpliftVanCalculatorResult actual = new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); + UpliftVanCalculatorResult result = new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); // Assert - Assert.IsNotNull(actual); - Assert.AreEqual(upliftVanKernel.FactorOfStability, actual.FactorOfStability); - Assert.AreEqual(upliftVanKernel.ZValue, actual.ZValue); - Assert.AreEqual(upliftVanKernel.ForbiddenZonesXEntryMax, actual.ForbiddenZonesXEntryMax); - Assert.AreEqual(upliftVanKernel.ForbiddenZonesXEntryMin, actual.ForbiddenZonesXEntryMin); + Assert.IsNotNull(result); + Assert.AreEqual(upliftVanKernel.FactorOfStability, result.FactorOfStability); + Assert.AreEqual(upliftVanKernel.ZValue, result.ZValue); + Assert.AreEqual(upliftVanKernel.ForbiddenZonesXEntryMax, result.ForbiddenZonesXEntryMax); + Assert.AreEqual(upliftVanKernel.ForbiddenZonesXEntryMin, result.ForbiddenZonesXEntryMin); UpliftVanCalculatorResultHelper.AssertSlidingCurve(UpliftVanSlidingCurveResultCreator.Create(upliftVanKernel.SlidingCurveResult), - actual.SlidingCurveResult); + result.SlidingCurveResult); UpliftVanCalculatorResultHelper.AssertSlipPlaneGrid(UpliftVanCalculationGridResultCreator.Create(upliftVanKernel.SlipPlaneResult), - actual.CalculationGridResult); + result.CalculationGridResult); Assert.IsTrue(testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel.Calculated); } @@ -125,7 +144,7 @@ public void Validate_Always_ReturnEmptyList() { // Setup - var input = new UpliftVanCalculatorInput(CreateSimpleConstructionProperties()); + UpliftVanCalculatorInput input = CreateValidCalculatorInput(); var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); // Call @@ -135,21 +154,68 @@ CollectionAssert.IsEmpty(validationResult); } - private static UpliftVanCalculatorInput.ConstructionProperties CreateSimpleConstructionProperties() + private static UpliftVanCalculatorInput CreateValidCalculatorInput() { var random = new Random(21); MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine(); - return new UpliftVanCalculatorInput.ConstructionProperties + return new UpliftVanCalculatorInput(new UpliftVanCalculatorInput.ConstructionProperties { AssessmentLevel = random.NextDouble(), SurfaceLine = surfaceLine, SoilProfile = CreateValidSoilProfile(surfaceLine), LeftGrid = new MacroStabilityInwardsGrid(), RightGrid = new MacroStabilityInwardsGrid() - }; + }); } + private static UpliftVanCalculatorInput CreateCompleteCalculatorInput() + { + var random = new Random(21); + + MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine(); + + return new UpliftVanCalculatorInput(new UpliftVanCalculatorInput.ConstructionProperties + { + AssessmentLevel = random.NextDouble(), + SurfaceLine = surfaceLine, + SoilProfile = CreateValidSoilProfile(surfaceLine), + WaterLevelRiverAverage = random.Next(), + WaterLevelPolder = random.Next(), + XCoordinateDrainageConstruction = random.Next(), + ZCoordinateDrainageConstruction = random.Next(), + MinimumLevelPhreaticLineAtDikeTopRiver = random.Next(), + MinimumLevelPhreaticLineAtDikeTopPolder = random.Next(), + PhreaticLineOffsetBelowDikeTopAtRiver = random.Next(), + PhreaticLineOffsetBelowDikeTopAtPolder = random.Next(), + PhreaticLineOffsetBelowShoulderBaseInside = random.Next(), + PhreaticLineOffsetBelowDikeToeAtPolder = random.Next(), + LeakageLengthOutwardsPhreaticLine3 = random.Next(), + LeakageLengthInwardsPhreaticLine3 = random.Next(), + LeakageLengthOutwardsPhreaticLine4 = random.Next(), + LeakageLengthInwardsPhreaticLine4 = random.Next(), + PiezometricHeadPhreaticLine2Outwards = random.Next(), + PiezometricHeadPhreaticLine2Inwards = random.Next(), + PenetrationLength = random.Next(), + UseDefaultOffsets = random.NextBoolean(), + AdjustPhreaticLine3And4ForUplift = random.NextBoolean(), + DrainageConstructionPresent = random.NextBoolean(), + DikeSoilScenario = random.NextEnumValue(), + MoveGrid = random.NextBoolean(), + MaximumSliceWidth = random.Next(), + GridAutomaticDetermined = random.NextBoolean(), + LeftGrid = new MacroStabilityInwardsGrid(), + RightGrid = new MacroStabilityInwardsGrid(), + TangentLineAutomaticAtBoundaries = random.NextBoolean(), + TangentLineZTop = random.Next(), + TangentLineZBottom = random.Next(), + CreateZones = random.NextBoolean(), + AutomaticForbiddenZones = random.NextBoolean(), + SlipPlaneMinimumDepth = random.Next(), + SlipPlaneMinimumLength = random.Next() + }); + } + private static MacroStabilityInwardsSoilProfileUnderSurfaceLine CreateValidSoilProfile(MacroStabilityInwardsSurfaceLine surfaceLine) { return new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] @@ -191,5 +257,23 @@ }); return surfaceLine; } + + private static void SetValidKernelOutput(UpliftVanKernelStub upliftVanKernel) + { + upliftVanKernel.SlidingCurveResult = SlidingDualCircleTestFactory.Create(); + upliftVanKernel.SlipPlaneResult = SlipPlaneUpliftVanTestFactory.Create(); + } + + private static void SetCompleteKernelOutput(UpliftVanKernelStub upliftVanKernel) + { + var random = new Random(11); + + upliftVanKernel.FactorOfStability = random.NextDouble(); + upliftVanKernel.ZValue = random.NextDouble(); + upliftVanKernel.ForbiddenZonesXEntryMax = random.NextDouble(); + upliftVanKernel.ForbiddenZonesXEntryMin = random.NextDouble(); + upliftVanKernel.SlidingCurveResult = SlidingDualCircleTestFactory.Create(); + upliftVanKernel.SlipPlaneResult = SlipPlaneUpliftVanTestFactory.Create(); + } } } \ No newline at end of file