public void CalculateExtreme_InputNull_ThrowsArgumentNullException() { // Call void Call() => WaternetCalculationService.CalculateExtreme(null, new GeneralMacroStabilityInwardsInput(), RoundedDouble.NaN); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("input", exception.ParamName); }
public void CalculateExtreme_GeneralInputNull_ThrowsArgumentNullException() { // Setup MacroStabilityInwardsInput input = testCalculation.InputParameters; // Call void Call() => WaternetCalculationService.CalculateExtreme(input, null, RoundedDouble.NaN); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("generalInput", exception.ParamName); }
public void CalculateExtreme_CalculationRan_ReturnMacroStabilityInwardsWaternet() { // Setup using (new MacroStabilityInwardsCalculatorFactoryConfig()) { var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance; // Call MacroStabilityInwardsWaternet output = WaternetCalculationService.CalculateExtreme(testCalculation.InputParameters, new GeneralMacroStabilityInwardsInput(), RoundedDouble.NaN); // Assert CalculatorOutputAssert.AssertWaternet(calculatorFactory.LastCreatedWaternetExtremeCalculator.Output, output); } }
public void CalculateExtreme_ErrorInCalculation_ReturnMacroStabilityInwardsWaternet() { // Setup using (new MacroStabilityInwardsCalculatorFactoryConfig()) { var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance; calculatorFactory.LastCreatedWaternetExtremeCalculator.ThrowExceptionOnCalculate = true; // Call MacroStabilityInwardsWaternet output = WaternetCalculationService.CalculateExtreme(testCalculation.InputParameters, new GeneralMacroStabilityInwardsInput(), RoundedDouble.NaN); // Assert Assert.IsNotNull(output); CollectionAssert.IsEmpty(output.PhreaticLines); CollectionAssert.IsEmpty(output.WaternetLines); } }
public void CalculateExtreme_WithInput_SetsInputOnCalculator() { // Setup RoundedDouble assessmentLevel = new Random(21).NextRoundedDouble(); MacroStabilityInwardsInput input = testCalculation.InputParameters; using (new MacroStabilityInwardsCalculatorFactoryConfig()) { // Call WaternetCalculationService.CalculateExtreme(input, new GeneralMacroStabilityInwardsInput(), assessmentLevel); // Assert var factory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance; WaternetCalculatorInput actualInput = factory.LastCreatedWaternetExtremeCalculator.Input; CalculatorInputAssert.AssertExtremeInput(input, actualInput, assessmentLevel); } }
/// <summary> /// Gets the calculated Waternet for extreme circumstances. /// </summary> /// <param name="input">The input to calculate the Waternet for.</param> /// <param name="generalInput">General calculation parameters that are the same across all calculations.</param> /// <param name="assessmentLevel">The assessment level at stake.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> /// <returns>Returns the corresponding derived Waternet value.</returns> public static MacroStabilityInwardsWaternet GetWaternetExtreme(MacroStabilityInwardsInput input, GeneralMacroStabilityInwardsInput generalInput, RoundedDouble assessmentLevel) { if (input == null) { throw new ArgumentNullException(nameof(input)); } if (generalInput == null) { throw new ArgumentNullException(nameof(generalInput)); } return(input.SoilProfileUnderSurfaceLine != null ? WaternetCalculationService.CalculateExtreme(input, generalInput, assessmentLevel) : new MacroStabilityInwardsWaternet(new MacroStabilityInwardsPhreaticLine[0], new MacroStabilityInwardsWaternetLine[0])); }