/// <summary>
        /// Creates a <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsSoilProfile2D"/>.
        /// </summary>
        /// <param name="soilProfile">The soil profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> or one from the
        /// <paramref name="registry"/> if it was created for the <see cref="soilProfile"/> earlier.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilProfileTwoDEntity Create(this MacroStabilityInwardsSoilProfile2D soilProfile,
                                                                        PersistenceRegistry registry)
        {
            if (soilProfile == null)
            {
                throw new ArgumentNullException(nameof(soilProfile));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(soilProfile))
            {
                return(registry.Get(soilProfile));
            }

            var entity = new MacroStabilityInwardsSoilProfileTwoDEntity
            {
                Name = soilProfile.Name.DeepClone()
            };

            AddEntitiesForSoilLayers(soilProfile.Layers, entity);
            AddEntitiesForPreconsolidationStresses(soilProfile.PreconsolidationStresses, entity);

            registry.Register(entity, soilProfile);
            return(entity);
        }
        public void Constructor_WithNameAndLayers_ReturnsInstanceWithPropsAndEquivalentLayerCollection()
        {
            // Setup
            const string name   = "Profile";
            var          layers = new Collection <MacroStabilityInwardsSoilLayer2D>
            {
                CreateRandomLayer(21)
            };

            MacroStabilityInwardsPreconsolidationStress[] preconsolidationStresses =
            {
                CreateRandomPreconsolidationStress(30)
            };

            // Call
            var profile = new MacroStabilityInwardsSoilProfile2D(name, layers, preconsolidationStresses);

            // Assert
            Assert.IsInstanceOf <IMacroStabilityInwardsSoilProfile <MacroStabilityInwardsSoilLayer2D> >(profile);
            Assert.AreNotSame(layers, profile.Layers);
            TestHelper.AssertCollectionsAreEqual(layers, profile.Layers,
                                                 new ReferenceEqualityComparer <MacroStabilityInwardsSoilLayer2D>());
            Assert.AreNotSame(preconsolidationStresses, profile.PreconsolidationStresses);
            TestHelper.AssertCollectionsAreEqual(preconsolidationStresses, profile.PreconsolidationStresses,
                                                 new ReferenceEqualityComparer <MacroStabilityInwardsPreconsolidationStress>());
            Assert.AreEqual(name, profile.Name);
        }
Esempio n. 3
0
        private static bool ValidateSurfaceLineIsNearSoilProfile(MacroStabilityInwardsInput inputParameters,
                                                                 MacroStabilityInwardsSoilProfile2D soilProfile2D)
        {
            IEnumerable <double> discretizedSurfaceLineXCoordinates = GetClippedDiscretizedXCoordinatesOfSurfaceLine(inputParameters.SurfaceLine.LocalGeometry,
                                                                                                                     soilProfile2D);
            IEnumerable <Point2D> surfaceLineWithInterpolations = GetSurfaceLineWithInterpolations(inputParameters, discretizedSurfaceLineXCoordinates);

            IEnumerable <IEnumerable <Segment2D> > layerPolygons = GetLayerPolygons(soilProfile2D);

            foreach (Point2D surfaceLinePoint in surfaceLineWithInterpolations)
            {
                IEnumerable <Point2D> intersectingCoordinates = layerPolygons.SelectMany(lp => Math2D.SegmentsIntersectionWithVerticalLine(lp, surfaceLinePoint.X));
                if (!intersectingCoordinates.Any())
                {
                    return(false);
                }

                double maxYCoordinate = intersectingCoordinates.Select(p => p.Y).Max();
                if (Math.Abs(surfaceLinePoint.Y - maxYCoordinate) - withinSurfaceLineLevelLimit >= 1e-5)
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Reads the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> and use the information
        /// to construct a <see cref="MacroStabilityInwardsSoilProfile2D"/>.
        /// </summary>
        /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> to
        /// create <see cref="MacroStabilityInwardsSoilProfile2D"/> for.</param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfile2D"/> or one from the <paramref name="collector"/>
        /// if the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> has been read before.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilProfile2D Read(this MacroStabilityInwardsSoilProfileTwoDEntity entity,
                                                              ReadConversionCollector collector)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            if (collector.Contains(entity))
            {
                return(collector.Get(entity));
            }

            IEnumerable <MacroStabilityInwardsSoilLayer2D> layers = entity.MacroStabilityInwardsSoilLayerTwoDEntities
                                                                    .OrderBy(sl => sl.Order)
                                                                    .Select(sl => sl.Read())
                                                                    .ToArray();
            IEnumerable <MacroStabilityInwardsPreconsolidationStress> preconsolidationStresses = entity.MacroStabilityInwardsPreconsolidationStressEntities
                                                                                                 .OrderBy(stressEntity => stressEntity.Order)
                                                                                                 .Select(stressEntity => stressEntity.Read())
                                                                                                 .ToArray();
            var soilProfile = new MacroStabilityInwardsSoilProfile2D(entity.Name,
                                                                     layers,
                                                                     preconsolidationStresses);

            collector.Read(entity, soilProfile);
            return(soilProfile);
        }
