Exemple #1
0
 private static void AddNestedLayers(MacroStabilityInwardsSoilLayerTwoDEntity entity,
                                     MacroStabilityInwardsSoilLayer2D soilLayer)
 {
     for (var i = 0; i < soilLayer.NestedLayers.Count(); i++)
     {
         entity.MacroStabilityInwardsSoilLayerTwoDEntity1.Add(soilLayer.NestedLayers.ElementAt(i).Create(i));
     }
 }
Exemple #2
0
        /// <summary>
        /// Adds an <see cref="MacroStabilityInwardsSoilLayer2D"/> to the registry.
        /// </summary>
        /// <param name="soilLayer">The soil layer to register.</param>
        /// <param name="id">The id of the soil.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/>
        /// is <c>null</c>.</exception>
        public void AddSoil(MacroStabilityInwardsSoilLayer2D soilLayer, string id)
        {
            if (soilLayer == null)
            {
                throw new ArgumentNullException(nameof(soilLayer));
            }

            soils.Add(soilLayer, id);
        }
Exemple #3
0
 private static PersistableSoilLayer Create(MacroStabilityInwardsSoilLayer2D layer, MacroStabilityInwardsExportStageType stageType,
                                            MacroStabilityInwardsExportRegistry registry)
 {
     return(new PersistableSoilLayer
     {
         LayerId = registry.GeometryLayers[stageType][layer],
         SoilId = registry.Soils[layer]
     });
 }
Exemple #4
0
 /// <summary>
 /// Create an area of the outer ring in 2D space based on the provided <paramref name="soilLayer"/>.
 /// </summary>
 /// <param name="soilLayer">The soil layer to create the outer ring for.</param>
 /// <returns>A collection containing a single collection of points in 2D space
 /// or an empty collection when <paramref name="soilLayer"/> is <c>null</c>.</returns>
 public static IEnumerable <IEnumerable <Point2D> > CreateOuterRingArea(MacroStabilityInwardsSoilLayer2D soilLayer)
 {
     return(soilLayer != null
                ? new IEnumerable <Point2D>[]
     {
         soilLayer.OuterRing.Points.ToArray()
     }
                : Enumerable.Empty <IEnumerable <Point2D> >());
 }
Exemple #5
0
        public void Read_WithValues_ReturnsMacroStabilityInwardsSoilLayer2DWithDoubleParameterValues()
        {
            // Setup
            MacroStabilityInwardsSoilLayerTwoDEntity entity = CreateMacroStabilityInwardsSoilLayerTwoDEntity();

            // Call
            MacroStabilityInwardsSoilLayer2D layer = entity.Read();

            // Assert
            AssertMacroStabilityInwardsSoilLayer2D(entity, layer);
        }
 private static MacroStabilityInwardsSoilLayer2D CopyAndModifySoilLayer(MacroStabilityInwardsSoilLayer2D soilLayer)
 {
     return(new MacroStabilityInwardsSoilLayer2D(soilLayer.OuterRing,
                                                 new MacroStabilityInwardsSoilLayerData
     {
         Color = soilLayer.Data.Color
     },
                                                 new[]
     {
         soilLayer.NestedLayers.ElementAt(0)
     }));
 }
