public void CreateExtremeWaternetForUpliftVan_ValidData_ReturnMacroStabilityInput()
        {
            // Setup
            UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create();

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

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

            // Call
            MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(
                input, soils, surfaceLine, soilProfile);

            // Assert
            CollectionAssert.AreEqual(soils, macroStabilityInput.StabilityModel.Soils, new SoilComparer());
            Assert.AreSame(soilProfile, macroStabilityInput.StabilityModel.ConstructionStages.Single().SoilProfile);

            PreConstructionStage preConstructionStage = macroStabilityInput.PreprocessingInput.PreConstructionStages.Single();

            Assert.AreSame(surfaceLine, preConstructionStage.SurfaceLine);
            Assert.IsTrue(preConstructionStage.CreateWaternet);
            KernelInputAssert.AssertWaternetCreatorInput(UpliftVanWaternetCreatorInputCreator.CreateExtreme(input), preConstructionStage.WaternetCreatorInput);
        }
        public void CreateExtreme_WithInput_ReturnWaternetCreatorInput([Values(true, false)] bool drainageConstructionPresent,
                                                                       [Values(true, false)] bool useDefaultOffsets)
        {
            // Setup
            var random = new Random(21);
            DrainageConstruction drainageConstruction = drainageConstructionPresent
                                                            ? new DrainageConstruction(random.Next(), random.Next())
                                                            : new DrainageConstruction();
            PhreaticLineOffsets phreaticLineOffsets = useDefaultOffsets
                                                          ? new PhreaticLineOffsets()
                                                          : new PhreaticLineOffsets(random.Next(), random.Next(),
                                                                                    random.Next(), random.Next());

            var input = new UpliftVanCalculatorInput(
                new UpliftVanCalculatorInput.ConstructionProperties
            {
                SurfaceLine                             = new MacroStabilityInwardsSurfaceLine("test"),
                SoilProfile                             = new TestSoilProfile(),
                SlipPlane                               = new UpliftVanSlipPlane(),
                DikeSoilScenario                        = MacroStabilityInwardsDikeSoilScenario.SandDikeOnClay,
                AssessmentLevel                         = random.NextDouble(),
                WaterLevelRiverAverage                  = random.NextDouble(),
                WaterLevelPolderExtreme                 = random.NextDouble(),
                DrainageConstruction                    = drainageConstruction,
                PhreaticLineOffsetsExtreme              = phreaticLineOffsets,
                PhreaticLineOffsetsDaily                = new PhreaticLineOffsets(),
                MinimumLevelPhreaticLineAtDikeTopRiver  = random.NextDouble(),
                MinimumLevelPhreaticLineAtDikeTopPolder = random.NextDouble(),
                AdjustPhreaticLine3And4ForUplift        = random.NextBoolean(),
                LeakageLengthOutwardsPhreaticLine3      = random.NextDouble(),
                LeakageLengthInwardsPhreaticLine3       = random.NextDouble(),
                LeakageLengthOutwardsPhreaticLine4      = random.NextDouble(),
                LeakageLengthInwardsPhreaticLine4       = random.NextDouble(),
                PiezometricHeadPhreaticLine2Outwards    = random.NextDouble(),
                PiezometricHeadPhreaticLine2Inwards     = random.NextDouble(),
                PenetrationLengthExtreme                = random.NextDouble()
            });

            // Call
            WaternetCreatorInput waternetCreatorInput = UpliftVanWaternetCreatorInputCreator.CreateExtreme(input);

            // Assert
            Assert.AreEqual(input.AssessmentLevel, waternetCreatorInput.HeadInPlLine3);
            Assert.AreEqual(input.AssessmentLevel, waternetCreatorInput.HeadInPlLine4);
            Assert.AreEqual(input.AssessmentLevel, waternetCreatorInput.WaterLevelRiver);
            Assert.AreEqual(input.WaterLevelPolderExtreme, waternetCreatorInput.WaterLevelPolder);
            Assert.AreEqual(input.PhreaticLineOffsetsExtreme.UseDefaults, waternetCreatorInput.UseDefaultOffsets);
            Assert.AreEqual(input.PhreaticLineOffsetsExtreme.BelowDikeTopAtRiver, waternetCreatorInput.PlLineOffsetBelowPointBRingtoetsWti2017);
            Assert.AreEqual(input.PhreaticLineOffsetsExtreme.BelowDikeTopAtPolder, waternetCreatorInput.PlLineOffsetBelowDikeTopAtPolder);
            Assert.AreEqual(input.PhreaticLineOffsetsExtreme.BelowShoulderBaseInside, waternetCreatorInput.PlLineOffsetBelowShoulderBaseInside);
            Assert.AreEqual(input.PhreaticLineOffsetsExtreme.BelowDikeToeAtPolder, waternetCreatorInput.PlLineOffsetBelowDikeToeAtPolder);
            Assert.AreEqual(input.PenetrationLengthExtreme, waternetCreatorInput.PenetrationLength);

            AssertGeneralWaternetCreatorInputValues(input, waternetCreatorInput);
            AssertIrrelevantValues(waternetCreatorInput);
        }
        public void CreateExtreme_InputNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => UpliftVanWaternetCreatorInputCreator.CreateExtreme(null);

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

            Assert.AreEqual("input", exception.ParamName);
        }
        public void CreateExtreme_ValidDikeSoilScenario_ReturnInputWithDikeSoilScenario(MacroStabilityInwardsDikeSoilScenario macroStabilityInwardsDikeSoilScenario,
                                                                                        DikeSoilScenario expectedDikeSoilScenario)
        {
            // Setup
            var input = new UpliftVanCalculatorInput(
                new UpliftVanCalculatorInput.ConstructionProperties
            {
                DrainageConstruction       = new DrainageConstruction(),
                PhreaticLineOffsetsExtreme = new PhreaticLineOffsets(),
                PhreaticLineOffsetsDaily   = new PhreaticLineOffsets(),
                SurfaceLine      = new MacroStabilityInwardsSurfaceLine("test"),
                SoilProfile      = new TestSoilProfile(),
                SlipPlane        = new UpliftVanSlipPlane(),
                DikeSoilScenario = macroStabilityInwardsDikeSoilScenario
            });

            // Call
            WaternetCreatorInput waternetCreatorInput = UpliftVanWaternetCreatorInputCreator.CreateExtreme(input);

            // Assert
            Assert.AreEqual(expectedDikeSoilScenario, waternetCreatorInput.DikeSoilScenario);
        }
        public void CreateExtreme_InvalidDikeSoilScenario_ThrowInvalidEnumArgumentException()
        {
            // Setup
            var input = new UpliftVanCalculatorInput(
                new UpliftVanCalculatorInput.ConstructionProperties
            {
                SurfaceLine = new MacroStabilityInwardsSurfaceLine("test"),
                SoilProfile = new TestSoilProfile(),
                PhreaticLineOffsetsExtreme = new PhreaticLineOffsets(),
                PhreaticLineOffsetsDaily   = new PhreaticLineOffsets(),
                DrainageConstruction       = new DrainageConstruction(),
                SlipPlane        = new UpliftVanSlipPlane(),
                DikeSoilScenario = (MacroStabilityInwardsDikeSoilScenario)99
            });

            // Call
            void Call() => UpliftVanWaternetCreatorInputCreator.CreateExtreme(input);

            // Assert
            string message = $"The value of argument 'dikeSoilScenario' ({99}) is invalid for Enum type '{nameof(MacroStabilityInwardsDikeSoilScenario)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message);
        }