Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs =================================================================== diff -u -r5c7faf8283e49113a2c7b9e17086148a99f13d2e -rc22b1f3b27e7a10c0f75bd8c7ee3d99a13ba8bc6 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision 5c7faf8283e49113a2c7b9e17086148a99f13d2e) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision c22b1f3b27e7a10c0f75bd8c7ee3d99a13ba8bc6) @@ -26,6 +26,7 @@ using Core.Common.TestUtil; using log4net.Core; using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.TestUtil; using Ringtoets.MacroStabilityInwards.CalculatedInput.TestUtil; using Ringtoets.MacroStabilityInwards.Data; @@ -47,7 +48,7 @@ [SetUp] public void Setup() { - testCalculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(); + testCalculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation()); } [Test] @@ -68,7 +69,8 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -89,7 +91,8 @@ invalidMacroStabilityInwardsCalculation.Output = output; // Call - bool isValid = MacroStabilityInwardsCalculationService.Validate(invalidMacroStabilityInwardsCalculation, GetTestNormativeAssessmentLevel()); + bool isValid = MacroStabilityInwardsCalculationService.Validate(invalidMacroStabilityInwardsCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert Assert.IsFalse(isValid); @@ -104,7 +107,8 @@ var isValid = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(calculation, GetTestNormativeAssessmentLevel()); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(calculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -131,7 +135,8 @@ calculator.LastCreatedUpliftVanCalculator.ReturnValidationError = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -157,7 +162,8 @@ calculator.LastCreatedUpliftVanCalculator.ReturnValidationWarning = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -184,7 +190,8 @@ calculator.LastCreatedUpliftVanCalculator.ReturnValidationError = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -210,7 +217,8 @@ calculatorFactory.LastCreatedUpliftVanCalculator.ThrowExceptionOnValidate = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, tuples => @@ -238,7 +246,7 @@ public void Calculate_ValidCalculation_LogStartAndEndOfValidatingInputsAndCalculation() { // Setup - RoundedDouble normativeAssessmentLevel = GetTestNormativeAssessmentLevel(); + RoundedDouble normativeAssessmentLevel = AssessmentSectionHelper.GetTestNormativeAssessmentLevel(); using (new MacroStabilityInwardsCalculatorFactoryConfig()) { @@ -267,7 +275,7 @@ public void Calculate_ValidCalculationWithOutput_ShouldChangeOutput() { // Setup - RoundedDouble normativeAssessmentLevel = GetTestNormativeAssessmentLevel(); + RoundedDouble normativeAssessmentLevel = AssessmentSectionHelper.GetTestNormativeAssessmentLevel(); MacroStabilityInwardsOutput output = MacroStabilityInwardsOutputTestFactory.CreateOutput(); testCalculation.Output = output; @@ -285,31 +293,6 @@ } } - [TestCase(true)] - [TestCase(false)] - public void Calculate_CompleteInput_SetsInputOnCalculator(bool useAssessmentLevelManualInput) - { - // Setup - RoundedDouble normativeAssessmentLevel = GetTestNormativeAssessmentLevel(); - MacroStabilityInwardsInput input = testCalculation.InputParameters; - - input.AssessmentLevel = (RoundedDouble) 2.2; - - input.UseAssessmentLevelManualInput = useAssessmentLevelManualInput; - using (new MacroStabilityInwardsCalculatorFactoryConfig()) - { - // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation, normativeAssessmentLevel); - - // Assert - RoundedDouble expectedAssessmentLevel = useAssessmentLevelManualInput - ? testCalculation.InputParameters.AssessmentLevel - : normativeAssessmentLevel; - - AssertInput(testCalculation.InputParameters, (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance, expectedAssessmentLevel); - } - } - [Test] public void Calculate_DrainageConstructionPresentFalse_SetsInputOnCalculator() { @@ -323,7 +306,8 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) @@ -355,7 +339,8 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) @@ -400,7 +385,8 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) @@ -436,7 +422,8 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) @@ -454,7 +441,7 @@ public void Calculate_CalculationRan_SetOutput() { // Setup - RoundedDouble normativeAssessmentLevel = GetTestNormativeAssessmentLevel(); + RoundedDouble normativeAssessmentLevel = AssessmentSectionHelper.GetTestNormativeAssessmentLevel(); using (new MacroStabilityInwardsCalculatorFactoryConfig()) { @@ -475,7 +462,7 @@ public void Calculate_ErrorWhileCalculating_LogErrorMessageAndThrowException() { // Setup - RoundedDouble normativeAssessmentLevel = GetTestNormativeAssessmentLevel(); + RoundedDouble normativeAssessmentLevel = AssessmentSectionHelper.GetTestNormativeAssessmentLevel(); using (new MacroStabilityInwardsCalculatorFactoryConfig()) { @@ -530,7 +517,8 @@ calculator.LastCreatedUpliftVanCalculator.ReturnCalculationError = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -554,7 +542,8 @@ calculator.LastCreatedUpliftVanCalculator.ReturnCalculationWarning = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -583,7 +572,8 @@ calculator.LastCreatedUpliftVanCalculator.ReturnCalculationError = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetTestNormativeAssessmentLevel()); + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, + AssessmentSectionHelper.GetTestNormativeAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -602,6 +592,31 @@ } } + [TestCase(true)] + [TestCase(false)] + public void Calculate_CompleteInput_SetsInputOnCalculator(bool useAssessmentLevelManualInput) + { + // Setup + RoundedDouble normativeAssessmentLevel = AssessmentSectionHelper.GetTestNormativeAssessmentLevel(); + MacroStabilityInwardsInput input = testCalculation.InputParameters; + + input.AssessmentLevel = (RoundedDouble) 2.2; + + input.UseAssessmentLevelManualInput = useAssessmentLevelManualInput; + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + MacroStabilityInwardsCalculationService.Calculate(testCalculation, normativeAssessmentLevel); + + // Assert + RoundedDouble expectedAssessmentLevel = useAssessmentLevelManualInput + ? testCalculation.InputParameters.AssessmentLevel + : normativeAssessmentLevel; + + AssertInput(testCalculation.InputParameters, (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance, expectedAssessmentLevel); + } + } + private static void AssertInput(MacroStabilityInwardsInput originalInput, TestMacroStabilityInwardsCalculatorFactory factory, RoundedDouble expectedAssessmentLevel) { UpliftVanCalculatorInput actualInput = factory.LastCreatedUpliftVanCalculator.Input; @@ -761,10 +776,5 @@ Assert.AreEqual(expectedGrid.NumberOfHorizontalPoints, actualGrid.NumberOfHorizontalPoints); Assert.AreEqual(expectedGrid.NumberOfVerticalPoints, actualGrid.NumberOfVerticalPoints); } - - private static RoundedDouble GetTestNormativeAssessmentLevel() - { - return (RoundedDouble) 1.1; - } } } \ No newline at end of file