Esempio n. 1
0
        public void Create_SoilProfileWithMultiplePreconsolidationStressesOnOneLayer_ReturnsPersistableStates()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(
                new TestHydraulicBoundaryLocation());

            calculation.InputParameters.StochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1)),
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 2))
            });

            IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile = calculation.InputParameters.SoilProfileUnderSurfaceLine;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableState> states = PersistableStateFactory.Create(soilProfile, idFactory, registry);

            // Assert
            Assert.AreEqual(1, states.Count());

            PersistableState state = states.First();

            Assert.IsNotNull(state.Id);
            CollectionAssert.IsEmpty(state.StateLines);
            CollectionAssert.IsEmpty(state.StatePoints);
        }
Esempio n. 2
0
        public void Create_WithWaternetsWithoutLines_ReturnsPersistableWaternetCollection()
        {
            // Setup
            var dailyWaternet   = new MacroStabilityInwardsWaternet(new MacroStabilityInwardsPhreaticLine[0], new MacroStabilityInwardsWaternetLine[0]);
            var extremeWaternet = new MacroStabilityInwardsWaternet(new MacroStabilityInwardsPhreaticLine[0], new MacroStabilityInwardsWaternetLine[0]);

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            // Call
            IEnumerable <PersistableWaternet> persistableWaternets = PersistableWaternetFactory.Create(dailyWaternet, extremeWaternet, new GeneralMacroStabilityInwardsInput(), idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertWaternets(new[]
            {
                dailyWaternet,
                extremeWaternet
            }, persistableWaternets);

            var stages = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            Assert.AreEqual(2, registry.Waternets.Count);

            for (var i = 0; i < stages.Length; i++)
            {
                Assert.AreEqual(registry.Waternets[stages[i]], persistableWaternets.ElementAt(i).Id);
            }
        }
        public void Create_WithSoilProfile_ReturnsPersistableSoilCollection(MacroStabilityInwardsShearStrengthModel shearStrengthModel)
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[]
                {
                    MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
                })
            },
                Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());

            var registry = new MacroStabilityInwardsExportRegistry();

            IEnumerable <MacroStabilityInwardsSoilLayer2D> originalLayers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers);

            originalLayers.ForEachElementDo(layer => layer.Data.ShearStrengthModel = shearStrengthModel);

            // Call
            PersistableSoilCollection soilCollection = PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry);

            // Assert
            IEnumerable <PersistableSoil> actualSoils = soilCollection.Soils;

            PersistableDataModelTestHelper.AssertPersistableSoils(originalLayers, actualSoils);

            Assert.AreEqual(actualSoils.Count(), registry.Soils.Count);
            for (var i = 0; i < originalLayers.Count(); i++)
            {
                KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registrySoil = registry.Soils.ElementAt(i);
                Assert.AreSame(originalLayers.ElementAt(i), registrySoil.Key);
                Assert.AreEqual(actualSoils.ElementAt(i).Id, registrySoil.Value);
            }
        }
