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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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());
        }
        /// <summary>
        /// Reads the <see cref="MacroStabilityInwardsPreconsolidationStressEntity"/> and use the information
        /// to construct a <see cref="MacroStabilityInwardsPreconsolidationStress"/>.
        /// </summary>
        /// <param name="entity">The <see cref="MacroStabilityInwardsPreconsolidationStressEntity"/> to create
        /// <see cref="MacroStabilityInwardsPreconsolidationStress"/> for.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsPreconsolidationStress"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/> is <c>null</c>.</exception>
        public static MacroStabilityInwardsPreconsolidationStress Read(this MacroStabilityInwardsPreconsolidationStressEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var location     = new Point2D(entity.CoordinateX, entity.CoordinateZ);
            var distribution = new VariationCoefficientLogNormalDistribution
            {
                Mean = (RoundedDouble)entity.PreconsolidationStressMean.ToNullAsNaN(),
                CoefficientOfVariation = (RoundedDouble)entity.PreconsolidationStressCoefficientOfVariation.ToNullAsNaN()
            };

            return(new MacroStabilityInwardsPreconsolidationStress(location, distribution));
        }
Ejemplo n.º 5
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 Read_WithCollector_ReturnsSoilProfileWithPropertiesSet()
        {
            // Setup
            Ring outerRingA = RingTestFactory.CreateRandomRing(32);
            Ring outerRingB = RingTestFactory.CreateRandomRing(33);

            var random = new Random(31);
            var preconsolidationStressEntity = new MacroStabilityInwardsPreconsolidationStressEntity
            {
                CoordinateX = random.NextDouble(),
                CoordinateZ = random.NextDouble(),
                PreconsolidationStressMean = random.NextDouble(),
                PreconsolidationStressCoefficientOfVariation = random.NextDouble(),
                Order = 1
            };

            var point2DXmlSerializer = new Point2DCollectionXmlSerializer();
            var entity = new MacroStabilityInwardsSoilProfileTwoDEntity
            {
                Name = nameof(MacroStabilityInwardsSoilProfileTwoDEntity),
                MacroStabilityInwardsSoilLayerTwoDEntities =
                {
                    new MacroStabilityInwardsSoilLayerTwoDEntity
                    {
                        MaterialName = "A",
                        OuterRingXml = point2DXmlSerializer.ToXml(outerRingA.Points),
                        Order        = 1
                    },
                    new MacroStabilityInwardsSoilLayerTwoDEntity
                    {
                        MaterialName = "B",
                        OuterRingXml = point2DXmlSerializer.ToXml(outerRingB.Points),
                        Order        = 0
                    }
                },
                MacroStabilityInwardsPreconsolidationStressEntities =
                {
                    preconsolidationStressEntity,
                    new MacroStabilityInwardsPreconsolidationStressEntity
                    {
                        Order = 0
                    }
                }
            };
            var collector = new ReadConversionCollector();

            // Call
            MacroStabilityInwardsSoilProfile2D profile = entity.Read(collector);

            // Assert
            Assert.IsNotNull(profile);
            Assert.AreEqual(entity.Name, profile.Name);
            CollectionAssert.AreEqual(new[]
            {
                "B",
                "A"
            }, profile.Layers.Select(l => l.Data.MaterialName));

            CollectionAssert.AreEqual(new[]
            {
                outerRingB,
                outerRingA
            }, profile.Layers.Select(l => l.OuterRing));

            profile.Layers.Select(l => l.NestedLayers).ForEachElementDo(CollectionAssert.IsEmpty);

            CollectionAssert.AreEqual(new[]
            {
                new MacroStabilityInwardsPreconsolidationStress(new Point2D(0, 0),
                                                                new VariationCoefficientLogNormalDistribution
                {
                    Mean = RoundedDouble.NaN,
                    CoefficientOfVariation = RoundedDouble.NaN
                }),
                new MacroStabilityInwardsPreconsolidationStress(new Point2D(preconsolidationStressEntity.CoordinateX,
                                                                            preconsolidationStressEntity.CoordinateZ),
                                                                new VariationCoefficientLogNormalDistribution
                {
                    Mean = (RoundedDouble)preconsolidationStressEntity.PreconsolidationStressMean.ToNullAsNaN(),
                    CoefficientOfVariation = (RoundedDouble)preconsolidationStressEntity.PreconsolidationStressCoefficientOfVariation.ToNullAsNaN()
                })
            }, profile.PreconsolidationStresses);
        }