Exemplo n.º 1
0
        public void Transform_SoilProfile2DWithInvalidPreconsolidationStress_ThrowsImportedDataException()
        {
            var random = new Random(21);
            var preconsolidationStress = new PreconsolidationStress
            {
                XCoordinate                  = double.NaN,
                ZCoordinate                  = random.NextDouble(),
                StressDistributionType       = SoilLayerConstants.LogNormalDistributionValue,
                StressMean                   = random.NextDouble(),
                StressCoefficientOfVariation = random.NextDouble(),
                StressShift                  = 0
            };

            var profile = new SoilProfile2D(1, "test", new[]
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            }, new[]
            {
                preconsolidationStress
            });

            // Call
            TestDelegate call = () => MacroStabilityInwardsSoilProfileTransformer.Transform(profile);

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

            Exception innerException = exception.InnerException;

            Assert.IsInstanceOf <ImportedDataTransformException>(innerException);
            string expectedMessage = CreateExpectedErrorMessage(profile.Name, innerException.Message);

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Exemplo n.º 2
0
        public void Transform_SoilProfile2DWithPreconsolidationStresses_ReturnMacroStabilityInwardsSoilProfile2DWithStresses()
        {
            // Setup
            var random = new Random(21);
            var preconsolidationStress = new PreconsolidationStress
            {
                XCoordinate                  = random.NextDouble(),
                ZCoordinate                  = random.NextDouble(),
                StressDistributionType       = SoilLayerConstants.LogNormalDistributionValue,
                StressMean                   = random.NextDouble(),
                StressCoefficientOfVariation = random.NextDouble(),
                StressShift                  = 0
            };

            var profile = new SoilProfile2D(1, "test", new[]
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            }, new[]
            {
                preconsolidationStress
            });

            // Call
            var transformedProfile = (MacroStabilityInwardsSoilProfile2D)MacroStabilityInwardsSoilProfileTransformer.Transform(profile);

            // Assert
            AssertPreconsolidationStress(preconsolidationStress, transformedProfile.PreconsolidationStresses.Single());
        }
Exemplo n.º 3
0
        public void Transform_SoilProfile2DWithLayerFilledWithOtherLayer_ReturnsProfileWithBottomAndLayers()
        {
            // Setup
            const string     profileName         = "SomeProfile";
            const long       pipingSoilProfileId = 1234L;
            List <Segment2D> loopHole            = Segment2DLoopCollectionHelper.CreateFromString(
                string.Join(Environment.NewLine,
                            "5",
                            ".....",
                            ".4.1.",
                            ".3.2.",
                            ".....",
                            "....."));

            SoilLayer2D soilLayer2D = SoilLayer2DTestFactory.CreateSoilLayer2D(
                new[]
            {
                loopHole
            },
                Segment2DLoopCollectionHelper.CreateFromString(
                    string.Join(Environment.NewLine,
                                "5",
                                "2...3",
                                ".....",
                                ".....",
                                ".....",
                                "1...4")));

            var profile = new SoilProfile2D(pipingSoilProfileId, profileName,
                                            new List <SoilLayer2D>
            {
                soilLayer2D,
                SoilLayer2DTestFactory.CreateSoilLayer2D(
                    new List <Segment2D[]>(),
                    loopHole)
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = 2.0
            };

            // Call
            PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile);

            // Assert
            Assert.AreEqual(profileName, transformed.Name);
            Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType);
            Assert.AreEqual(4, transformed.Layers.Count());
            CollectionAssert.AreEquivalent(new[]
            {
                4.0,
                3.0,
                3.0,
                2.0
            }, transformed.Layers.Select(rl => rl.Top));
            Assert.AreEqual(0, transformed.Bottom);
        }
Exemplo n.º 4
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());
        }
Exemplo n.º 5
0
        public void SoilLayer2DTransform_ValidIsAquifer_ReturnsMacroStabilityInwardsSoilLayer2D(double isAquifer, bool transformedIsAquifer)
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.IsAquifer = isAquifer;

            // Call
            MacroStabilityInwardsSoilLayer2D soilLayer2D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedIsAquifer, soilLayer2D.Data.IsAquifer);
        }
Exemplo n.º 6
0
        public void SoilLayer2DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer2D(double?color, Color transformedColor)
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.Color = color;

            // Call
            MacroStabilityInwardsSoilLayer2D soilLayer2D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedColor, soilLayer2D.Data.Color);
        }