Esempio n. 5
0
        public void Validate_SurfaceLineNotNear2DProfile_ReturnsError(MacroStabilityInwardsSoilProfile2D soilProfile)
        {
            // Setup

            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0.0, 10),
                new Point3D(1, 0.0, 20),
                new Point3D(2, 0.0, 10)
            });

            input.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0,
                                                                                         soilProfile);
            input.SurfaceLine = surfaceLine;

            // Call
            IEnumerable <string> messages = MacroStabilityInwardsInputValidator.Validate(input,
                                                                                         AssessmentSectionTestHelper.GetTestAssessmentLevel()).ToArray();

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                "De profielschematisatie moet op de ondergrondschematisatie liggen."
            }, messages);
        }
Esempio n. 6
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            MacroStabilityInwardsSoilProfile2D soilProfile = CreateMacroStabilityInwardsSoilProfile2D("some name");
            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsSoilProfileTwoDEntity entity = soilProfile.Create(registry);

            // Assert
            TestHelper.AssertAreEqualButNotSame(soilProfile.Name, entity.Name);
        }
Esempio n. 7
0
        public void Create_PersistenceRegistryNull_ThrowsArgumentNullException()
        {
            // Setup
            MacroStabilityInwardsSoilProfile2D soilProfile = CreateMacroStabilityInwardsSoilProfile2D();

            // Call
            TestDelegate test = () => soilProfile.Create(null);

            // Assert
            string parameterName = Assert.Throws <ArgumentNullException>(test).ParamName;

            Assert.AreEqual("registry", parameterName);
        }
Esempio n. 8
0
        public void GivenCreatedEntity_WhenCreateCalledOnSameObject_ThenSameEntityInstanceReturned()
        {
            // Given
            MacroStabilityInwardsSoilProfile2D soilProfile = CreateMacroStabilityInwardsSoilProfile2D();
            var registry = new PersistenceRegistry();

            MacroStabilityInwardsSoilProfileTwoDEntity firstEntity = soilProfile.Create(registry);

            // When
            MacroStabilityInwardsSoilProfileTwoDEntity secondEntity = soilProfile.Create(registry);

            // Then
            Assert.AreSame(firstEntity, secondEntity);
        }
        public void ToString_WithName_ReturnsName(string name)
        {
            // Setup
            var profile = new MacroStabilityInwardsSoilProfile2D(name, new[]
            {
                CreateRandomLayer(2)
            }, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>());

            // Call
            var text = profile.ToString();

            // Assert
            Assert.AreEqual(name, text);
        }
