예제 #1
0
        /// <summary>
        /// Transforms the generic <paramref name="soilLayer"/> into a
        /// <see cref="MacroStabilityInwardsSoilLayer1D"/>.
        /// </summary>
        /// <param name="soilLayer">The soil layer to use in the transformation.</param>
        /// <returns>A <see cref="MacroStabilityInwardsSoilLayer1D"/> based on the given data.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/> is
        /// <c>null</c>.</exception>
        /// <exception cref="ImportedDataTransformException">Thrown when transformation would not result
        /// in a valid transformed instance.</exception>
        public static MacroStabilityInwardsSoilLayer1D Transform(SoilLayer1D soilLayer)
        {
            if (soilLayer == null)
            {
                throw new ArgumentNullException(nameof(soilLayer));
            }

            ValidateStochasticParameters(soilLayer);
            return(new MacroStabilityInwardsSoilLayer1D(soilLayer.Top, ConvertSoilLayerData(soilLayer)));
        }
예제 #2
0
        public void Constructor_WithTop_ReturnsNewInstanceWithTopSet()
        {
            // Setup
            double top = new Random(22).NextDouble();

            // Call
            var layer = new SoilLayer1D(top);

            // Assert
            Assert.IsInstanceOf <SoilLayerBase>(layer);
            Assert.AreEqual(top, layer.Top);
        }
예제 #3
0
        public void SoilLayer1DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer1D(double?color, Color transformedColor)
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            layer.Color = color;

            // Call
            MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedColor, soilLayer1D.Data.Color);
        }
예제 #4
0
        public void SoilLayer1DTransform_ValidIsAquifer_ReturnsMacroStabilityInwardsSoilLayer1D(double isAquifer, bool transformedIsAquifer)
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            layer.IsAquifer = isAquifer;

            // Call
            MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedIsAquifer, soilLayer1D.Data.IsAquifer);
        }
예제 #5
0
        public void SoilLayer1DTransform_ValidUsePopValue_ReturnMacroStabilityInwardSoilLayer1D(double?usePop, bool transformedUsePopValue)
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            layer.UsePop = usePop;

            // Call
            MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedUsePopValue, soilLayer1D.Data.UsePop);
        }
예제 #6
0
        public void SoilLayer1DTransform_ValidShearStrengthModelValue_ReturnMacroStabilityInwardSoilLayer1D(double?sheartStrengthModel,
                                                                                                            MacroStabilityInwardsShearStrengthModel transformedShearStrengthModel)
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            layer.ShearStrengthModel = sheartStrengthModel;

            // Call
            MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(transformedShearStrengthModel, soilLayer1D.Data.ShearStrengthModel);
        }
예제 #7
0
        public void SoilLayer1DTransform_InvalidShearStrengthModelValue_ThrowsImportedDataTransformException()
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            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);
        }
예제 #8
0
        public void SoilLayer1DTransform_ShearStrengthModelValueNone_ThrowsImportedDataTransformException()
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            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);
        }
예제 #9
0
        public void SoilLayer1DTransform_InvalidIsAquifer_ThrowsImportedDataException(double?isAquifer)
        {
            // Setup
            SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer();

            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);
        }
예제 #10
0
        /// <summary>
        /// Transforms the generic <paramref name="soilLayer"/> into a <see cref="PipingSoilLayer"/>.
        /// </summary>
        /// <param name="soilLayer">The soil layer to use in the transformation.</param>
        /// <returns>A new <see cref="PipingSoilLayer"/> based on the given data.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/> is <c>null</c>.</exception>
        /// <exception cref="ImportedDataTransformException">Thrown when transformation would not result
        /// in a valid transformed instance.</exception>
        public static PipingSoilLayer Transform(SoilLayer1D soilLayer)
        {
            if (soilLayer == null)
            {
                throw new ArgumentNullException(nameof(soilLayer));
            }

            ValidateStochasticParameters(soilLayer);

            var pipingSoilLayer = new PipingSoilLayer(soilLayer.Top)
            {
                IsAquifer    = TransformIsAquifer(soilLayer.IsAquifer, soilLayer.MaterialName),
                MaterialName = soilLayer.MaterialName,
                Color        = SoilLayerColorConverter.Convert(soilLayer.Color)
            };

            SetStochasticParameters(pipingSoilLayer, soilLayer);

            return(pipingSoilLayer);
        }