Exemplo n.º 7
0
        public void SoilLayer2DTransform_ValidUsePopValue_ReturnMacroStabilityInwardSoilLayer2D(double?usePop, bool transformedUsePopValue)
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.UsePop = usePop;

            // Call
            MacroStabilityInwardsSoilLayer2D soilLayer2D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedUsePopValue, soilLayer2D.Data.UsePop);
        }
Exemplo n.º 8
0
        public void SoilLayer2DTransform_ValidShearStrengthModelValue_ReturnMacroStabilityInwardSoilLayer2D(double?shearStrengthModel,
                                                                                                            MacroStabilityInwardsShearStrengthModel transformedShearStrengthModel)
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.ShearStrengthModel = shearStrengthModel;

            // Call
            MacroStabilityInwardsSoilLayer2D soilLayer2D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedShearStrengthModel, soilLayer2D.Data.ShearStrengthModel);
        }
Exemplo n.º 9
0
        public void Constructor_NameNull_ThrowsArgumentNullException()
        {
            // Setup
            SoilLayer2D[] soilLayer2Ds =
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            };

            // Call
            TestDelegate test = () => new SoilProfile2D(1, null, soilLayer2Ds, Enumerable.Empty <PreconsolidationStress>());

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

            Assert.AreEqual("name", exception.ParamName);
        }
Exemplo n.º 10
0
        public void Constructor_PreconsolidationStressesNull_ThrowsArgumentNullException()
        {
            // Setup
            SoilLayer2D[] soilLayer2Ds =
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            };

            // Call
            TestDelegate call = () => new SoilProfile2D(1, string.Empty, soilLayer2Ds, null);

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

            Assert.AreEqual("preconsolidationStresses", exception.ParamName);
        }
        public void Transform_ValidStochasticSoilModelWithSoilProfile2D_ReturnsExpectedPipingStochasticSoilModel()
        {
            // Setup
            var          random        = new Random(21);
            const string name          = "name";
            const double intersectionX = 1.0;

            SoilLayer2D layer   = SoilLayer2DTestFactory.CreateSoilLayer2D();
            var         profile = new SoilProfile2D(0, "SoilProfile2D", new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = intersectionX
            };

            var    transformer = new PipingStochasticSoilModelTransformer();
            double probability = random.NextDouble();
            var    soilModel   = new StochasticSoilModel(name, FailureMechanismType.Piping)
            {
                StochasticSoilProfiles =
                {
                    new StochasticSoilProfile(probability, profile)
                },
                Geometry =
                {
                    new Point2D(1.0, 0.0),
                    new Point2D(0.0, 0.0)
                }
            };

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

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

            var expectedPipingSoilProfile = new[]
            {
                new PipingStochasticSoilProfile(probability, PipingSoilProfileTransformer.Transform(profile))
            };

            AssertPipingStochasticSoilProfiles(expectedPipingSoilProfile, transformed.StochasticSoilProfiles.ToArray());
        }
Exemplo n.º 12
0
        public void Transform_ValidSoilProfile2D_ReturnMacroStabilityInwardsSoilProfile2D()
        {
            // Setup
            var profile = new SoilProfile2D(1, "test", new[]
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            }, Enumerable.Empty <PreconsolidationStress>());

            // Call
            var transformedProfile = (MacroStabilityInwardsSoilProfile2D)MacroStabilityInwardsSoilProfileTransformer.Transform(profile);

            // Assert
            Assert.AreEqual(profile.Name, transformedProfile.Name);
            Assert.AreEqual(profile.Layers.Count(), transformedProfile.Layers.Count());
            CollectionAssert.AllItemsAreInstancesOfType(transformedProfile.Layers, typeof(MacroStabilityInwardsSoilLayer2D));
            CollectionAssert.IsEmpty(transformedProfile.PreconsolidationStresses);
        }