Esempio n. 10
0
        public void Validate_SurfaceLineNear2DProfileWithFloatingLayerDefinitions_ReturnsError()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0.0, 20),
                new Point3D(20, 0.0, 20)
            });

            var soilProfile = new MacroStabilityInwardsSoilProfile2D(
                "profile",
                new[]
            {
                new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
                {
                    new Point2D(0, 20),
                    new Point2D(5, 20),
                    new Point2D(5, 15),
                    new Point2D(20, 15),
                    new Point2D(20, 10),
                    new Point2D(0, 10)
                })),
                new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
                {
                    new Point2D(10, 17),
                    new Point2D(10, 20),
                    new Point2D(20, 20),
                    new Point2D(20, 17)
                }))
            }, new MacroStabilityInwardsPreconsolidationStress[0]);

            input.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0,
                                                                                         soilProfile);
            input.SurfaceLine = surfaceLine;

            // Call
            IEnumerable <string> messages = MacroStabilityInwardsInputValidator.Validate(input,
                                                                                         AssessmentSectionTestHelper.GetTestAssessmentLevel()).ToArray();

            // Assert
            CollectionAssert.AreEqual(new[]
            {
                "De profielschematisatie moet op de ondergrondschematisatie liggen."
            }, messages);
        }
        public void SoilProfile2DCreate_ProfileWithData_ReturnsSoilProfileUnderSurfaceLine()
        {
            // Setup
            var profile = new MacroStabilityInwardsSoilProfile2D("name",
                                                                 new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
            },
                                                                 Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>());

            // Call
            MacroStabilityInwardsSoilProfileUnderSurfaceLine profileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(profile, new MacroStabilityInwardsSurfaceLine(string.Empty));

            // Assert
            Assert.AreSame(profile.Layers, profileUnderSurfaceLine.Layers);
            Assert.AreSame(profile.PreconsolidationStresses, profileUnderSurfaceLine.PreconsolidationStresses);
        }
Esempio n. 12
0
        public void Validate_SurfaceLineNear2DProfileWithLayersWithTriangularXCoordinateDefinitions_ReturnsEmpty()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0, 0.0, 10),
                new Point3D(10, 0.0, 20),
                new Point3D(20, 0.0, 10)
            });

            var soilProfile = new MacroStabilityInwardsSoilProfile2D(
                "profile",
                new[]
            {
                new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
                {
                    new Point2D(0, 10),
                    new Point2D(10, 20),
                    new Point2D(20, 10)
                })),
                new MacroStabilityInwardsSoilLayer2D(new Ring(new[]
                {
                    new Point2D(0, 10),
                    new Point2D(5, 15),
                    new Point2D(7.5, 10),
                    new Point2D(12.5, 10),
                    new Point2D(15, 15),
                    new Point2D(20, 10)
                }))
            }, new MacroStabilityInwardsPreconsolidationStress[0]);

            input.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0,
                                                                                         soilProfile);
            input.SurfaceLine = surfaceLine;

            // Call
            IEnumerable <string> messages = MacroStabilityInwardsInputValidator.Validate(input,
                                                                                         AssessmentSectionTestHelper.GetTestAssessmentLevel()).ToArray();

            // Assert
            CollectionAssert.IsEmpty(messages);
        }
