Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs =================================================================== diff -u -r8d246ac6328e6e649ff6e78dfe3fac210d789ba0 -r6cd47071c8dbb10eb401925acbb067c4be9266d9 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision 8d246ac6328e6e649ff6e78dfe3fac210d789ba0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision 6cd47071c8dbb10eb401925acbb067c4be9266d9) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Core.Common.Base.Data; using Core.Common.TestUtil; using log4net.Core; using NUnit.Framework; @@ -53,7 +54,7 @@ public void Validate_CalculationNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => MacroStabilityInwardsCalculationService.Validate(null); + TestDelegate test = () => MacroStabilityInwardsCalculationService.Validate(null, RoundedDouble.NaN); // Assert var exception = Assert.Throws(test); @@ -67,7 +68,7 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation); + Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -88,7 +89,7 @@ invalidMacroStabilityInwardsCalculation.Output = output; // Call - bool isValid = MacroStabilityInwardsCalculationService.Validate(invalidMacroStabilityInwardsCalculation); + bool isValid = MacroStabilityInwardsCalculationService.Validate(invalidMacroStabilityInwardsCalculation, GetCalculatedTestAssessmentLevel()); // Assert Assert.IsFalse(isValid); @@ -103,7 +104,7 @@ var isValid = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(calculation); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(calculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -130,7 +131,7 @@ calculator.LastCreatedUpliftVanCalculator.ReturnValidationError = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -156,7 +157,7 @@ calculator.LastCreatedUpliftVanCalculator.ReturnValidationWarning = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -183,7 +184,7 @@ calculator.LastCreatedUpliftVanCalculator.ReturnValidationError = true; // Call - Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation); + Action call = () => isValid = MacroStabilityInwardsCalculationService.Validate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -209,7 +210,7 @@ calculatorFactory.LastCreatedUpliftVanCalculator.ThrowExceptionOnValidate = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation); + Action call = () => MacroStabilityInwardsCalculationService.Validate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, tuples => @@ -226,7 +227,7 @@ public void Calculate_CalculationNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => MacroStabilityInwardsCalculationService.Calculate(null); + TestDelegate test = () => MacroStabilityInwardsCalculationService.Calculate(null, RoundedDouble.NaN); // Assert var exception = Assert.Throws(test); @@ -237,15 +238,17 @@ public void Calculate_ValidCalculation_LogStartAndEndOfValidatingInputsAndCalculation() { // Setup + RoundedDouble normativeAssessmentLevel = GetCalculatedTestAssessmentLevel(); + using (new MacroStabilityInwardsCalculatorFactoryConfig()) { Action call = () => { // Precondition - Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation)); + Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation, normativeAssessmentLevel)); // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, normativeAssessmentLevel); }; // Assert @@ -264,17 +267,18 @@ public void Calculate_ValidCalculationWithOutput_ShouldChangeOutput() { // Setup + RoundedDouble normativeAssessmentLevel = GetCalculatedTestAssessmentLevel(); MacroStabilityInwardsOutput output = MacroStabilityInwardsOutputTestFactory.CreateOutput(); testCalculation.Output = output; using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Precondition - Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation)); + Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation, normativeAssessmentLevel)); // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, normativeAssessmentLevel); // Assert Assert.AreNotSame(output, testCalculation.Output); @@ -288,7 +292,7 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert AssertInput(testCalculation.InputParameters, (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance); @@ -308,11 +312,11 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) - .LastCreatedUpliftVanCalculator.Input; + .LastCreatedUpliftVanCalculator.Input; Assert.IsFalse(actualInput.DrainageConstruction.IsPresent); Assert.IsNaN(actualInput.DrainageConstruction.XCoordinate); Assert.IsNaN(actualInput.DrainageConstruction.ZCoordinate); @@ -340,11 +344,11 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) - .LastCreatedUpliftVanCalculator.Input; + .LastCreatedUpliftVanCalculator.Input; Assert.IsTrue(actualInput.PhreaticLineOffsetsExtreme.UseDefaults); Assert.IsNaN(actualInput.PhreaticLineOffsetsExtreme.BelowDikeToeAtPolder); Assert.IsNaN(actualInput.PhreaticLineOffsetsExtreme.BelowDikeTopAtPolder); @@ -385,11 +389,11 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) - .LastCreatedUpliftVanCalculator.Input; + .LastCreatedUpliftVanCalculator.Input; Assert.IsTrue(actualInput.SlipPlane.GridAutomaticDetermined); Assert.IsNull(actualInput.SlipPlane.LeftGrid); Assert.IsNull(actualInput.SlipPlane.RightGrid); @@ -421,11 +425,11 @@ using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert UpliftVanCalculatorInput actualInput = ((TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance) - .LastCreatedUpliftVanCalculator.Input; + .LastCreatedUpliftVanCalculator.Input; Assert.IsTrue(actualInput.SlipPlaneConstraints.AutomaticForbiddenZones); Assert.AreEqual(createZones, actualInput.SlipPlaneConstraints.CreateZones); Assert.IsNaN(actualInput.SlipPlaneConstraints.ZoneBoundaryLeft); @@ -439,15 +443,17 @@ public void Calculate_CalculationRan_SetOutput() { // Setup + RoundedDouble normativeAssessmentLevel = GetCalculatedTestAssessmentLevel(); + using (new MacroStabilityInwardsCalculatorFactoryConfig()) { var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance; // Precondition - Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation)); + Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation, normativeAssessmentLevel)); // Call - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, normativeAssessmentLevel); // Assert AssertOutput(calculatorFactory.LastCreatedUpliftVanCalculator.Output, testCalculation.Output); @@ -458,13 +464,15 @@ public void Calculate_ErrorWhileCalculating_LogErrorMessageAndThrowException() { // Setup + RoundedDouble normativeAssessmentLevel = GetCalculatedTestAssessmentLevel(); + using (new MacroStabilityInwardsCalculatorFactoryConfig()) { var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance; calculatorFactory.LastCreatedUpliftVanCalculator.ThrowExceptionOnCalculate = true; // Precondition - Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation)); + Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation, normativeAssessmentLevel)); var exceptionThrown = false; @@ -473,7 +481,7 @@ { try { - MacroStabilityInwardsCalculationService.Calculate(testCalculation); + MacroStabilityInwardsCalculationService.Calculate(testCalculation, normativeAssessmentLevel); } catch (UpliftVanCalculatorException) { @@ -511,7 +519,7 @@ calculator.LastCreatedUpliftVanCalculator.ReturnCalculationError = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation); + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -535,7 +543,7 @@ calculator.LastCreatedUpliftVanCalculator.ReturnCalculationWarning = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation); + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -564,7 +572,7 @@ calculator.LastCreatedUpliftVanCalculator.ReturnCalculationError = true; // Call - Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation); + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation, GetCalculatedTestAssessmentLevel()); // Assert TestHelper.AssertLogMessages(call, messages => @@ -742,5 +750,10 @@ Assert.AreEqual(expectedGrid.NumberOfHorizontalPoints, actualGrid.NumberOfHorizontalPoints); Assert.AreEqual(expectedGrid.NumberOfVerticalPoints, actualGrid.NumberOfVerticalPoints); } + + private static RoundedDouble GetCalculatedTestAssessmentLevel() + { + return (RoundedDouble) 1.1; + } } } \ No newline at end of file