Esempio n. 4
0
        public void Create_WithValidData_ReturnsPersistableCalculationSettingsCollection()
        {
            // Setup
            MacroStabilityInwardsSlidingCurve slidingCurve = MacroStabilityInwardsOutputTestFactory.CreateOutput().SlidingCurve;
            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            // Call
            IEnumerable <PersistableCalculationSettings> settingsCollection = PersistableCalculationSettingsFactory.Create(slidingCurve, idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertCalculationSettings(slidingCurve, settingsCollection);

            var stages = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            Assert.AreEqual(2, registry.Settings.Count);

            for (var i = 0; i < stages.Length; i++)
            {
                Assert.AreEqual(registry.Settings[stages[i]], settingsCollection.ElementAt(i).Id);
            }
        }
        public void Create_WithValidData_ReturnsPersistableWaternetCreatorSettingsCollection()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(
                new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsInput input = calculation.InputParameters;

            RoundedDouble normativeAssessmentLevel = RoundedDouble.NaN;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(input.SoilProfileUnderSurfaceLine, idFactory, registry);

            // Call
            IEnumerable <PersistableWaternetCreatorSettings> waternetCreatorSettingsCollection = PersistableWaternetCreatorSettingsFactory.Create(input, normativeAssessmentLevel,
                                                                                                                                                  idFactory, registry);

            // Assert
            var stages = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            PersistableDataModelTestHelper.AssertWaternetCreatorSettings(input, waternetCreatorSettingsCollection, normativeAssessmentLevel, stages);
            AssertRegistry(registry, stages, waternetCreatorSettingsCollection);
        }
        private static void AssertRegistry(MacroStabilityInwardsExportRegistry registry, IEnumerable <PersistableGeometry> geometries,
                                           IEnumerable <MacroStabilityInwardsSoilLayer2D> layers)
        {
            var stageTypes = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            Assert.AreEqual(stageTypes.Length, registry.Geometries.Count);
            Assert.AreEqual(stageTypes.Length, registry.GeometryLayers.Count);

            for (var i = 0; i < stageTypes.Length; i++)
            {
                KeyValuePair <MacroStabilityInwardsExportStageType, string> storedGeometry = registry.Geometries.ElementAt(i);
                Assert.AreEqual(stageTypes[i], storedGeometry.Key);
                Assert.AreEqual(geometries.ElementAt(i).Id, storedGeometry.Value);

                KeyValuePair <MacroStabilityInwardsExportStageType, Dictionary <MacroStabilityInwardsSoilLayer2D, string> > storedGeometryLayers = registry.GeometryLayers.ElementAt(i);

                Assert.AreEqual(stageTypes[i], storedGeometryLayers.Key);

                IEnumerable <PersistableLayer> persistableGeometryLayers = geometries.ElementAt(i).Layers;
                Assert.AreEqual(persistableGeometryLayers.Count(), storedGeometryLayers.Value.Count);

                for (var j = 0; j < persistableGeometryLayers.Count(); j++)
                {
                    KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> storedGeometryLayer = storedGeometryLayers.Value.ElementAt(j);

                    Assert.AreSame(layers.ElementAt(j), storedGeometryLayer.Key);
                    Assert.AreEqual(persistableGeometryLayers.ElementAt(j).Id, storedGeometryLayer.Value);
                }
            }
        }
Esempio n. 7
0
        public void Create_WithValidData_ReturnsPersistableStates()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario   calculation           = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1))
            });

            IMacroStabilityInwardsSoilLayer lastLayer = stochasticSoilProfile.SoilProfile.Layers.Last();

            lastLayer.Data.UsePop = true;
            lastLayer.Data.Pop    = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)1,
                CoefficientOfVariation = (RoundedDouble)2
            };
            calculation.InputParameters.StochasticSoilProfile = stochasticSoilProfile;

            IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile = calculation.InputParameters.SoilProfileUnderSurfaceLine;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableState> states = PersistableStateFactory.Create(soilProfile, idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertStates(soilProfile, states);
            PersistableState state = states.First();

            Assert.AreEqual(registry.States[MacroStabilityInwardsExportStageType.Daily], state.Id);
        }
        private static void AssertRegistry(MacroStabilityInwardsExportRegistry registry, MacroStabilityInwardsExportStageType[] stages, IEnumerable <PersistableWaternetCreatorSettings> waternetCreatorSettingsCollection)
        {
            Assert.AreEqual(stages.Length, registry.WaternetCreatorSettings.Count);

            for (var i = 0; i < stages.Length; i++)
            {
                PersistableWaternetCreatorSettings waternetCreatorSettings = waternetCreatorSettingsCollection.ElementAt(i);
                Assert.AreEqual(registry.WaternetCreatorSettings[stages[i]], waternetCreatorSettings.Id);
            }
        }
        public void AddGeometryLayer_GeometryLayerNull_ThrowsArgumentNullException()
        {
            // Setup
            var registry = new MacroStabilityInwardsExportRegistry();

            // Call
            void Call() => registry.AddGeometryLayer(new Random(21).NextEnumValue <MacroStabilityInwardsExportStageType>(), null, "1");

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

            Assert.AreEqual("geometryLayer", exception.ParamName);
        }
        public void AddSoil_SoilLayerNull_ThrowsArgumentNullException()
        {
            // Setup
            var registry = new MacroStabilityInwardsExportRegistry();

            // Call
            void Call() => registry.AddSoil(null, "1");

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

            Assert.AreEqual("soilLayer", exception.ParamName);
        }
        public void AddSettings_InvalidStageType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            var registry = new MacroStabilityInwardsExportRegistry();
            const MacroStabilityInwardsExportStageType stageType = (MacroStabilityInwardsExportStageType)99;

            // Call
            void Call() => registry.AddSettings(stageType, "1");

            // Assert
            string expectedMessage = $"The value of argument '{nameof(stageType)}' ({stageType}) is invalid for Enum type '{nameof(MacroStabilityInwardsExportStageType)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var registry = new MacroStabilityInwardsExportRegistry();

            // Assert
            CollectionAssert.IsEmpty(registry.Settings);
            CollectionAssert.IsEmpty(registry.Soils);
            CollectionAssert.IsEmpty(registry.Geometries);
            CollectionAssert.IsEmpty(registry.GeometryLayers);
            CollectionAssert.IsEmpty(registry.SoilLayers);
            CollectionAssert.IsEmpty(registry.Waternets);
            CollectionAssert.IsEmpty(registry.WaternetCreatorSettings);
            CollectionAssert.IsEmpty(registry.States);
        }
        public void AddGeometryLayer_InvalidStageType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D geometryLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            var registry = new MacroStabilityInwardsExportRegistry();
            const MacroStabilityInwardsExportStageType stageType = (MacroStabilityInwardsExportStageType)99;

            // Call
            void Call() => registry.AddGeometryLayer(stageType, geometryLayer, "1");

            // Assert
            string expectedMessage = $"The value of argument '{nameof(stageType)}' ({stageType}) is invalid for Enum type '{nameof(MacroStabilityInwardsExportStageType)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
        public void AddSettings_ValidStageType_AddsStageTypeWithSettingsId()
        {
            // Setup
            var          registry  = new MacroStabilityInwardsExportRegistry();
            var          stageType = new Random(21).NextEnumValue <MacroStabilityInwardsExportStageType>();
            const string id        = "1";

            // Call
            registry.AddSettings(stageType, id);

            // Assert
            Assert.AreEqual(1, registry.Settings.Count);
            KeyValuePair <MacroStabilityInwardsExportStageType, string> registeredSettings = registry.Settings.Single();

            Assert.AreEqual(stageType, registeredSettings.Key);
            Assert.AreEqual(id, registeredSettings.Value);
        }
        public void AddSoil_WithSoilLayer_AddsSoilLayerWithId()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D soilLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            var          registry = new MacroStabilityInwardsExportRegistry();
            const string id       = "1";

            // Call
            registry.AddSoil(soilLayer, id);

            // Assert
            Assert.AreEqual(1, registry.Soils.Count);
            KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredSoil = registry.Soils.Single();

            Assert.AreSame(soilLayer, registeredSoil.Key);
            Assert.AreEqual(id, registeredSoil.Value);
        }
        public void AddGeometryLayer_StageTypeAlreadyRegistered_AddsGeometryLayerId()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D geometryLayer1 = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();
            MacroStabilityInwardsSoilLayer2D geometryLayer2 = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            geometryLayer2.Data.MaterialName = "Test material";
            geometryLayer2.Data.IsAquifer    = true;

            var          registry  = new MacroStabilityInwardsExportRegistry();
            var          stageType = new Random(21).NextEnumValue <MacroStabilityInwardsExportStageType>();
            const string id1       = "1";
            const string id2       = "2";

            registry.AddGeometryLayer(stageType, geometryLayer1, id1);

            // Precondition
            Assert.AreEqual(1, registry.GeometryLayers.Count);

            // Call
            registry.AddGeometryLayer(stageType, geometryLayer2, id2);

            // Assert
            Assert.AreEqual(1, registry.GeometryLayers.Count);
            KeyValuePair <MacroStabilityInwardsExportStageType, Dictionary <MacroStabilityInwardsSoilLayer2D, string> > registeredStageTypeGeometry = registry.GeometryLayers.Single();

            Assert.AreEqual(stageType, registeredStageTypeGeometry.Key);

            Assert.AreEqual(2, registeredStageTypeGeometry.Value.Count);

            Dictionary <MacroStabilityInwardsSoilLayer2D, string> registeredGeometries = registeredStageTypeGeometry.Value;

            KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredGeometry1 = registeredGeometries.First();

            Assert.AreSame(geometryLayer1, registeredGeometry1.Key);
            Assert.AreEqual(id1, registeredGeometry1.Value);
            KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredGeometry2 = registeredGeometries.Last();

            Assert.AreSame(geometryLayer2, registeredGeometry2.Key);
            Assert.AreEqual(id2, registeredGeometry2.Value);
        }
        public void Create_WithValidData_ReturnsNull()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[]
                {
                    MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
                })
            }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());

            var registry = new MacroStabilityInwardsExportRegistry();

            // Call
            IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, new IdFactory(), registry);

            // Assert
            IEnumerable <MacroStabilityInwardsSoilLayer2D> layersRecursively = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers);

            PersistableDataModelTestHelper.AssertPersistableGeometry(layersRecursively, geometries);
            AssertRegistry(registry, geometries, layersRecursively);
        }