Esempio n. 13
0
        public void GetProperties_WithSoilProfile2D_ReturnExpectedValues()
        {
            // Setup
            var    random      = new Random(21);
            double probability = random.NextDouble();

            MacroStabilityInwardsSoilLayer2D layerOne = CreateMacroStabilityInwardsSoilLayer2D();
            MacroStabilityInwardsSoilLayer2D layerTwo = CreateMacroStabilityInwardsSoilLayer2D();

            MacroStabilityInwardsSoilLayer2D[] layers =
            {
                layerOne,
                layerTwo
            };

            MacroStabilityInwardsPreconsolidationStress[] stresses =
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress()
            };

            var soilProfile           = new MacroStabilityInwardsSoilProfile2D("<some name>", layers, stresses);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(probability, soilProfile);

            // Call
            var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Assert
            Assert.AreEqual(soilProfile.Name, properties.Name);
            Assert.AreEqual(soilProfile.Name, properties.ToString());

            Assert.AreEqual(layers.Length, properties.Layers2D.Length);
            Assert.AreSame(layerOne, properties.Layers2D[0].Data);
            Assert.AreSame(layerTwo, properties.Layers2D[1].Data);

            CollectionAssert.IsEmpty(properties.Layers1D);
            Assert.AreEqual(double.NaN, properties.Bottom);
            Assert.AreEqual(2, properties.Probability.NumberOfDecimalPlaces);
            Assert.AreEqual(probability * 100, properties.Probability, properties.Probability.GetAccuracy());
            Assert.AreEqual("2D profiel", properties.Type);

            Assert.AreEqual(stresses.Length, properties.PreconsolidationStresses.Length);
            Assert.AreSame(stresses[0], properties.PreconsolidationStresses[0].Data);
        }
Esempio n. 14
0
        public void Create_DifferentStochasticSoilProfilesWithSameMacroStabilityInwardsSoilProfile2D_ReturnsEntityWithSameSoilProfileEntitySet()
        {
            // Setup
            var random = new Random(31);

            MacroStabilityInwardsSoilProfile2D soilProfile = MacroStabilityInwardsSoilProfile2DTestFactory.CreateMacroStabilityInwardsSoilProfile2D();
            var firstStochasticSoilProfile  = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(), soilProfile);
            var secondStochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(), soilProfile);
            var registry = new PersistenceRegistry();

            MacroStabilityInwardsStochasticSoilProfileEntity firstEntity = firstStochasticSoilProfile.Create(registry, 0);

            // Call
            MacroStabilityInwardsStochasticSoilProfileEntity secondEntity = secondStochasticSoilProfile.Create(registry, 0);

            // Assert
            Assert.IsNull(firstEntity.MacroStabilityInwardsSoilProfileOneDEntity);
            Assert.IsNull(secondEntity.MacroStabilityInwardsSoilProfileOneDEntity);
            Assert.AreSame(firstEntity.MacroStabilityInwardsSoilProfileTwoDEntity, secondEntity.MacroStabilityInwardsSoilProfileTwoDEntity);
        }
        public void GivenReadObject_WhenReadCalledOnSameEntity_ThenSameObjectInstanceReturned()
        {
            // Given
            var entity = new MacroStabilityInwardsSoilProfileTwoDEntity
            {
                Name = "testName",
                MacroStabilityInwardsSoilLayerTwoDEntities =
                {
                    MacroStabilityInwardsSoilLayerTwoDEntityTestFactory.CreateMacroStabilityInwardsSoilLayerTwoDEntity()
                }
            };
            var collector = new ReadConversionCollector();

            MacroStabilityInwardsSoilProfile2D profile = entity.Read(collector);

            // When
            MacroStabilityInwardsSoilProfile2D secondProfile = entity.Read(collector);

            // Then
            Assert.AreSame(profile, secondProfile);
        }
Esempio n. 16
0
        public void Create_WithMacroStabilityInwardsSoilProfile2D_ReturnsStochasticSoilProfileEntityWithPropertiesSet()
        {
            // Setup
            var random = new Random(31);
            MacroStabilityInwardsSoilProfile2D soilProfile =
                MacroStabilityInwardsSoilProfile2DTestFactory.CreateMacroStabilityInwardsSoilProfile2D();
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(), soilProfile);

            int order = random.Next();

            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsStochasticSoilProfileEntity entity = stochasticSoilProfile.Create(registry, order);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(stochasticSoilProfile.Probability, entity.Probability);
            Assert.IsNull(entity.MacroStabilityInwardsSoilProfileOneDEntity);
            Assert.AreEqual(soilProfile.Name, entity.MacroStabilityInwardsSoilProfileTwoDEntity.Name);
            Assert.AreEqual(order, entity.Order);
        }