Exemplo n.º 13
0
        public void SoilLayer2DTransform_InvalidShearStrengthModelValue_ThrowsImportedDataTransformException()
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.ShearStrengthModel = 2;

            // Call
            TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            var    exception       = Assert.Throws <ImportedDataTransformException>(test);
            string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
                                                                "Ongeldige waarde voor parameter 'Schuifsterkte model'.");

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Exemplo n.º 14
0
        public void SoilLayer2DTransform_ShearStrengthModelValueNone_ThrowsImportedDataTransformException()
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.ShearStrengthModel = 1;

            // Call
            TestDelegate call = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            var    exception       = Assert.Throws <ImportedDataTransformException>(call);
            string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
                                                                "Er is geen schuifsterkte model opgegeven.");

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Exemplo n.º 15
0
        public void SoilLayer2DTransform_InvalidUsePopValue_ReturnMacroStabilityInwardSoilLayer2D()
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.UsePop = 1;

            // Call
            TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            var    exception       = Assert.Throws <ImportedDataTransformException>(test);
            string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
                                                                "Ongeldige waarde voor parameter 'Gebruik POP'.");

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Exemplo n.º 16
0
        public void SoilLayer2DTransform_InvalidIsAquifer_ThrowsImportedDataException(double?isAquifer)
        {
            // Setup
            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D();

            layer.IsAquifer = isAquifer;

            // Call
            TestDelegate call = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            var    exception       = Assert.Throws <ImportedDataTransformException>(call);
            string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
                                                                "Ongeldige waarde voor parameter 'Is aquifer'.");

            Assert.AreEqual(expectedMessage, exception.Message);
            Assert.IsInstanceOf <NotSupportedException>(exception.InnerException);
        }
        public void Transform_ValidStochasticSoilModelWithSameProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel()
        {
            // Setup
            const string soilModelName   = "name";
            const string soilProfileName = "SoilProfile";
            const double intersectionX   = 1.0;

            SoilLayer2D layer   = SoilLayer2DTestFactory.CreateSoilLayer2D();
            var         profile = new SoilProfile2D(0, soilProfileName, new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = intersectionX
            };

            const double        originalProfileOneProbability = 0.2;
            const double        originalProfileTwoProbability = 0.7;
            StochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModelWithGeometry(soilModelName, new[]
            {
                new StochasticSoilProfile(originalProfileOneProbability, profile),
                new StochasticSoilProfile(originalProfileTwoProbability, profile)
            });

            var transformer = new PipingStochasticSoilModelTransformer();
            PipingStochasticSoilModel transformed = null;

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

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

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

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

            Assert.AreEqual(expectedProbability, transformedStochasticSoilProfiles[0].Probability, 1e-6);
        }
        private static IEnumerable <TestCaseData> GetSupportedStochasticSoilProfilesWithInvalidProbabilities()
        {
            double[] invalidProbabilities =
            {
                double.NaN,
                double.NegativeInfinity,
                double.PositiveInfinity,
                1.1,
                -0.1,
                5,
                -5
            };

            const long   id   = 1;
            const string name = "test";

            foreach (double invalidProbability in invalidProbabilities)
            {
                yield return(new TestCaseData(new StochasticSoilProfile(invalidProbability,
                                                                        new SoilProfile2D(id,
                                                                                          name,
                                                                                          new[]
                {
                    SoilLayer2DTestFactory.CreateSoilLayer2D()
                }, Enumerable.Empty <PreconsolidationStress>())
                {
                    IntersectionX = 1.0
                }))
                             .SetName($"2D Soil Profile - {invalidProbability}"));

                yield return(new TestCaseData(new StochasticSoilProfile(invalidProbability,
                                                                        new SoilProfile1D(id,
                                                                                          name,
                                                                                          1,
                                                                                          new[]
                {
                    SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer()
                })))
                             .SetName($"1D Soil Profile - {invalidProbability}"));
            }
        }
        public void Transform_ValidTwoStochasticSoilModelWithSameProfile_ReturnsExpectedPipingStochasticSoilModel()
        {
            // Setup
            const double intersectionX = 1.0;

            SoilLayer2D layer   = SoilLayer2DTestFactory.CreateSoilLayer2D();
            var         profile = new SoilProfile2D(0, "SoilProfile2D", new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = intersectionX
            };

            var transformer = new PipingStochasticSoilModelTransformer();
            StochasticSoilModel soilModel1 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModelWithGeometry(new[]
            {
                StochasticSoilProfileTestFactory.CreateStochasticSoilProfileWithValidProbability(profile)
            });

            StochasticSoilModel soilModel2 = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModelWithGeometry(new[]
            {
                StochasticSoilProfileTestFactory.CreateStochasticSoilProfileWithValidProbability(profile)
            });

            // Call
            PipingStochasticSoilModel transformed1 = transformer.Transform(soilModel1);
            PipingStochasticSoilModel transformed2 = transformer.Transform(soilModel2);

            // Assert
            PipingStochasticSoilProfile[] transformedStochasticSoilProfiles1 = transformed1.StochasticSoilProfiles.ToArray();
            PipingStochasticSoilProfile[] transformedStochasticSoilProfiles2 = transformed2.StochasticSoilProfiles.ToArray();
            Assert.AreEqual(1, transformedStochasticSoilProfiles1.Length);
            Assert.AreEqual(1, transformedStochasticSoilProfiles2.Length);

            PipingStochasticSoilProfile pipingStochasticSoilProfile1 = transformedStochasticSoilProfiles1[0];
            PipingStochasticSoilProfile pipingStochasticSoilProfile2 = transformedStochasticSoilProfiles2[0];

            Assert.AreSame(pipingStochasticSoilProfile1.SoilProfile, pipingStochasticSoilProfile2.SoilProfile);
        }
        public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel()
        {
            // 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);

            var transformer = new PipingStochasticSoilModelTransformer();
            StochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModelWithGeometry(new[]
            {
                stochasticSoilProfile2D,
                stochasticSoilProfile1D
            });

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

            // Assert
            PipingStochasticSoilProfile[] 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);
        }