예제 #11
0
        public void SoilLayer1DTransform_PropertiesSetAndValid_ReturnMacroStabilityInwardSoilLayer1D()
        {
            // Setup
            var random = new Random(22);

            double       isAquifer    = random.Next(0, 2);
            double       top          = random.NextDouble();
            const string materialName = "materialX";
            double       color        = random.NextDouble();

            const double abovePhreaticLevelMean = 0.3;
            const double abovePhreaticLevelCoefficientOfVariation = 0.2;
            const double abovePhreaticLevelShift = 0.1;
            const double belowPhreaticLevelMean  = 0.4;
            const double belowPhreaticLevelCoefficientOfVariation = 0.3;
            const double belowPhreaticLevelShift                        = 0.2;
            double       cohesionMean                                   = random.NextDouble();
            double       cohesionCoefficientOfVariation                 = random.NextDouble();
            double       frictionAngleMean                              = random.NextDouble();
            double       frictionAngleCoefficientOfVariation            = random.NextDouble();
            double       shearStrengthRatioMean                         = random.NextDouble();
            double       shearStrengthRatioCoefficientOfVariation       = random.NextDouble();
            double       strengthIncreaseExponentMean                   = random.NextDouble();
            double       strengthIncreaseExponentCoefficientOfVariation = random.NextDouble();
            double       popMean = random.NextDouble();
            double       popCoefficientOfVariation = random.NextDouble();

            var layer = new SoilLayer1D(top)
            {
                IsAquifer              = isAquifer,
                MaterialName           = materialName,
                Color                  = color,
                AbovePhreaticLevelMean = abovePhreaticLevelMean,
                AbovePhreaticLevelCoefficientOfVariation = abovePhreaticLevelCoefficientOfVariation,
                AbovePhreaticLevelShift = abovePhreaticLevelShift,
                BelowPhreaticLevelMean  = belowPhreaticLevelMean,
                BelowPhreaticLevelCoefficientOfVariation = belowPhreaticLevelCoefficientOfVariation,
                BelowPhreaticLevelShift                        = belowPhreaticLevelShift,
                CohesionMean                                   = cohesionMean,
                CohesionCoefficientOfVariation                 = cohesionCoefficientOfVariation,
                FrictionAngleMean                              = frictionAngleMean,
                FrictionAngleCoefficientOfVariation            = frictionAngleCoefficientOfVariation,
                ShearStrengthRatioMean                         = shearStrengthRatioMean,
                ShearStrengthRatioCoefficientOfVariation       = shearStrengthRatioCoefficientOfVariation,
                StrengthIncreaseExponentMean                   = strengthIncreaseExponentMean,
                StrengthIncreaseExponentCoefficientOfVariation = strengthIncreaseExponentCoefficientOfVariation,
                PopMean = popMean,
                PopCoefficientOfVariation = popCoefficientOfVariation
            };

            // Call
            MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Assert.AreEqual(top, soilLayer1D.Top);

            MacroStabilityInwardsSoilLayerData data = soilLayer1D.Data;

            Assert.AreEqual(materialName, data.MaterialName);
            bool expectedIsAquifer = isAquifer.Equals(1.0);

            Assert.AreEqual(expectedIsAquifer, data.IsAquifer);
            Color expectedColor = Color.FromArgb(Convert.ToInt32(color));

            Assert.AreEqual(expectedColor, data.Color);

            Assert.AreEqual(abovePhreaticLevelMean, data.AbovePhreaticLevel.Mean,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelCoefficientOfVariation, data.AbovePhreaticLevel.CoefficientOfVariation,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(abovePhreaticLevelShift, data.AbovePhreaticLevel.Shift,
                            data.AbovePhreaticLevel.GetAccuracy());

            Assert.AreEqual(belowPhreaticLevelMean, data.BelowPhreaticLevel.Mean,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelCoefficientOfVariation, data.BelowPhreaticLevel.CoefficientOfVariation,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(belowPhreaticLevelShift, data.BelowPhreaticLevel.Shift,
                            data.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(cohesionMean, data.Cohesion.Mean,
                            data.Cohesion.GetAccuracy());
            Assert.AreEqual(cohesionCoefficientOfVariation, data.Cohesion.CoefficientOfVariation,
                            data.Cohesion.GetAccuracy());

            Assert.AreEqual(frictionAngleMean, data.FrictionAngle.Mean,
                            data.FrictionAngle.GetAccuracy());
            Assert.AreEqual(frictionAngleCoefficientOfVariation, data.FrictionAngle.CoefficientOfVariation,
                            data.FrictionAngle.GetAccuracy());

            Assert.AreEqual(shearStrengthRatioMean, data.ShearStrengthRatio.Mean,
                            data.ShearStrengthRatio.GetAccuracy());
            Assert.AreEqual(shearStrengthRatioCoefficientOfVariation, data.ShearStrengthRatio.CoefficientOfVariation,
                            data.ShearStrengthRatio.GetAccuracy());

            Assert.AreEqual(strengthIncreaseExponentMean, data.StrengthIncreaseExponent.Mean,
                            data.StrengthIncreaseExponent.GetAccuracy());
            Assert.AreEqual(strengthIncreaseExponentCoefficientOfVariation, data.StrengthIncreaseExponent.CoefficientOfVariation,
                            data.StrengthIncreaseExponent.GetAccuracy());

            Assert.AreEqual(popMean, data.Pop.Mean, data.Pop.GetAccuracy());
            Assert.AreEqual(popCoefficientOfVariation, data.Pop.CoefficientOfVariation,
                            data.Pop.GetAccuracy());
        }
예제 #12
0
        public void SoilLayer1DTransform_InvalidStochasticDistributionValues_ThrowImportedDataTransformException(SoilLayer1D layer, string parameterName)
        {
            // Call
            TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

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

            Exception innerException = exception.InnerException;

            Assert.IsInstanceOf <ArgumentOutOfRangeException>(innerException);
            string expectedMessage = CreateExpectedErrorMessageForParameterVariable(layer.MaterialName, parameterName, innerException.Message);

            Assert.AreEqual(expectedMessage, exception.Message);
        }
예제 #13
0
        public void SoilLayer1DTransform_IncorrectLogNormalDistributionShift_ThrowImportedDataTransformException(SoilLayer1D layer, string parameterName)
        {
            // Call
            TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);

            // Assert
            Exception exception       = Assert.Throws <ImportedDataTransformException>(test);
            string    expectedMessage = CreateExpectedErrorMessageForParameterVariable(layer.MaterialName, parameterName, "Parameter moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.");

            Assert.AreEqual(expectedMessage, exception.Message);
        }
예제 #14
0
        public void ReadSoilProfile_DatabaseWith1DProfile1LayerWithAllNullValues_ReturnsProfileWithDefaultValues()
        {
            // Setup
            string dbFile = Path.Combine(testDataPath, "1dprofileWithLayerWithNullValuesOnly.soil");

            using (var reader = new SoilProfile1DReader(dbFile))
            {
                reader.Initialize();

                // Call
                SoilProfile1D profile = reader.ReadSoilProfile();

                // Assert
                Assert.AreEqual(1, profile.Bottom);
                Assert.AreEqual("Schematisering1", profile.Name);

                SoilLayer1D soilLayer = profile.Layers.Single();
                Assert.AreEqual("dummy", soilLayer.MaterialName);
                Assert.AreEqual(1, soilLayer.Top);
                Assert.IsNull(soilLayer.IsAquifer);
                Assert.IsNull(soilLayer.Color);

                Assert.IsNull(soilLayer.BelowPhreaticLevelDistributionType);
                Assert.IsNaN(soilLayer.BelowPhreaticLevelMean);
                Assert.IsNaN(soilLayer.BelowPhreaticLevelDeviation);
                Assert.IsNaN(soilLayer.BelowPhreaticLevelCoefficientOfVariation);
                Assert.IsNaN(soilLayer.BelowPhreaticLevelShift);

                Assert.IsNull(soilLayer.DiameterD70DistributionType);
                Assert.IsNaN(soilLayer.DiameterD70Mean);
                Assert.IsNaN(soilLayer.DiameterD70CoefficientOfVariation);
                Assert.IsNaN(soilLayer.DiameterD70Shift);

                Assert.IsNull(soilLayer.PermeabilityDistributionType);
                Assert.IsNaN(soilLayer.PermeabilityMean);
                Assert.IsNaN(soilLayer.PermeabilityCoefficientOfVariation);
                Assert.IsNaN(soilLayer.PermeabilityShift);

                Assert.IsNull(soilLayer.UsePop);
                Assert.IsNull(soilLayer.ShearStrengthModel);

                Assert.IsNull(soilLayer.AbovePhreaticLevelDistributionType);
                Assert.IsNaN(soilLayer.AbovePhreaticLevelMean);
                Assert.IsNaN(soilLayer.AbovePhreaticLevelCoefficientOfVariation);
                Assert.IsNaN(soilLayer.AbovePhreaticLevelShift);

                Assert.IsNull(soilLayer.CohesionDistributionType);
                Assert.IsNaN(soilLayer.CohesionMean);
                Assert.IsNaN(soilLayer.CohesionCoefficientOfVariation);
                Assert.IsNaN(soilLayer.CohesionShift);

                Assert.IsNull(soilLayer.FrictionAngleDistributionType);
                Assert.IsNaN(soilLayer.FrictionAngleMean);
                Assert.IsNaN(soilLayer.FrictionAngleCoefficientOfVariation);
                Assert.IsNaN(soilLayer.FrictionAngleShift);

                Assert.IsNull(soilLayer.ShearStrengthRatioDistributionType);
                Assert.IsNaN(soilLayer.ShearStrengthRatioMean);
                Assert.IsNaN(soilLayer.ShearStrengthRatioCoefficientOfVariation);
                Assert.IsNaN(soilLayer.ShearStrengthRatioShift);

                Assert.IsNull(soilLayer.StrengthIncreaseExponentDistributionType);
                Assert.IsNaN(soilLayer.StrengthIncreaseExponentMean);
                Assert.IsNaN(soilLayer.StrengthIncreaseExponentCoefficientOfVariation);
                Assert.IsNaN(soilLayer.StrengthIncreaseExponentShift);

                Assert.IsNull(soilLayer.PopDistributionType);
                Assert.IsNaN(soilLayer.PopMean);
                Assert.IsNaN(soilLayer.PopCoefficientOfVariation);
                Assert.IsNaN(soilLayer.PopShift);
            }

            Assert.IsTrue(TestHelper.CanOpenFileForWrite(dbFile));
        }