Exemple #7
0
        private static void AssertMacroStabilityInwardsSoilLayer2D(MacroStabilityInwardsSoilLayerTwoDEntity entity,
                                                                   MacroStabilityInwardsSoilLayer2D layer)
        {
            Assert.IsNotNull(layer);
            MacroStabilityInwardsSoilLayerData data = layer.Data;

            Assert.AreEqual(Convert.ToBoolean(entity.IsAquifer), data.IsAquifer);
            Assert.AreEqual(entity.Color, data.Color.ToInt64());
            Assert.AreEqual(entity.MaterialName, data.MaterialName);

            Assert.AreEqual(entity.AbovePhreaticLevelMean ?? double.NaN, data.AbovePhreaticLevel.Mean,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.AbovePhreaticLevelCoefficientOfVariation ?? double.NaN, data.AbovePhreaticLevel.CoefficientOfVariation,
                            data.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.AbovePhreaticLevelShift ?? double.NaN, data.AbovePhreaticLevel.Shift,
                            data.AbovePhreaticLevel.GetAccuracy());

            Assert.AreEqual(entity.BelowPhreaticLevelMean ?? double.NaN, data.BelowPhreaticLevel.Mean,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.BelowPhreaticLevelCoefficientOfVariation ?? double.NaN, data.BelowPhreaticLevel.CoefficientOfVariation,
                            data.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(entity.BelowPhreaticLevelShift ?? double.NaN, data.BelowPhreaticLevel.Shift,
                            data.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(entity.CohesionMean ?? double.NaN, data.Cohesion.Mean,
                            data.Cohesion.GetAccuracy());
            Assert.AreEqual(entity.CohesionCoefficientOfVariation ?? double.NaN, data.Cohesion.CoefficientOfVariation,
                            data.Cohesion.GetAccuracy());

            Assert.AreEqual(entity.FrictionAngleMean ?? double.NaN, data.FrictionAngle.Mean,
                            data.FrictionAngle.GetAccuracy());
            Assert.AreEqual(entity.FrictionAngleCoefficientOfVariation ?? double.NaN, data.FrictionAngle.CoefficientOfVariation,
                            data.FrictionAngle.GetAccuracy());

            Assert.AreEqual(entity.ShearStrengthRatioMean ?? double.NaN, data.ShearStrengthRatio.Mean,
                            data.ShearStrengthRatio.GetAccuracy());
            Assert.AreEqual(entity.ShearStrengthRatioCoefficientOfVariation ?? double.NaN, data.ShearStrengthRatio.CoefficientOfVariation,
                            data.ShearStrengthRatio.GetAccuracy());

            Assert.AreEqual(entity.StrengthIncreaseExponentMean ?? double.NaN, data.StrengthIncreaseExponent.Mean,
                            data.StrengthIncreaseExponent.GetAccuracy());
            Assert.AreEqual(entity.StrengthIncreaseExponentCoefficientOfVariation ?? double.NaN, data.StrengthIncreaseExponent.CoefficientOfVariation,
                            data.StrengthIncreaseExponent.GetAccuracy());

            Assert.AreEqual(entity.PopMean ?? double.NaN, data.Pop.Mean, data.Pop.GetAccuracy());
            Assert.AreEqual(entity.PopCoefficientOfVariation ?? double.NaN, data.Pop.CoefficientOfVariation,
                            data.Pop.GetAccuracy());

            CollectionAssert.AreEqual(new Point2DCollectionXmlSerializer().FromXml(entity.OuterRingXml),
                                      layer.OuterRing.Points);
            CollectionAssert.IsEmpty(layer.NestedLayers);
        }
Exemple #8
0
        public void GetProperties_WithDataEmptyName_ReturnExpectedValues()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            layer.Data.MaterialName = string.Empty;

            // Call
            var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer);

            // Assert
            Assert.AreEqual("Onbekend", properties.Name);
        }
Exemple #9
0
        public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet()
        {
            // Setup
            var random = new Random(31);
            MacroStabilityInwardsSoilLayer2D soilLayer = CreateMacroStabilityInwardsSoilLayer2D();
            int order = random.Next();

            // Call
            MacroStabilityInwardsSoilLayerTwoDEntity entity = soilLayer.Create(order);

            // Assert
            AssertMacroStabilityInwardsSoilLayerTwoDEntity(soilLayer, entity, order);
        }
 private static PersistableStatePoint CreateYieldStressStatePoint(MacroStabilityInwardsSoilLayer2D layer, IMacroStabilityInwardsPreconsolidationStress preconsolidationStress,
                                                                  MacroStabilityInwardsExportStageType stageType, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
 {
     return(new PersistableStatePoint
     {
         Id = idFactory.Create(),
         LayerId = registry.GeometryLayers[stageType][layer],
         IsProbabilistic = false,
         Point = new PersistablePoint(preconsolidationStress.Location.X, preconsolidationStress.Location.Y),
         Stress = CreateYieldStress(preconsolidationStress),
         Label = string.Format(Resources.PersistableStateFactory_CreateStatePoint_PreconsolidationStress_LayerName_0, layer.Data.MaterialName)
     });
 }
Exemple #11
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);
        }
        private static PersistableLayer CreateLayer(MacroStabilityInwardsSoilLayer2D layer, MacroStabilityInwardsExportStageType stageType,
                                                    IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            var persistableLayer = new PersistableLayer
            {
                Id     = idFactory.Create(),
                Label  = layer.Data.MaterialName,
                Points = layer.OuterRing.Points.Select(p => new PersistablePoint(p.X, p.Y)).ToArray()
            };

            registry.AddGeometryLayer(stageType, layer, persistableLayer.Id);
            return(persistableLayer);
        }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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);
        }
