public void Read_WithValues_ReturnsExpectedMacroStabilityInwardsPreconsolidationStress()
        {
            // Setup
            var random = new Random(31);
            var entity = new MacroStabilityInwardsPreconsolidationStressEntity
            {
                CoordinateX = random.NextDouble(),
                CoordinateZ = random.NextDouble(),
                PreconsolidationStressMean = random.NextDouble(),
                PreconsolidationStressCoefficientOfVariation = random.NextDouble()
            };

            // Call
            MacroStabilityInwardsPreconsolidationStress stress = entity.Read();

            // Assert
            Assert.IsNotNull(stress);
            Assert.AreEqual(entity.CoordinateX, stress.Location.X);
            Assert.AreEqual(entity.CoordinateZ, stress.Location.Y);

            VariationCoefficientLogNormalDistribution preconsolidationStressDistribution = stress.Stress;

            AssertAreEqual(entity.PreconsolidationStressMean, preconsolidationStressDistribution.Mean);
            AssertAreEqual(entity.PreconsolidationStressCoefficientOfVariation, preconsolidationStressDistribution.CoefficientOfVariation);
        }
        public void Constructor_ValidArguments_ReturnsExpectedValues()
        {
            // Setup
            var random = new Random(21);

            var location     = new Point2D(random.NextDouble(), random.NextDouble());
            var distribution = new VariationCoefficientLogNormalDistribution
            {
                Mean = random.NextRoundedDouble(0.1, double.MaxValue),
                CoefficientOfVariation = random.NextRoundedDouble()
            };

            // Call
            var stress = new MacroStabilityInwardsPreconsolidationStress(location, distribution);

            // Assert
            Assert.IsInstanceOf <IMacroStabilityInwardsPreconsolidationStress>(stress);
            Assert.AreEqual(location, stress.Location);

            DistributionAssert.AreEqual(new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = distribution.Mean,
                CoefficientOfVariation = distribution.CoefficientOfVariation
            }, stress.Stress);
        }
        public void Transform_ValidPreconsolidationStress_ReturnMacroStabilityInwardsPreconsolidationStress()
        {
            // Setup
            var random = new Random(21);
            var preconsolidationStress = new PreconsolidationStress
            {
                XCoordinate                  = random.NextDouble(),
                ZCoordinate                  = random.NextDouble(),
                StressDistributionType       = 3,
                StressMean                   = random.NextDouble(),
                StressCoefficientOfVariation = random.NextDouble(),
                StressShift                  = 0
            };

            // Call
            MacroStabilityInwardsPreconsolidationStress transformedStress =
                MacroStabilityInwardsPreconsolidationStressTransformer.Transform(preconsolidationStress);

            // Assert
            Assert.AreEqual(preconsolidationStress.XCoordinate, transformedStress.Location.X);
            Assert.AreEqual(preconsolidationStress.ZCoordinate, transformedStress.Location.Y);

            VariationCoefficientLogNormalDistribution transformedPreconsolidationStressDistribution = transformedStress.Stress;

            Assert.AreEqual(preconsolidationStress.StressMean, transformedPreconsolidationStressDistribution.Mean,
                            transformedPreconsolidationStressDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationStress.StressCoefficientOfVariation,
                            transformedPreconsolidationStressDistribution.CoefficientOfVariation,
                            transformedPreconsolidationStressDistribution.GetAccuracy());
        }
Пример #4
0
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var random = new Random(31);

            var stress = new MacroStabilityInwardsPreconsolidationStress(new Point2D(random.NextDouble(), random.NextDouble()),
                                                                         new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)0.005,
                CoefficientOfVariation = random.NextRoundedDouble()
            });
            int order = random.Next();

            // Call
            MacroStabilityInwardsPreconsolidationStressEntity entity = stress.Create(order);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(stress.Location.X, entity.CoordinateX);
            Assert.AreEqual(stress.Location.Y, entity.CoordinateZ);

            VariationCoefficientLogNormalDistribution preconsolidationStressDistribution = stress.Stress;

            Assert.AreEqual(preconsolidationStressDistribution.Mean, entity.PreconsolidationStressMean,
                            preconsolidationStressDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationStressDistribution.CoefficientOfVariation, entity.PreconsolidationStressCoefficientOfVariation,
                            preconsolidationStressDistribution.GetAccuracy());
            Assert.AreEqual(order, entity.Order);
        }
Пример #5
0
        private static void AssertPreconsolidationStress(PreconsolidationStress preconsolidationStress,
                                                         MacroStabilityInwardsPreconsolidationStress transformedPreconsolidationStress)
        {
            Assert.AreEqual(preconsolidationStress.XCoordinate,
                            transformedPreconsolidationStress.Location.X);
            Assert.AreEqual(preconsolidationStress.ZCoordinate,
                            transformedPreconsolidationStress.Location.Y);

            VariationCoefficientLogNormalDistribution stressDistribution = transformedPreconsolidationStress.Stress;

            Assert.AreEqual(preconsolidationStress.StressMean, stressDistribution.Mean, stressDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationStress.StressCoefficientOfVariation, stressDistribution.CoefficientOfVariation, stressDistribution.GetAccuracy());
        }
