コード例 #1
0
        public void CalculateDaily_InputNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => WaternetCalculationService.CalculateDaily(null, new GeneralMacroStabilityInwardsInput());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("input", exception.ParamName);
        }
コード例 #2
0
        public void CalculateDaily_GeneralInputNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsInput input = testCalculation.InputParameters;

            // Call
            void Call() => WaternetCalculationService.CalculateDaily(input, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("generalInput", exception.ParamName);
        }
コード例 #3
0
        public void CalculateDaily_CalculationRan_ReturnMacroStabilityInwardsWaternet()
        {
            // Setup
            using (new MacroStabilityInwardsCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance;

                // Call
                MacroStabilityInwardsWaternet output = WaternetCalculationService.CalculateDaily(testCalculation.InputParameters, new GeneralMacroStabilityInwardsInput());

                // Assert
                CalculatorOutputAssert.AssertWaternet(calculatorFactory.LastCreatedWaternetDailyCalculator.Output, output);
            }
        }
コード例 #4
0
        public void CalculateDaily_ErrorInCalculation_ReturnMacroStabilityInwardsWaternet()
        {
            // Setup
            using (new MacroStabilityInwardsCalculatorFactoryConfig())
            {
                var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance;
                calculatorFactory.LastCreatedWaternetDailyCalculator.ThrowExceptionOnCalculate = true;

                // Call
                MacroStabilityInwardsWaternet output = WaternetCalculationService.CalculateDaily(testCalculation.InputParameters, new GeneralMacroStabilityInwardsInput());

                // Assert
                Assert.IsNotNull(output);
                CollectionAssert.IsEmpty(output.PhreaticLines);
                CollectionAssert.IsEmpty(output.WaternetLines);
            }
        }
コード例 #5
0
        public void CalculateDaily_WithInput_SetsInputOnCalculator()
        {
            // Setup
            MacroStabilityInwardsInput input = testCalculation.InputParameters;

            using (new MacroStabilityInwardsCalculatorFactoryConfig())
            {
                // Call
                WaternetCalculationService.CalculateDaily(input, new GeneralMacroStabilityInwardsInput());

                // Assert
                var factory = (TestMacroStabilityInwardsCalculatorFactory)MacroStabilityInwardsCalculatorFactory.Instance;
                WaternetCalculatorInput actualInput = factory.LastCreatedWaternetDailyCalculator.Input;

                CalculatorInputAssert.AssertDailyInput(input, actualInput);
            }
        }
コード例 #6
0
        /// <summary>
        /// Gets the calculated Waternet for daily 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>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        /// <returns>Returns the corresponding derived Waternet value.</returns>
        public static MacroStabilityInwardsWaternet GetWaternetDaily(MacroStabilityInwardsInput input,
                                                                     GeneralMacroStabilityInwardsInput generalInput)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (generalInput == null)
            {
                throw new ArgumentNullException(nameof(generalInput));
            }

            return(input.SoilProfileUnderSurfaceLine != null
                       ? WaternetCalculationService.CalculateDaily(input, generalInput)
                       : new MacroStabilityInwardsWaternet(new MacroStabilityInwardsPhreaticLine[0],
                                                           new MacroStabilityInwardsWaternetLine[0]));
        }