Esempio n. 18
0
        public void Create_SoilProfileWithPOPAndPreconsolidationStressOnOneLayer_ReturnsPersistableStates()
        {
            // Setup
            MacroStabilityInwardsCalculationScenario   calculation           = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1))
            });

            IMacroStabilityInwardsSoilLayer firstLayer = stochasticSoilProfile.SoilProfile.Layers.First();

            firstLayer.Data.UsePop = true;
            firstLayer.Data.Pop    = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)1,
                CoefficientOfVariation = (RoundedDouble)2
            };
            calculation.InputParameters.StochasticSoilProfile = stochasticSoilProfile;

            IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile = calculation.InputParameters.SoilProfileUnderSurfaceLine;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableState> states = PersistableStateFactory.Create(soilProfile, idFactory, registry);

            // Assert
            Assert.AreEqual(1, states.Count());

            PersistableState state = states.First();

            Assert.IsNotNull(state.Id);
            CollectionAssert.IsEmpty(state.StateLines);
            CollectionAssert.IsEmpty(state.StatePoints);
        }
        public void Create_WithValidData_ReturnsPersistableSoilLayerCollectionCollection()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[]
                {
                    MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
                })
            },
                Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableSoilCollection         soils      = PersistableSoilCollectionFactory.Create(soilProfile, idFactory, registry);
            IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, idFactory, registry);

            // Call
            IEnumerable <PersistableSoilLayerCollection> soilLayerCollections = PersistableSoilLayerCollectionFactory.Create(soilProfile, idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertPersistableSoilLayers(soilProfile.Layers, soilLayerCollections, soils.Soils, geometries);

            var stages = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            Assert.AreEqual(2, registry.SoilLayers.Count);

            for (var i = 0; i < stages.Length; i++)
            {
                Assert.AreEqual(registry.SoilLayers[stages[i]], soilLayerCollections.ElementAt(i).Id);
            }
        }
        public void Create_WithDifferentCharacteristics_ReturnsPersistableWaternetCreatorSettingsCollection([Values(true, false)] bool isDitchPresent,
                                                                                                            [Values(true, false)] bool isShouldBaseInsidePresent)
        {
            // Setup
            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(
                new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsInput input = calculation.InputParameters;

            if (isDitchPresent)
            {
                input.SurfaceLine.SetDitchPolderSideAt(new Point3D(0.1, 0, 2));
                input.SurfaceLine.SetBottomDitchPolderSideAt(new Point3D(0.2, 0, 2));
                input.SurfaceLine.SetBottomDitchDikeSideAt(new Point3D(0.3, 0, 3));
                input.SurfaceLine.SetDitchDikeSideAt(new Point3D(0.4, 0, 3));
            }

            if (isShouldBaseInsidePresent)
            {
                input.SurfaceLine.SetShoulderBaseInsideAt(new Point3D(0.5, 0, 1));
            }

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(input.SoilProfileUnderSurfaceLine, idFactory, registry);

            // Call
            IEnumerable <PersistableWaternetCreatorSettings> waternetCreatorSettingsCollection = PersistableWaternetCreatorSettingsFactory.Create(
                input, RoundedDouble.NaN, idFactory, registry);

            // Assert
            foreach (PersistableWaternetCreatorSettings waternetCreatorSettings in waternetCreatorSettingsCollection)
            {
                Assert.AreEqual(isDitchPresent, waternetCreatorSettings.IsDitchPresent);
                PersistableDataModelTestHelper.AssertDitchCharacteristics(input.SurfaceLine, waternetCreatorSettings.DitchCharacteristics, isDitchPresent);
                PersistableDataModelTestHelper.AssertEmbankmentCharacteristics(input.SurfaceLine, waternetCreatorSettings.EmbankmentCharacteristics);
            }
        }
        public void Create_InvalidShearStrengthType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            var registry    = new MacroStabilityInwardsExportRegistry();
            var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
            },
                Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>());
            const MacroStabilityInwardsShearStrengthModel shearStrengthModel = (MacroStabilityInwardsShearStrengthModel)99;

            soilProfile.Layers.First().Data.ShearStrengthModel = shearStrengthModel;

            // Call
            void Call() => PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry);

            // Assert
            string message   = $"The value of argument 'shearStrengthModel' ({shearStrengthModel}) is invalid for Enum type '{nameof(MacroStabilityInwardsShearStrengthModel)}'.";
            var    exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message);

            Assert.AreEqual("shearStrengthModel", exception.ParamName);
        }
        public void AddGeometryLayer_NewStageType_AddsStageTypeAndGeometryLayerId()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D geometryLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            var          registry  = new MacroStabilityInwardsExportRegistry();
            var          stageType = new Random(21).NextEnumValue <MacroStabilityInwardsExportStageType>();
            const string id        = "1";

            // Call
            registry.AddGeometryLayer(stageType, geometryLayer, id);

            // Assert
            Assert.AreEqual(1, registry.GeometryLayers.Count);
            KeyValuePair <MacroStabilityInwardsExportStageType, Dictionary <MacroStabilityInwardsSoilLayer2D, string> > registeredStorageTypeGeometry = registry.GeometryLayers.Single();

            Assert.AreEqual(stageType, registeredStorageTypeGeometry.Key);

            Assert.AreEqual(1, registeredStorageTypeGeometry.Value.Count);
            KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredGeometry = registeredStorageTypeGeometry.Value.Single();

            Assert.AreSame(geometryLayer, registeredGeometry.Key);
            Assert.AreEqual(id, registeredGeometry.Value);
        }
        public void Create_WithDifferentDikeSoilScenarios_ReturnsPersistableWaternetCreatorSettingsCollection(MacroStabilityInwardsDikeSoilScenario soilScenario)
        {
            // Setup
            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(
                new TestHydraulicBoundaryLocation());
            MacroStabilityInwardsInput input = calculation.InputParameters;

            input.DikeSoilScenario = soilScenario;

            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            PersistableGeometryFactory.Create(input.SoilProfileUnderSurfaceLine, idFactory, registry);

            // Call
            IEnumerable <PersistableWaternetCreatorSettings> waternetCreatorSettingsCollection = PersistableWaternetCreatorSettingsFactory.Create(
                input, RoundedDouble.NaN, idFactory, registry);

            // Assert
            foreach (PersistableWaternetCreatorSettings waternetCreatorSettings in waternetCreatorSettingsCollection)
            {
                Assert.AreEqual(PersistableDataModelTestHelper.GetEmbankmentSoilScenario(input.DikeSoilScenario), waternetCreatorSettings.EmbankmentSoilScenario);
            }
        }
        public void Create_WithValidData_ReturnsStages()
        {
            // Setup
            var idFactory = new IdFactory();
            var registry  = new MacroStabilityInwardsExportRegistry();

            var stageTypes = new[]
            {
                MacroStabilityInwardsExportStageType.Daily,
                MacroStabilityInwardsExportStageType.Extreme
            };

            var settingsList   = new List <PersistableCalculationSettings>();
            var geometryList   = new List <PersistableGeometry>();
            var soilLayersList = new List <PersistableSoilLayerCollection>();
            var waternetList   = new List <PersistableWaternet>();
            var waternetCreatorSettingsList = new List <PersistableWaternetCreatorSettings>();
            var stateList = new List <PersistableState>();

            foreach (MacroStabilityInwardsExportStageType stageType in stageTypes)
            {
                var settings = new PersistableCalculationSettings
                {
                    Id = idFactory.Create()
                };
                settingsList.Add(settings);

                var geometry = new PersistableGeometry
                {
                    Id = idFactory.Create()
                };
                geometryList.Add(geometry);

                var persistableSoilLayerCollection = new PersistableSoilLayerCollection
                {
                    Id = idFactory.Create()
                };
                soilLayersList.Add(persistableSoilLayerCollection);

                var waternet = new PersistableWaternet
                {
                    Id = idFactory.Create()
                };
                waternetList.Add(waternet);

                var waternetCreatorSettings = new PersistableWaternetCreatorSettings
                {
                    Id = idFactory.Create()
                };
                waternetCreatorSettingsList.Add(waternetCreatorSettings);

                var state = new PersistableState
                {
                    Id = idFactory.Create()
                };
                stateList.Add(state);

                registry.AddSettings(stageType, settings.Id);
                registry.AddGeometry(stageType, geometry.Id);
                registry.AddSoilLayer(stageType, persistableSoilLayerCollection.Id);
                registry.AddWaternet(stageType, waternet.Id);
                registry.AddWaternetCreatorSettings(stageType, waternetCreatorSettings.Id);
                registry.AddState(stageType, state.Id);
            }

            // Call
            IEnumerable <PersistableStage> stages = PersistableStageFactory.Create(idFactory, registry);

            // Assert
            PersistableDataModelTestHelper.AssertStages(stages, settingsList, geometryList, soilLayersList, waternetList, waternetCreatorSettingsList, stateList);
        }