Beispiel #1
0
        public void SoilLayer1DTransform_SoilLayer1DNull_ThrowsArgumentNullException()
        {
            // Call
            TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform((SoilLayer1D)null);

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

            Assert.AreEqual("soilLayer", exception.ParamName);
        }
Beispiel #2
0
        public void SoilLayer2DTransform_IncorrectLogNormalDistributionShift_ThrowImportedDataTransformException(SoilLayer2D 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);
        }
Beispiel #3
0
        public void SoilLayer2DTransform_SoilLayer2DWithInvalidLoops_ThrowsImportedDataException(SoilLayer2D soilLayer)
        {
            // Call
            TestDelegate call = () => MacroStabilityInwardsSoilLayerTransformer.Transform(soilLayer);

            // Assert
            var    exception       = Assert.Throws <ImportedDataTransformException>(call);
            string expectedMessage = CreateExpectedErrorMessage(soilLayer.MaterialName,
                                                                "De laag bevat een ongeldige geometrie.");

            Assert.AreEqual(expectedMessage, exception.Message);
            Assert.IsInstanceOf <ArgumentException>(exception.InnerException);
        }
Beispiel #4
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);
        }
Beispiel #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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        public void SoilLayer2DTransform_InvalidStochasticDistributionValues_ThrowImportedDataTransformException(SoilLayer2D 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);
        }
Beispiel #9
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);
        }
Beispiel #10
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);
        }
Beispiel #11
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);
        }
Beispiel #12
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);
        }
Beispiel #13
0
        public void SoilLayer2DTransform_PropertiesSetAndValid_ReturnMacroStabilityInwardSoilLayer2D()
        {
            // Setup
            var nestedLayer1 = new SoilLayer2D(CreateRandomLoop(21), Enumerable.Empty <SoilLayer2D>());
            var nestedLayer2 = new SoilLayer2D(CreateRandomLoop(22), Enumerable.Empty <SoilLayer2D>());
            var nestedLayer3 = new SoilLayer2D(CreateRandomLoop(22),
                                               new[]
            {
                nestedLayer2
            });
            var layer = new SoilLayer2D(CreateRandomLoop(23),
                                        new[]
            {
                nestedLayer1,
                nestedLayer3
            });

            SetRandomSoilData(nestedLayer1, 21, "Nested sand");
            SetRandomSoilData(nestedLayer2, 22, "Nested gold");
            SetRandomSoilData(nestedLayer3, 23, "Nested clay");
            SetRandomSoilData(layer, 24, "Sand");

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

            // Assert
            AssertSoilLayer(layer, transformedLayer);
            Assert.AreEqual(2, transformedLayer.NestedLayers.Count());

            MacroStabilityInwardsSoilLayer2D transformedNestedLayer1 = transformedLayer.NestedLayers.ElementAt(0);

            AssertSoilLayer(nestedLayer1, transformedNestedLayer1);
            CollectionAssert.IsEmpty(transformedNestedLayer1.NestedLayers);

            MacroStabilityInwardsSoilLayer2D transformedNestedLayer3 = transformedLayer.NestedLayers.ElementAt(1);

            AssertSoilLayer(nestedLayer3, transformedNestedLayer3);
            Assert.AreEqual(1, transformedNestedLayer3.NestedLayers.Count());

            MacroStabilityInwardsSoilLayer2D transformedNestedLayer2 = transformedNestedLayer3.NestedLayers.ElementAt(0);

            AssertSoilLayer(nestedLayer2, transformedNestedLayer2);
            CollectionAssert.IsEmpty(transformedNestedLayer2.NestedLayers);
        }
Beispiel #14
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());
        }