Exemple #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);
        }
        public void HasValidStatePoints_SoilProfileWithPOPAndPreconsolidationStressOnOneLayer_ReturnsFalse()
        {
            // Setup
            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
            };

            MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile,
                                                                                                                                                          CreateSurfaceLine());

            // Call
            bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine);

            // Assert
            Assert.IsFalse(hasValidStatePoints);
        }
        public void Constructor_WithPreconsolidationStress_PropertiesHaveExpectedAttributeValues()
        {
            // Call
            var properties = new MacroStabilityInwardsPreconsolidationStressProperties(
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress());

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(3, dynamicProperties.Count);

            const string generalCategory = "Algemeen";

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                dynamicProperties[0],
                generalCategory,
                "X [m]",
                "Lokale x-coördinaat van het punt waarvoor de grensspanning is opgegeven.",
                true);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                dynamicProperties[1],
                generalCategory,
                "Z [m+NAP]",
                "Lokale z-coördinaat van het punt waarvoor de grensspanning is opgegeven.",
                true);
            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
                dynamicProperties[2],
                generalCategory,
                "Grensspanning [kN/m²]",
                "Grensspanning op de aangegeven locatie.",
                true);
        }
Exemple #4
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);
        }
        public void Export_SoilProfileWithMultiplePreconsolidationStressesOnOneLayer_LogsWarningAndReturnsTrue()
        {
            // Setup
            string filePath = TestHelper.GetScratchPadPath($"{nameof(MacroStabilityInwardsCalculationExporterTest)}.{nameof(Export_SoilProfileWithMultiplePreconsolidationStressesOnOneLayer_LogsWarningAndReturnsTrue)}.ValidFile.stix");

            MacroStabilityInwardsCalculationScenario calculation = MacroStabilityInwardsCalculationScenarioTestFactory.CreateMacroStabilityInwardsCalculationScenarioWithValidInput(new TestHydraulicBoundaryLocation());

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

            var exporter = new MacroStabilityInwardsCalculationExporter(calculation, new GeneralMacroStabilityInwardsInput(), new PersistenceFactory(), filePath, AssessmentSectionTestHelper.GetTestAssessmentLevel);

            try
            {
                using (new MacroStabilityInwardsCalculatorFactoryConfig())
                {
                    // Call
                    var exportResult            = false;
                    void Call() => exportResult = exporter.Export();

                    // Assert
                    var expectedMessage = $"'{calculation.Name}': De schematisatie van de berekening bevat meerdere stresspunten binnen één laag of stresspunten die niet aan een laag gekoppeld kunnen worden. Er worden daarom geen POP en grensspanningen geëxporteerd.";
                    TestHelper.AssertLogMessageWithLevelIsGenerated(Call, new Tuple <string, LogLevelConstant>(expectedMessage, LogLevelConstant.Warn));
                    Assert.IsTrue(exportResult);
                }
            }
            finally
            {
                File.Delete(filePath);
            }
        }
        public void ToString_Always_ReturnsEmptyString()
        {
            // Setup
            var properties = new MacroStabilityInwardsPreconsolidationStressProperties(
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress());

            // Call
            string result = properties.ToString();

            // Assert
            Assert.IsEmpty(result);
        }
        public void HasValidStatePoints_SoilProfileWithPreconsolidationStressOutsideLayers_ReturnsFalse()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, -50))
            });

            MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile, CreateSurfaceLine());

            // Call
            bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine);

            // Assert
            Assert.IsFalse(hasValidStatePoints);
        }
        public void GetLayerForPreconsolidationStress_PreconsolidationStressNotInLayer_ReturnsNull()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, -50))
            });

            MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile,
                                                                                                                                                          CreateSurfaceLine());

            // Call
            MacroStabilityInwardsSoilLayer2D layer = PersistableStateHelper.GetLayerForPreconsolidationStress(soilProfileUnderSurfaceLine.Layers, soilProfileUnderSurfaceLine.PreconsolidationStresses.First());

            // Assert
            Assert.IsNull(layer);
        }
Exemple #9
0
        public void GetProperties_WithSoilProfile2D_ReturnExpectedValues()
        {
            // Setup
            var    random      = new Random(21);
            double probability = random.NextDouble();

            MacroStabilityInwardsSoilLayer2D layerOne = CreateMacroStabilityInwardsSoilLayer2D();
            MacroStabilityInwardsSoilLayer2D layerTwo = CreateMacroStabilityInwardsSoilLayer2D();

            MacroStabilityInwardsSoilLayer2D[] layers =
            {
                layerOne,
                layerTwo
            };

            MacroStabilityInwardsPreconsolidationStress[] stresses =
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress()
            };

            var soilProfile           = new MacroStabilityInwardsSoilProfile2D("<some name>", layers, stresses);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, soilProfile);

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            Assert.AreEqual(soilProfile.Name, properties.Name);
            Assert.AreEqual(soilProfile.Name, properties.ToString());

            Assert.AreEqual(layers.Length, properties.Layers2D.Length);
            Assert.AreSame(layerOne, properties.Layers2D[0].Data);
            Assert.AreSame(layerTwo, properties.Layers2D[1].Data);

            CollectionAssert.IsEmpty(properties.Layers1D);
            Assert.AreEqual(double.NaN, properties.Bottom);
            Assert.AreEqual(2, properties.Probability.NumberOfDecimalPlaces);
            Assert.AreEqual(probability * 100, properties.Probability, properties.Probability.GetAccuracy());
            Assert.AreEqual("2D profiel", properties.Type);

            Assert.AreEqual(stresses.Length, properties.PreconsolidationStresses.Length);
            Assert.AreSame(stresses[0], properties.PreconsolidationStresses[0].Data);
        }