Esempio n. 17
0
        public void Validate_SurfaceLineNear2DProfile_ReturnsEmpty(MacroStabilityInwardsSoilProfile2D soilProfile)
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test");

            surfaceLine.SetGeometry(new[]
            {
                new Point3D(0.0, 0.0, 10),
                new Point3D(0.1, 0.0, 20),
                new Point3D(0.2, 0.0, 10)
            });

            input.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0,
                                                                                         soilProfile);
            input.SurfaceLine = surfaceLine;

            // Call
            IEnumerable <string> messages = MacroStabilityInwardsInputValidator.Validate(input,
                                                                                         AssessmentSectionTestHelper.GetTestAssessmentLevel()).ToArray();

            // Assert
            CollectionAssert.IsEmpty(messages);
        }
Esempio n. 18
0
        public void DynamicVisibleValidationMethod_WithSoilProfile2D_Only2DPropertiesVisible()
        {
            // Setup
            IEnumerable <MacroStabilityInwardsSoilLayer2D> layers = new[]
            {
                CreateMacroStabilityInwardsSoilLayer2D()
            };

            var soilProfile           = new MacroStabilityInwardsSoilProfile2D("name", layers, Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>());
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.2, soilProfile);
            var properties            = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile);

            // Call
            bool bottomVisible   = properties.DynamicVisibleValidationMethod("Bottom");
            bool layers1DVisible = properties.DynamicVisibleValidationMethod("Layers1D");
            bool layers2DVisible = properties.DynamicVisibleValidationMethod("Layers2D");
            bool preconsolidationStressesVisible = properties.DynamicVisibleValidationMethod("PreconsolidationStresses");

            // Assert
            Assert.IsFalse(bottomVisible);
            Assert.IsFalse(layers1DVisible);
            Assert.IsTrue(layers2DVisible);
            Assert.IsTrue(preconsolidationStressesVisible);
        }
Esempio n. 19
0
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var soilProfile = new MacroStabilityInwardsSoilProfile2D("some name", new[]
            {
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(),
                MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D()
            }, new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress()
            });
            var registry = new PersistenceRegistry();

            // Call
            MacroStabilityInwardsSoilProfileTwoDEntity entity = soilProfile.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(soilProfile.Layers.Count(), entity.MacroStabilityInwardsSoilLayerTwoDEntities.Count);
            Assert.AreEqual(soilProfile.PreconsolidationStresses.Count(), entity.MacroStabilityInwardsPreconsolidationStressEntities.Count);

            AssertPreconsolidationStress(soilProfile.PreconsolidationStresses.First(),
                                         entity.MacroStabilityInwardsPreconsolidationStressEntities.First());
        }
Esempio n. 20
0
 private static IEnumerable <IEnumerable <Segment2D> > GetLayerPolygons(MacroStabilityInwardsSoilProfile2D soilProfile2D)
 {
     return(soilProfile2D.Layers
            .Select(l => Math2D.ConvertPointsToPolygonSegments(l.OuterRing.Points))
            .ToArray());
 }
