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);
        }
        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);
        }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }
        /// <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]));
        }