Exemplo n.º 21
0
        private static IEnumerable <TestCaseData> GetSoilLayerWithInvalidGeometry()
        {
            var pointA     = new Point2D(0.0, 0.0);
            var pointB     = new Point2D(1.0, 0.0);
            var segmentOne = new Segment2D(pointA, pointB);
            var segmentTwo = new Segment2D(pointB, pointA);

            Segment2D[] validGeometry =
            {
                segmentOne,
                segmentTwo
            };

            yield return(new TestCaseData(SoilLayer2DTestFactory.CreateSoilLayer2D(new IEnumerable <Segment2D> [0],
                                                                                   Enumerable.Empty <Segment2D>())));

            yield return(new TestCaseData(SoilLayer2DTestFactory.CreateSoilLayer2D(new[]
            {
                Enumerable.Empty <Segment2D>()
            },
                                                                                   validGeometry)));
        }
        private static IEnumerable <TestCaseData> GetValidConfiguredAndSupportedSoilProfiles()
        {
            var random = new Random(21);

            const long   id   = 1;
            const string name = "test";

            yield return(new TestCaseData(new SoilProfile2D(id, name, new[]
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D()
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = random.NextDouble() + 1
            })
                         .SetName("2D Profile"));

            yield return(new TestCaseData(new SoilProfile1D(id, name, random.NextDouble(),
                                                            new[]
            {
                SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer()
            }))
                         .SetName("1D Profile"));
        }
Exemplo n.º 23
0
        public void Transform_ValidSoilProfile2D_ReturnsExpectedPipingSoilProfile()
        {
            // Setup
            const string name          = "name";
            const double bottom        = 0.5;
            const double intersectionX = 1.0;

            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(new List <Segment2D[]>(),
                                                                         new List <Segment2D>
            {
                new Segment2D(new Point2D(1.0, bottom),
                              new Point2D(1.2, 1)),
                new Segment2D(new Point2D(1.2, 1),
                              new Point2D(1.0, bottom))
            });
            var profile = new SoilProfile2D(0, name, new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = intersectionX
            };

            // Call
            PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile);

            // Assert
            Assert.AreEqual(name, transformed.Name);
            Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType);
            Assert.AreEqual(bottom, transformed.Bottom);

            double bottomOut;
            IEnumerable <PipingSoilLayer> actualPipingSoilLayers = PipingSoilLayerTransformer.Transform(
                layer, intersectionX, out bottomOut);

            AssertPipingSoilLayers(actualPipingSoilLayers, transformed.Layers);
        }