Пример #6
0
        private static void AssertPreconsolidationStress(MacroStabilityInwardsPreconsolidationStress preconsolidationStress,
                                                         MacroStabilityInwardsPreconsolidationStressEntity entity)
        {
            Assert.AreEqual(preconsolidationStress.Location.X, entity.CoordinateX);
            Assert.AreEqual(preconsolidationStress.Location.Y, entity.CoordinateZ);

            VariationCoefficientLogNormalDistribution preconsolidationDistribution = preconsolidationStress.Stress;

            Assert.AreEqual(preconsolidationDistribution.Mean, entity.PreconsolidationStressMean,
                            preconsolidationDistribution.GetAccuracy());
            Assert.AreEqual(preconsolidationDistribution.CoefficientOfVariation, entity.PreconsolidationStressCoefficientOfVariation,
                            preconsolidationDistribution.GetAccuracy());
        }
        private static MacroStabilityInwardsPreconsolidationStress CopyAndModifyPreconsolidationsStress(
            MacroStabilityInwardsPreconsolidationStress preconsolidationStress)
        {
            var random           = new Random(29);
            var modifiedLocation = new Point2D(preconsolidationStress.Location.X + random.NextDouble(),
                                               preconsolidationStress.Location.Y);
            var distribution = new VariationCoefficientLogNormalDistribution
            {
                Mean = preconsolidationStress.Stress.Mean,
                CoefficientOfVariation = preconsolidationStress.Stress.CoefficientOfVariation
            };

            return(new MacroStabilityInwardsPreconsolidationStress(modifiedLocation, distribution));
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsPreconsolidationStressEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsPreconsolidationStress"/>.
        /// </summary>
        /// <param name="preconsolidationStress">PreconsolidationStress to create a database entity for.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsPreconsolidationStressEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="preconsolidationStress"/> is <c>null</c>.</exception>
        public static MacroStabilityInwardsPreconsolidationStressEntity Create(this MacroStabilityInwardsPreconsolidationStress preconsolidationStress,
                                                                               int order)
        {
            if (preconsolidationStress == null)
            {
                throw new ArgumentNullException(nameof(preconsolidationStress));
            }

            return(new MacroStabilityInwardsPreconsolidationStressEntity
            {
                CoordinateX = preconsolidationStress.Location.X,
                CoordinateZ = preconsolidationStress.Location.Y,
                PreconsolidationStressMean = preconsolidationStress.Stress.Mean.ToNaNAsNull(),
                PreconsolidationStressCoefficientOfVariation = preconsolidationStress.Stress.CoefficientOfVariation.ToNaNAsNull(),
                Order = order
            });
        }
Пример #9
0
        public void Convert_WithSoilProfile_ReturnSoilProfile()
        {
            // Setup
            var random = new Random(22);

            MacroStabilityInwardsSoilLayer2D soilLayer1 = CreateRandomSoilLayer(22, new[]
            {
                CreateRandomSoilLayer(23, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>()),
                CreateRandomSoilLayer(24, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>())
            });

            MacroStabilityInwardsSoilLayer2D soilLayer2 = CreateRandomSoilLayer(25, new[]
            {
                CreateRandomSoilLayer(26, new[]
                {
                    CreateRandomSoilLayer(27, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>())
                })
            });

            var preconsolidationStress = new MacroStabilityInwardsPreconsolidationStress(new Point2D(random.NextDouble(), random.NextDouble()),
                                                                                         new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)0.05,
                CoefficientOfVariation = random.NextRoundedDouble()
            });

            var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(
                new[]
            {
                soilLayer1,
                soilLayer2
            },
                new[]
            {
                preconsolidationStress
            });

            // Call
            SoilProfile soilProfile = SoilProfileConverter.Convert(profile);

            // Assert
            CalculatorInputAssert.AssertSoilProfile(profile, soilProfile);
        }
        public void GetPreconsolidationStress_ValidPreconsolidationStress_CreateDesignVariableForPreconsolidationStress()
        {
            // Setup
            var location           = new Point2D(random.NextDouble(), random.NextDouble());
            var stressDistribution = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)0.005,
                CoefficientOfVariation = (RoundedDouble)coefficientOfVariation
            };

            var preconsolidationStress = new MacroStabilityInwardsPreconsolidationStress(location, stressDistribution);

            // Call
            VariationCoefficientDesignVariable <VariationCoefficientLogNormalDistribution> preconsoldationStress =
                MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPreconsolidationStress(preconsolidationStress);

            // Assert
            DistributionAssert.AreEqual(preconsolidationStress.Stress, preconsoldationStress.Distribution);
            AssertPercentile(0.05, preconsoldationStress);
        }
Пример #11
0
        public void Create_WithNaNValues_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var random = new Random(31);

            var stress = new MacroStabilityInwardsPreconsolidationStress(new Point2D(random.NextDouble(), random.NextDouble()),
                                                                         new VariationCoefficientLogNormalDistribution
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            });
            int order = random.Next();

            // Call
            MacroStabilityInwardsPreconsolidationStressEntity entity = stress.Create(order);

            // Assert
            Assert.IsNotNull(entity);
            Assert.IsNull(entity.PreconsolidationStressMean);
            Assert.IsNull(entity.PreconsolidationStressCoefficientOfVariation);
            Assert.AreEqual(order, entity.Order);
        }
        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);
        }