public void Create_UpliftVanSlipPlaneConstraintsNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => SlipPlaneConstraintsCreator.Create(null);

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

            Assert.AreEqual("input", exception.ParamName);
        }
        public void Create_WithUpliftVanSlipPlaneConstraints_ReturnsExpectedSlipPlaneConstraints()
        {
            // Setup
            var random = new Random(39);
            var upliftVanSlipPlaneConstraints = new UpliftVanSlipPlaneConstraints(random.NextDouble(), random.NextDouble(),
                                                                                  random.NextDouble(), random.NextDouble());

            // Call
            SlipPlaneConstraints slipPlaneConstraints = SlipPlaneConstraintsCreator.Create(upliftVanSlipPlaneConstraints);

            // Assert
            Assert.AreEqual(upliftVanSlipPlaneConstraints.SlipPlaneMinimumDepth, slipPlaneConstraints.SlipPlaneMinDepth);
            Assert.AreEqual(upliftVanSlipPlaneConstraints.SlipPlaneMinimumLength, slipPlaneConstraints.SlipPlaneMinLength);
            Assert.AreEqual(upliftVanSlipPlaneConstraints.ZoneBoundaryLeft, slipPlaneConstraints.XEntryMin);
            Assert.AreEqual(upliftVanSlipPlaneConstraints.ZoneBoundaryRight, slipPlaneConstraints.XEntryMax);
            Assert.IsNaN(slipPlaneConstraints.XExitMin); // Irrelevant
            Assert.IsNaN(slipPlaneConstraints.XExitMax); // Irrelevant
        }
        public void CreateUpliftVan_ValidData_ReturnMacroStabilityInput()
        {
            // Setup
            UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create();

            LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup);
            List <Soil>     soils          = layersWithSoil.Select(lws => lws.Soil).ToList();

            SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine);
            SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil);

            var dailyWaternet   = new Waternet();
            var extremeWaternet = new Waternet();

            // Call
            MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateUpliftVan(
                input, soils, layerLookup, surfaceLine, soilProfile, dailyWaternet, extremeWaternet);

            // Assert
            StabilityInput stabilityModel = macroStabilityInput.StabilityModel;

            Assert.AreEqual(Orientation.Inwards, stabilityModel.Orientation);
            Assert.AreEqual(SearchAlgorithm.Grid, stabilityModel.SearchAlgorithm);
            Assert.AreEqual(StabilityModelOptionType.UpliftVan, stabilityModel.ModelOption);

            CollectionAssert.AreEqual(soils, stabilityModel.Soils, new SoilComparer());
            Assert.AreEqual(input.MoveGrid, stabilityModel.MoveGrid);
            Assert.AreEqual(input.MaximumSliceWidth, stabilityModel.MaximumSliceWidth);

            UpliftVanKernelInputAssert.AssertUpliftVanCalculationGrid(
                UpliftVanCalculationGridCreator.Create(input.SlipPlane), stabilityModel.UpliftVanCalculationGrid);

            UpliftVanKernelInputAssert.AssertSlipPlaneConstraints(
                SlipPlaneConstraintsCreator.Create(input.SlipPlaneConstraints), stabilityModel.SlipPlaneConstraints);

            AssertConstructionStages(input, stabilityModel, soilProfile, dailyWaternet, extremeWaternet, layerLookup);

            Assert.AreEqual(input.SlipPlane.GridNumberOfRefinements, stabilityModel.NumberOfRefinementsGrid);
            Assert.AreEqual(input.SlipPlane.TangentLineNumberOfRefinements, stabilityModel.NumberOfRefinementsTangentLines);

            SearchAreaConditions searchAreaConditions = macroStabilityInput.PreprocessingInput.SearchAreaConditions;

            Assert.AreEqual(0.8, searchAreaConditions.MaxSpacingBetweenBoundaries);
            Assert.IsTrue(searchAreaConditions.OnlyAbovePleistoceen);
            Assert.AreEqual(input.SlipPlane.GridAutomaticDetermined, searchAreaConditions.AutoSearchArea);
            Assert.AreEqual(input.SlipPlane.TangentLinesAutomaticAtBoundaries, searchAreaConditions.AutoTangentLines);
            Assert.AreEqual(1, searchAreaConditions.TangentLineNumber);
            Assert.AreEqual(0, searchAreaConditions.TangentLineZTop);
            Assert.AreEqual(0, searchAreaConditions.TangentLineZBottom);
            Assert.AreEqual(input.SlipPlaneConstraints.AutomaticForbiddenZones, searchAreaConditions.AutomaticForbiddenZones);

            Assert.AreEqual(2, macroStabilityInput.PreprocessingInput.PreConstructionStages.Count);

            foreach (PreConstructionStage preConstructionStage in macroStabilityInput.PreprocessingInput.PreConstructionStages)
            {
                Assert.IsFalse(preConstructionStage.CreateWaternet);
                Assert.AreSame(surfaceLine, preConstructionStage.SurfaceLine);
                Assert.IsNull(preConstructionStage.WaternetCreatorInput); // Not needed as Waternet is already calculated
            }

            AssertIrrelevantValues(stabilityModel, searchAreaConditions);
        }