Esempio n. 21
0
        private static IEnumerable <double> GetClippedDiscretizedXCoordinatesOfSurfaceLine(IEnumerable <Point2D> surfaceLinePoints,
                                                                                           MacroStabilityInwardsSoilProfile2D soilProfile2D)
        {
            IEnumerable <double> surfaceLineXCoordinates = surfaceLinePoints.Select(p => p.X).ToArray();
            IEnumerable <double> soilProfileXCoordinates = GetSoilProfile2DXCoordinates(soilProfile2D).ToArray();

            double maximumXCoordinateSurfaceLine = surfaceLineXCoordinates.Max();
            double maximumXCoordinateSoilProfile = soilProfileXCoordinates.Max();
            double maxXCoordinate = Math.Min(maximumXCoordinateSoilProfile, maximumXCoordinateSurfaceLine);

            double minimumXCoordinateSurfaceLine = surfaceLineXCoordinates.Min();
            double minimumXCoordinateSoilProfile = soilProfileXCoordinates.Min();
            double minXCoordinate = Math.Max(minimumXCoordinateSoilProfile, minimumXCoordinateSurfaceLine);

            IEnumerable <double> clippedSoilProfileXCoordinates = soilProfileXCoordinates.Where(xCoordinate => IsXCoordinateInRange(xCoordinate, minXCoordinate, maxXCoordinate));
            IEnumerable <double> clippedSurfaceLineXCoordinates = surfaceLineXCoordinates.Where(xCoordinate => IsXCoordinateInRange(xCoordinate, minXCoordinate, maxXCoordinate));

            double[] uniqueClippedXCoordinates = clippedSoilProfileXCoordinates.Concat(clippedSurfaceLineXCoordinates)
                                                 .Distinct()
                                                 .OrderBy(xCoordinate => xCoordinate)
                                                 .ToArray();

            var xCoordinates = new List <double>();

            for (var i = 0; i < uniqueClippedXCoordinates.Length - 1; i++)
            {
                double firstXCoordinate  = uniqueClippedXCoordinates[i];
                double secondXCoordinate = uniqueClippedXCoordinates[i + 1];

                xCoordinates.AddRange(GetDiscretizedXCoordinatesBetweenInterval(firstXCoordinate, secondXCoordinate));
            }

            xCoordinates.Add(uniqueClippedXCoordinates.Last());

            return(xCoordinates);
        }
Esempio n. 22
0
 /// <summary>
 /// Obtains the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> which was registered for the given
 /// <paramref name="model"/>.
 /// </summary>
 /// <param name="model">The <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> for which a create
 /// operation has been registered.</param>
 /// <returns>The constructed <see cref="MacroStabilityInwardsSoilProfile2D"/>.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="model"/> is <c>null</c>.</exception>
 /// <exception cref="InvalidOperationException">Thrown when no create operation
 /// has been registered for <paramref name="model"/>.</exception>
 /// <remarks>Use <see cref="Contains(MacroStabilityInwardsSoilProfile2D)"/> to find out whether a
 /// create operation has been registered for <paramref name="model"/>.</remarks>
 internal MacroStabilityInwardsSoilProfileTwoDEntity Get(MacroStabilityInwardsSoilProfile2D model)
 {
     return(Get(macroStabilityInwardsSoil2DProfiles, model));
 }
Esempio n. 23
0
 /// <summary>
 /// Checks whether a create operations has been registered for the given <paramref name="model"/>.
 /// </summary>
 /// <param name="model">The <see cref="MacroStabilityInwardsSoilProfile2D"/> to check for.</param>
 /// <returns><c>true</c> if the <see cref="model"/> was registered before, <c>false</c> otherwise.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="model"/> is <c>null</c>.</exception>
 internal bool Contains(MacroStabilityInwardsSoilProfile2D model)
 {
     return(ContainsValue(macroStabilityInwardsSoil2DProfiles, model));
 }
Esempio n. 24
0
 /// <summary>
 /// Registers a create operation for <paramref name="model"/> and the <paramref name="entity"/>
 /// that was constructed with the information.
 /// </summary>
 /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> to be registered.</param>
 /// <param name="model">The <see cref="MacroStabilityInwardsSoilProfile2D"/> to be registered.</param>
 /// <exception cref="ArgumentNullException">Thrown when any of the input parameters is <c>null</c>.</exception>
 internal void Register(MacroStabilityInwardsSoilProfileTwoDEntity entity, MacroStabilityInwardsSoilProfile2D model)
 {
     Register(macroStabilityInwardsSoil2DProfiles, entity, model);
 }
        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);
        }