Exemplo n.º 24
0
        public void Transform_SoilProfile2DWithSingleLayerOnlyOuterLoop_ReturnsProfileWithBottomAndALayer()
        {
            // Setup
            const string profileName = "SomeProfile";
            var          firstPoint  = new Point2D(-0.5, 1.0);
            var          secondPoint = new Point2D(0.5, 1.0);
            var          thirdPoint  = new Point2D(0.5, -1.0);
            var          fourthPoint = new Point2D(-0.5, -1.0);

            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(
                new List <Segment2D[]>(),
                new List <Segment2D>
            {
                new Segment2D(firstPoint, secondPoint),
                new Segment2D(secondPoint, thirdPoint),
                new Segment2D(thirdPoint, fourthPoint),
                new Segment2D(fourthPoint, firstPoint)
            });

            var profile = new SoilProfile2D(0, profileName, new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = 0.0
            };

            // Call
            PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile);

            // Assert
            Assert.AreEqual(profileName, transformed.Name);
            Assert.AreEqual(1, transformed.Layers.Count());
            Assert.AreEqual(1.0, transformed.Layers.ToArray()[0].Top);
            Assert.AreEqual(-1.0, transformed.Bottom);
            Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType);
        }
Exemplo n.º 25
0
        public void Transform_SoilProfile2DLayerWithVerticalLineOnXInXml_ThrowsImportedDataTransformException()
        {
            // Setup
            const string profileName = "SomeProfile";
            const double atX         = 0.0;

            SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(
                new List <Segment2D[]>(),
                new List <Segment2D>
            {
                new Segment2D(new Point2D(atX, 0.0),
                              new Point2D(atX, 1.0)),
                new Segment2D(new Point2D(atX, 1.0),
                              new Point2D(0.5, 0.5)),
                new Segment2D(new Point2D(0.5, 0.5),
                              new Point2D(atX, 0.0))
            });

            var profile = new SoilProfile2D(0, profileName, new[]
            {
                layer
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = atX
            };

            // Call
            TestDelegate test = () => PipingSoilProfileTransformer.Transform(profile);

            // Assert
            var    exception = Assert.Throws <ImportedDataTransformException>(test);
            string message   = $"Er is een fout opgetreden bij het inlezen van grondlaag '{layer.MaterialName}': " +
                               "Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D " +
                               $"laag verticaal lopen op de gekozen positie: x = {atX}.";

            Assert.AreEqual(message, exception.Message);
        }
Exemplo n.º 26
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);
        }
Exemplo n.º 27
0
        public void Transform_SoilProfile2DWithMultipleLayersOnlyOuterLoop_ReturnsProfileWithBottomAndLayers()
        {
            // Setup
            const string profileName         = "SomeProfile";
            const long   pipingSoilProfileId = 1234L;

            var profile = new SoilProfile2D(pipingSoilProfileId, profileName,
                                            new List <SoilLayer2D>
            {
                SoilLayer2DTestFactory.CreateSoilLayer2D(
                    new List <Segment2D[]>(),
                    Segment2DLoopCollectionHelper.CreateFromString(
                        string.Join(Environment.NewLine,
                                    "10",
                                    "...",
                                    "...",
                                    "...",
                                    "...",
                                    "...",
                                    "...",
                                    "...",
                                    "1.2",
                                    "4.3",
                                    "..."))),
                SoilLayer2DTestFactory.CreateSoilLayer2D(
                    new List <Segment2D[]>(),
                    Segment2DLoopCollectionHelper.CreateFromString(
                        string.Join(Environment.NewLine,
                                    "10",
                                    "...",
                                    "...",
                                    "...",
                                    "...",
                                    "...",
                                    "4.3",
                                    "...",
                                    "1.2",
                                    "...",
                                    "..."))),
                SoilLayer2DTestFactory.CreateSoilLayer2D(
                    new List <Segment2D[]>(),
                    Segment2DLoopCollectionHelper.CreateFromString(
                        string.Join(Environment.NewLine,
                                    "10",
                                    "...",
                                    "1.2",
                                    "...",
                                    "...",
                                    "...",
                                    "4.3",
                                    "...",
                                    "...",
                                    "...",
                                    "...")))
            }, Enumerable.Empty <PreconsolidationStress>())
            {
                IntersectionX = 1.0
            };

            // Call
            PipingSoilProfile transformed = PipingSoilProfileTransformer.Transform(profile);

            // Assert
            Assert.AreEqual(profileName, transformed.Name);
            Assert.AreEqual(SoilProfileType.SoilProfile2D, transformed.SoilProfileSourceType);
            Assert.AreEqual(3, transformed.Layers.Count());
            CollectionAssert.AreEquivalent(new[]
            {
                2.0,
                4.0,
                8.0
            }, transformed.Layers.Select(rl => rl.Top));
            Assert.AreEqual(1.0, transformed.Bottom);
        }