Exemple #16
0
        public void Constructor_WithOuterRing_ReturnsNewInstance()
        {
            // Setup
            Ring outerRing = RingTestFactory.CreateRandomRing();

            // Call
            var layer = new MacroStabilityInwardsSoilLayer2D(outerRing);

            // Assert
            Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer);
            Assert.AreSame(outerRing, layer.OuterRing);
            Assert.IsNotNull(layer.Data);
            Assert.IsEmpty(layer.NestedLayers);
        }
Exemple #17
0
        public void ToString_ValidName_ReturnsMaterialName()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            layer.Data.MaterialName = "Layer A 2D";

            var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer);

            // Call
            string name = properties.ToString();

            // Assert
            Assert.AreEqual(layer.Data.MaterialName, name);
        }
Exemple #18
0
        public void Constructor_ValidMacroStabilityInwardsSoilLayer2D_ExpectedValues()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D soilLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            // Call
            var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(soilLayer);

            // Assert
            Assert.IsInstanceOf <MacroStabilityInwardsSoilLayer2DBaseProperties>(properties);
            TestHelper.AssertTypeConverter <MacroStabilityInwardsSoilLayer2DTopLevelProperties, ExpandableObjectConverter>();
            TestHelper.AssertTypeConverter <MacroStabilityInwardsSoilLayer2DTopLevelProperties,
                                            ExpandableArrayConverter>(nameof(MacroStabilityInwardsSoilLayer2DTopLevelProperties.NestedLayers));
            Assert.AreSame(soilLayer, properties.Data);
        }
        private static PersistableStatePoint CreatePOPStatePoint(MacroStabilityInwardsSoilLayer2D layer, MacroStabilityInwardsExportStageType stageType,
                                                                 IdFactory idFactory, MacroStabilityInwardsExportRegistry registry)
        {
            Point2D interiorPoint = AdvancedMath2D.GetPolygonInteriorPoint(layer.OuterRing.Points, layer.NestedLayers.Select(layers => layers.OuterRing.Points));

            return(new PersistableStatePoint
            {
                Id = idFactory.Create(),
                LayerId = registry.GeometryLayers[stageType][layer],
                IsProbabilistic = true,
                Point = new PersistablePoint(interiorPoint.X, interiorPoint.Y),
                Stress = CreatePOPStress(layer.Data),
                Label = string.Format(Resources.PersistableStateFactory_CreateStatePoint_POP_LayerName_0, layer.Data.MaterialName)
            });
        }
Exemple #20
0
        public void ToString_EmptyName_ReturnsDefaultName()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            layer.Data.MaterialName = string.Empty;

            var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer);

            // Call
            string name = properties.ToString();

            // Assert
            Assert.AreEqual("Onbekend", name);
        }
Exemple #21
0
        public void Constructor_WithOuterRingDataAndNestedLayers_ReturnsNewInstance()
        {
            // Setup
            Ring outerRing = RingTestFactory.CreateRandomRing();
            var  data      = new MacroStabilityInwardsSoilLayerData();
            IEnumerable <MacroStabilityInwardsSoilLayer2D> nestedLayers = Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>();

            // Call
            var layer = new MacroStabilityInwardsSoilLayer2D(outerRing, data, nestedLayers);

            // Assert
            Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer);
            Assert.AreSame(outerRing, layer.OuterRing);
            Assert.AreSame(data, layer.Data);
            Assert.AreSame(nestedLayers, layer.NestedLayers);
        }
Exemple #22
0
        public void CreateSoilLayerChartData_LayerWithEmptyNameAndColor_ReturnsEmptyChartDataCollectionWithExpectedStyling()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            layer.Data.MaterialName = string.Empty;
            layer.Data.Color        = Color.Empty;

            // Call
            ChartMultipleAreaData data = MacroStabilityInwardsChartDataFactory.CreateSoilLayerChartData(layer);

            // Assert
            CollectionAssert.IsEmpty(data.Areas);
            Assert.AreEqual("Onbekend", data.Name);
            AssertEqualStyle(data.Style, Color.White, Color.Black, 1, false);
        }
        public void AddGeometryLayer_InvalidStageType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D geometryLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            var registry = new MacroStabilityInwardsExportRegistry();
            const MacroStabilityInwardsExportStageType stageType = (MacroStabilityInwardsExportStageType)99;

            // Call
            void Call() => registry.AddGeometryLayer(stageType, geometryLayer, "1");

            // Assert
            string expectedMessage = $"The value of argument '{nameof(stageType)}' ({stageType}) is invalid for Enum type '{nameof(MacroStabilityInwardsExportStageType)}'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);
        }