Exemple #10
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 Constructor_WithPreconsolidationStress_ReturnsExpectedValues()
        {
            // Setup
            MacroStabilityInwardsPreconsolidationStress preconsolidationStress =
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress();

            // Call
            var properties = new MacroStabilityInwardsPreconsolidationStressProperties(preconsolidationStress);

            // Assert
            Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsPreconsolidationStress> >(properties);
            Assert.AreSame(preconsolidationStress, properties.Data);

            Assert.AreEqual(2, properties.XCoordinate.NumberOfDecimalPlaces);
            Assert.AreEqual(preconsolidationStress.Location.X, properties.XCoordinate, properties.XCoordinate.GetAccuracy());
            Assert.AreEqual(2, properties.ZCoordinate.NumberOfDecimalPlaces);
            Assert.AreEqual(preconsolidationStress.Location.Y, properties.ZCoordinate, properties.ZCoordinate.GetAccuracy());

            Assert.IsInstanceOf <VariationCoefficientLogNormalDistributionDesignVariableProperties>(properties.PreconsolidationStress);
            TestHelper.AssertTypeConverter <MacroStabilityInwardsPreconsolidationStressProperties, ExpandableObjectConverter>(
                nameof(MacroStabilityInwardsPreconsolidationStressProperties.PreconsolidationStress));
            Assert.AreEqual(preconsolidationStress.Stress.Mean, properties.PreconsolidationStress.Mean);
            Assert.AreEqual(preconsolidationStress.Stress.CoefficientOfVariation, properties.PreconsolidationStress.CoefficientOfVariation);
        }
Exemple #12
0
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfile2D("some name", new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(),
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
            }, new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress()
            });
            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsSoilProfileTwoDEntity entity = soilProfile.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(soilProfile.Layers.Count(), entity.MacroStabilityInwardsSoilLayerTwoDEntities.Count);
            Assert.AreEqual(soilProfile.PreconsolidationStresses.Count(), entity.MacroStabilityInwardsPreconsolidationStressEntities.Count);

            AssertPreconsolidationStress(soilProfile.PreconsolidationStresses.First(),
                                         entity.MacroStabilityInwardsPreconsolidationStressEntities.First());
        }
        public void Export_CalculationGroupWithNestedGroupsAndCalculationsWithExportWarnings_LogsMessagesAndWritesFile()
        {
            // Setup
            string folderPath = TestHelper.GetScratchPadPath($"{nameof(MacroStabilityInwardsCalculationGroupExporterTest)}.{nameof(Export_CalculationGroupWithNestedGroupsAndCalculationsWithExportWarnings_LogsMessagesAndWritesFile)}");

            Directory.CreateDirectory(folderPath);
            string filePath = Path.Combine(folderPath, "export.zip");

            MacroStabilityInwardsCalculationScenario calculation1 = CreateCalculation("calculation1");

            calculation1.InputParameters.StochasticSoilProfile.SoilProfile.Layers.ForEachElementDo(layer => layer.Data.IsAquifer = true);
            MacroStabilityInwardsCalculationScenario calculation2 = CreateCalculation("calculation2");

            calculation2.InputParameters.StochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1)),
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 2))
            });
            MacroStabilityInwardsCalculationScenario calculation3 = CreateCalculation("calculation3");
            MacroStabilityInwardsCalculationScenario calculation4 = CreateCalculation("calculation4");

            var rootCalculationGroup = new CalculationGroup();
            var nestedGroup1         = new CalculationGroup
            {
                Name = "NestedGroup1"
            };
            var nestedGroup2 = new CalculationGroup
            {
                Name = "NestedGroup2"
            };

            nestedGroup2.Children.Add(calculation4);
            nestedGroup1.Children.Add(calculation3);
            nestedGroup1.Children.Add(nestedGroup2);
            rootCalculationGroup.Children.Add(calculation1);
            rootCalculationGroup.Children.Add(calculation2);
            rootCalculationGroup.Children.Add(nestedGroup1);

            var exporter = new MacroStabilityInwardsCalculationGroupExporter(rootCalculationGroup, new GeneralMacroStabilityInwardsInput(),
                                                                             new PersistenceFactory(), filePath, fileExtension,
                                                                             c => AssessmentSectionTestHelper.GetTestAssessmentLevel());

            try
            {
                using (new MacroStabilityInwardsCalculatorFactoryConfig())
                {
                    // Call
                    var exportResult            = false;
                    void Call() => exportResult = exporter.Export();

                    // Assert
                    TestHelper.AssertLogMessagesAreGenerated(Call, new[]
                    {
                        $"'{calculation1.Name}': De schematisatie van de berekening bevat meerdere aquifer lagen. De volgorde van de aquifer lagen kan niet bepaald worden tijdens exporteren. Er worden daarom geen lagen als aquifer geëxporteerd.",
                        $"'{calculation2.Name}': De schematisatie van de berekening bevat meerdere stresspunten binnen één laag of stresspunten die niet aan een laag gekoppeld kunnen worden. Er worden daarom geen POP en grensspanningen geëxporteerd."
                    });
                    Assert.IsTrue(exportResult);
                    AssertFilesExistInZip(new[]
                    {
                        $"{calculation1.Name}.{fileExtension}",
                        $"{calculation2.Name}.{fileExtension}",
                        $"{nestedGroup1.Name}/{calculation3.Name}.{fileExtension}",
                        $"{nestedGroup1.Name}/{nestedGroup2.Name}/{calculation4.Name}.{fileExtension}"
                    }, filePath);
                }
            }
            finally
            {
                DirectoryHelper.TryDelete(folderPath);
            }
        }