Пример #1
0
        public void Transform_ValidStochasticSoilModelWithSameProfileInTwoStochasticSoilProfiles_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel(ISoilProfile soilProfile)
        {
            // Setup
            const string        soilModelName = "name";
            const double        originalProfileOneProbability = 0.2;
            const double        originalProfileTwoProbability = 0.7;
            StochasticSoilModel soilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry(soilModelName, new[]
            {
                new StochasticSoilProfile(originalProfileOneProbability, soilProfile),
                new StochasticSoilProfile(originalProfileTwoProbability, soilProfile)
            });

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();
            MacroStabilityInwardsStochasticSoilModel transformed = null;

            // Call
            Action call = () => transformed = transformer.Transform(soilModel);

            // Assert
            string expectedMessage = $"Ondergrondschematisatie '{soilProfile.Name}' is meerdere keren gevonden in ondergrondmodel '{soilModelName}'. " +
                                     "Kansen van voorkomen worden opgeteld.";

            TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn));

            MacroStabilityInwardsStochasticSoilProfile[] transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(1, transformedStochasticSoilProfiles.Length);
            const double expectedProbability = originalProfileOneProbability + originalProfileTwoProbability;

            Assert.AreEqual(expectedProbability, transformedStochasticSoilProfiles[0].Probability, 1e-6);
        }
Пример #2
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();

            // Assert
            Assert.IsInstanceOf <IStochasticSoilModelTransformer <MacroStabilityInwardsStochasticSoilModel> >(transformer);
        }
Пример #3
0
        public void Transform_ValidStochasticSoilModelWithSoilProfile2D_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel()
        {
            // Setup
            var    random      = new Random(21);
            double probability = random.NextDouble();

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();
            StochasticSoilModel soilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry("some name", new[]
            {
                new StochasticSoilProfile(probability, new SoilProfile2D(2, "test", new[]
                {
                    SoilLayer2DTestFactory.CreateSoilLayer2D()
                }, Enumerable.Empty <PreconsolidationStress>()))
            });

            // Call
            MacroStabilityInwardsStochasticSoilModel transformedModel = transformer.Transform(soilModel);

            // Assert
            Assert.AreEqual(soilModel.Name, transformedModel.Name);
            CollectionAssert.AreEqual(soilModel.Geometry, transformedModel.Geometry);
            Assert.AreEqual(1, transformedModel.StochasticSoilProfiles.Count());

            var expectedStochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, new MacroStabilityInwardsSoilProfile2D("test", new[]
            {
                new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
                {
                    new Point2D(1.0, 1.0),
                    new Point2D(2.0, 1.0)
                }),
                                                     new MacroStabilityInwardsSoilLayerData
                {
                    UsePop = true
                },
                                                     new[]
                {
                    new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
                    {
                        new Point2D(0.0, 0.0),
                        new Point2D(1.0, 0.0)
                    }),
                                                         new MacroStabilityInwardsSoilLayerData
                    {
                        UsePop = true
                    },
                                                         Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>())
                })
            }, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>()));

            AssertStochasticSoilProfile(expectedStochasticSoilProfile, transformedModel.StochasticSoilProfiles.First());
        }
Пример #4
0
        public void Transform_StochasticSoilModelNull_ThrowsArgumentNullException()
        {
            // Setup
            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();

            // Call
            TestDelegate call = () => transformer.Transform(null);

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

            Assert.AreEqual("stochasticSoilModel", exception.ParamName);
        }
Пример #5
0
        public void Transform_InvalidFailureMechanismType_ThrowsImportedDataTransformException(FailureMechanismType failureMechanismType)
        {
            // Setup
            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();
            var soilModel   = new StochasticSoilModel("some name", failureMechanismType);

            // Call
            TestDelegate test = () => transformer.Transform(soilModel);

            // Assert
            var exception = Assert.Throws <ImportedDataTransformException>(test);

            Assert.AreEqual($"Het stochastische ondergrondmodel met '{failureMechanismType}' als faalmechanisme type is niet ondersteund. " +
                            "Alleen stochastische ondergrondmodellen met 'Stability' als faalmechanisme type zijn ondersteund.", exception.Message);
        }
Пример #6
0
        public void Transform_InvalidStochasticSoilModel_ThrowsImportedDataTransformException()
        {
            // Setup
            var stochasticSoilModel = new StochasticSoilModel("name", FailureMechanismType.Stability);

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();

            // Call
            TestDelegate test = () => transformer.Transform(stochasticSoilModel);

            // Assert
            var exception = Assert.Throws <ImportedDataTransformException>(test);

            Exception innerException = exception.InnerException;

            Assert.IsNotNull(innerException);
            Assert.IsInstanceOf <ArgumentException>(innerException);
            Assert.AreEqual(innerException.Message, exception.Message);
        }