Exemple #24
0
        /// <summary>
        /// Adds a geometry layer to the registry.
        /// </summary>
        /// <param name="stageType">The <see cref="MacroStabilityInwardsExportStageType"/>
        /// to register the geometry layer for.</param>
        /// <param name="geometryLayer">The geometry layer to register.</param>
        /// <param name="id">The id of the geometry layer.</param>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="stageType"/>
        /// has an invalid value.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="geometryLayer"/>
        /// is <c>null</c>.</exception>
        public void AddGeometryLayer(MacroStabilityInwardsExportStageType stageType, MacroStabilityInwardsSoilLayer2D geometryLayer, string id)
        {
            ValidateStageType(stageType);

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

            if (!geometryLayers.ContainsKey(stageType))
            {
                geometryLayers.Add(stageType, new Dictionary <MacroStabilityInwardsSoilLayer2D, string>());
            }

            geometryLayers[stageType].Add(geometryLayer, id);
        }
Exemple #25
0
        public void Constructor_ValidData_PropertiesHaveExpectedAttributeValues()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            // Call
            var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer);

            // Assert
            PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);

            Assert.AreEqual(4, dynamicProperties.Count);

            const string generalCategoryName = "Algemeen";

            PropertyDescriptor nameProperty = dynamicProperties[0];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
                                                                            generalCategoryName,
                                                                            "Naam",
                                                                            "De naam van de grondlaag.",
                                                                            true);

            PropertyDescriptor outerRingProperty = dynamicProperties[1];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(outerRingProperty,
                                                                            generalCategoryName,
                                                                            "Geometrie",
                                                                            "De geometrie van de buitenring van deze grondlaag.",
                                                                            true);

            PropertyDescriptor nestedLayersProperty = dynamicProperties[2];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nestedLayersProperty,
                                                                            generalCategoryName,
                                                                            "Uitsneden",
                                                                            "De uitsneden binnen deze grondlaag.",
                                                                            true);

            PropertyDescriptor isAquiferProperty = dynamicProperties[3];

            PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isAquiferProperty,
                                                                            generalCategoryName,
                                                                            "Is aquifer",
                                                                            "Geeft aan of deze grondlaag een watervoerende laag betreft.",
                                                                            true);
        }
        public void GetLayerForPreconsolidationStress_PreconsolidationStressNotInLayer_ReturnsNull()
        {
            // Setup
            MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[]
            {
                MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, -50))
            });

            MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile,
                                                                                                                                                          CreateSurfaceLine());

            // Call
            MacroStabilityInwardsSoilLayer2D layer = PersistableStateHelper.GetLayerForPreconsolidationStress(soilProfileUnderSurfaceLine.Layers, soilProfileUnderSurfaceLine.PreconsolidationStresses.First());

            // Assert
            Assert.IsNull(layer);
        }
