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 CreateDaily_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(),
                WaterLevelPolderDaily                   = random.NextDouble(),
                DrainageConstruction                    = drainageConstruction,
                PhreaticLineOffsetsExtreme              = new PhreaticLineOffsets(),
                PhreaticLineOffsetsDaily                = 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(),
                PenetrationLengthDaily                  = random.NextDouble()
            });

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

            // Assert
            Assert.AreEqual(input.WaterLevelRiverAverage, waternetCreatorInput.HeadInPlLine3);
            Assert.AreEqual(input.WaterLevelRiverAverage, waternetCreatorInput.HeadInPlLine4);
            Assert.AreEqual(input.WaterLevelRiverAverage, waternetCreatorInput.WaterLevelRiver);
            Assert.AreEqual(input.WaterLevelPolderDaily, waternetCreatorInput.WaterLevelPolder);
            Assert.AreEqual(input.PhreaticLineOffsetsDaily.UseDefaults, waternetCreatorInput.UseDefaultOffsets);
            Assert.AreEqual(input.PhreaticLineOffsetsDaily.BelowDikeTopAtRiver, waternetCreatorInput.PlLineOffsetBelowPointBRingtoetsWti2017);
            Assert.AreEqual(input.PhreaticLineOffsetsDaily.BelowDikeTopAtPolder, waternetCreatorInput.PlLineOffsetBelowDikeTopAtPolder);
            Assert.AreEqual(input.PhreaticLineOffsetsDaily.BelowShoulderBaseInside, waternetCreatorInput.PlLineOffsetBelowShoulderBaseInside);
            Assert.AreEqual(input.PhreaticLineOffsetsDaily.BelowDikeToeAtPolder, waternetCreatorInput.PlLineOffsetBelowDikeToeAtPolder);
            Assert.AreEqual(input.PenetrationLengthDaily, 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);
        }