Пример #7
0
        public void Transform_ValidStochasticSoilModelWithProfileInvalidProbability_ThrowsImportedDataException(StochasticSoilProfile profile)
        {
            // Setup
            StochasticSoilModel soilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry(new[]
            {
                profile
            });

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();

            // Call
            TestDelegate call = () => transformer.Transform(soilModel);

            // Assert
            var          exception       = Assert.Throws <ImportedDataTransformException>(call);
            const string expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel " +
                                           "moet in het bereik [0,0, 1,0] liggen.";

            StringAssert.StartsWith(expectedMessage, exception.Message);
        }
Пример #8
0
        public void Transform_ValidStochasticSoilModelWithSoilProfile1D_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel()
        {
            // Setup
            var          random      = new Random(21);
            double       probability = random.NextDouble();
            const double top         = 4;

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();
            StochasticSoilModel soilModel =
                MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry("some name", new[]
            {
                new StochasticSoilProfile(probability, new SoilProfile1D(2, "test", 3, new[]
                {
                    SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top)
                }))
            });

            // Call
            MacroStabilityInwardsStochasticSoilModel transformedModel = transformer.Transform(soilModel);

            // Assert
            Assert.AreEqual(soilModel.Name, transformedModel.Name);
            CollectionAssert.AreEqual(soilModel.Geometry, transformedModel.Geometry);
            Assert.AreEqual(1, transformedModel.StochasticSoilProfiles.Count());

            var expectedStochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, new MacroStabilityInwardsSoilProfile1D("test", 3, new[]
            {
                new MacroStabilityInwardsSoilLayer1D(top)
                {
                    Data =
                    {
                        UsePop             = true,
                        ShearStrengthModel = MacroStabilityInwardsShearStrengthModel.CPhi,
                        IsAquifer          = false
                    }
                }
            }));

            AssertStochasticSoilProfile(expectedStochasticSoilProfile, transformedModel.StochasticSoilProfiles.First());
        }
Пример #9
0
        public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel()
        {
            // Setup
            var          random          = new Random(21);
            const string soilProfileName = "SoilProfile";
            const double intersectionX   = 1.0;

            var soilProfile2D = new SoilProfile2D(0, soilProfileName, new[]
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = intersectionX
            };
            var stochasticSoilProfile2D = new StochasticSoilProfile(random.NextDouble(), soilProfile2D);

            var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[]
            {
                SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer()
            });
            var stochasticSoilProfile1D = new StochasticSoilProfile(random.NextDouble(), soilProfile1D);

            StochasticSoilModel soilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry(new[]
            {
                stochasticSoilProfile2D,
                stochasticSoilProfile1D
            });

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();

            // Call
            MacroStabilityInwardsStochasticSoilModel transformed = transformer.Transform(soilModel);

            // Assert
            MacroStabilityInwardsStochasticSoilProfile[] transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(2, transformedStochasticSoilProfiles.Length);
            Assert.AreEqual(stochasticSoilProfile2D.Probability, transformedStochasticSoilProfiles[0].Probability, 1e-6);
            Assert.AreEqual(stochasticSoilProfile1D.Probability, transformedStochasticSoilProfiles[1].Probability, 1e-6);
        }
Пример #10
0
        public void Transform_TwoStochasticSoilModelsWithSameProfile_ReturnExpectedMacroStabilityInwardsStochasticSoilModel()
        {
            // Setup
            SoilLayer2D layer   = SoilLayer2DTestFactory.CreateSoilLayer2D();
            var         profile = new SoilProfile2D(2, "test", new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>());

            StochasticSoilModel soilModel1 = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry(new[]
            {
                StochasticSoilProfileTestFactory.CreateStochasticSoilProfileWithValidProbability(profile)
            });

            StochasticSoilModel soilModel2 = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateMacroStabilityInwardsStochasticSoilModelWithGeometry(new[]
            {
                StochasticSoilProfileTestFactory.CreateStochasticSoilProfileWithValidProbability(profile)
            });

            var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer();

            // Call
            MacroStabilityInwardsStochasticSoilModel transformedModel1 = transformer.Transform(soilModel1);
            MacroStabilityInwardsStochasticSoilModel transformedModel2 = transformer.Transform(soilModel2);

            // Assert
            MacroStabilityInwardsStochasticSoilProfile[] transformedStochasticSoilProfiles1 = transformedModel1.StochasticSoilProfiles.ToArray();
            MacroStabilityInwardsStochasticSoilProfile[] transformedStochasticSoilProfiles2 = transformedModel2.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(1, transformedStochasticSoilProfiles1.Length);
            Assert.AreEqual(1, transformedStochasticSoilProfiles2.Length);

            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile1 = transformedStochasticSoilProfiles1[0];
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile2 = transformedStochasticSoilProfiles2[0];

            Assert.AreSame(stochasticSoilProfile1.SoilProfile, stochasticSoilProfile2.SoilProfile);
        }