Exemple #27
0
        private static void AssertSoilData(SoilLayer2D original, MacroStabilityInwardsSoilLayer2D actual)
        {
            Assert.AreEqual(original.MaterialName, actual.Data.MaterialName);
            Assert.AreEqual(original.IsAquifer.Equals(1.0), actual.Data.IsAquifer);
            Assert.AreEqual(Color.FromArgb(Convert.ToInt32(original.Color)), actual.Data.Color);

            MacroStabilityInwardsSoilLayerData soilLayerData = actual.Data;

            Assert.AreEqual(original.AbovePhreaticLevelMean, soilLayerData.AbovePhreaticLevel.Mean,
                            soilLayerData.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.AbovePhreaticLevelCoefficientOfVariation, soilLayerData.AbovePhreaticLevel.CoefficientOfVariation,
                            soilLayerData.AbovePhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.AbovePhreaticLevelShift, soilLayerData.AbovePhreaticLevel.Shift,
                            soilLayerData.AbovePhreaticLevel.GetAccuracy());

            Assert.AreEqual(original.BelowPhreaticLevelMean, soilLayerData.BelowPhreaticLevel.Mean,
                            soilLayerData.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.BelowPhreaticLevelCoefficientOfVariation, soilLayerData.BelowPhreaticLevel.CoefficientOfVariation,
                            soilLayerData.BelowPhreaticLevel.GetAccuracy());
            Assert.AreEqual(original.BelowPhreaticLevelShift, soilLayerData.BelowPhreaticLevel.Shift,
                            soilLayerData.BelowPhreaticLevel.GetAccuracy());

            Assert.AreEqual(original.CohesionMean, soilLayerData.Cohesion.Mean,
                            soilLayerData.Cohesion.GetAccuracy());
            Assert.AreEqual(original.CohesionCoefficientOfVariation, soilLayerData.Cohesion.CoefficientOfVariation,
                            soilLayerData.Cohesion.GetAccuracy());

            Assert.AreEqual(original.FrictionAngleMean, soilLayerData.FrictionAngle.Mean,
                            soilLayerData.FrictionAngle.GetAccuracy());
            Assert.AreEqual(original.FrictionAngleCoefficientOfVariation, soilLayerData.FrictionAngle.CoefficientOfVariation,
                            soilLayerData.FrictionAngle.GetAccuracy());

            Assert.AreEqual(original.ShearStrengthRatioMean, soilLayerData.ShearStrengthRatio.Mean,
                            soilLayerData.ShearStrengthRatio.GetAccuracy());
            Assert.AreEqual(original.ShearStrengthRatioCoefficientOfVariation, soilLayerData.ShearStrengthRatio.CoefficientOfVariation,
                            soilLayerData.ShearStrengthRatio.GetAccuracy());

            Assert.AreEqual(original.StrengthIncreaseExponentMean, soilLayerData.StrengthIncreaseExponent.Mean,
                            soilLayerData.StrengthIncreaseExponent.GetAccuracy());
            Assert.AreEqual(original.StrengthIncreaseExponentCoefficientOfVariation, soilLayerData.StrengthIncreaseExponent.CoefficientOfVariation,
                            soilLayerData.StrengthIncreaseExponent.GetAccuracy());

            Assert.AreEqual(original.PopMean, soilLayerData.Pop.Mean, soilLayerData.Pop.GetAccuracy());
            Assert.AreEqual(original.PopCoefficientOfVariation, soilLayerData.Pop.CoefficientOfVariation,
                            soilLayerData.Pop.GetAccuracy());
        }
        /// <summary>
        /// Create <see cref="ChartMultipleAreaData"/> for a <see cref="MacroStabilityInwardsSoilLayer2D"/>.
        /// </summary>
        /// <param name="layer">The layer to create the <see cref="ChartMultipleAreaData"/> for.</param>
        /// <returns>The created <see cref="ChartMultipleAreaData"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="layer"/> is <c>null</c>.</exception>
        public static ChartMultipleAreaData CreateSoilLayerChartData(MacroStabilityInwardsSoilLayer2D layer)
        {
            if (layer == null)
            {
                throw new ArgumentNullException(nameof(layer));
            }

            MacroStabilityInwardsSoilLayerData data = layer.Data;

            return(new ChartMultipleAreaData(SoilLayerDataHelper.GetValidName(data.MaterialName),
                                             new ChartAreaStyle
            {
                FillColor = SoilLayerDataHelper.GetValidColor(data.Color),
                StrokeColor = Color.Black,
                StrokeThickness = 1
            }));
        }
Exemple #29
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string materialName = "MaterialName";
            var          soilLayer    = new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing())
            {
                Data =
                {
                    MaterialName = materialName
                }
            };

            // Call
            MacroStabilityInwardsSoilLayerTwoDEntity entity = soilLayer.Create(0);

            // Assert
            TestHelper.AssertAreEqualButNotSame(materialName, entity.MaterialName);
        }
        public void AddSoil_WithSoilLayer_AddsSoilLayerWithId()
        {
            // Setup
            MacroStabilityInwardsSoilLayer2D soilLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D();

            var          registry = new MacroStabilityInwardsExportRegistry();
            const string id       = "1";

            // Call
            registry.AddSoil(soilLayer, id);

            // Assert
            Assert.AreEqual(1, registry.Soils.Count);
            KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registeredSoil = registry.Soils.Single();

            Assert.AreSame(soilLayer, registeredSoil.Key);
            Assert.AreEqual(id, registeredSoil.Value);
        }