public void SoilProfile1DCreate_ValidSoilProfile1D_ReturnsEmptyPreconsolidationStresses() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 4.0), new Point3D(4, 0, 0.0), new Point3D(8, 0, 4.0) }); var layer = new MacroStabilityInwardsSoilLayer1D(1); var profile = new MacroStabilityInwardsSoilProfile1D("name", 0, new[] { layer }); // Call MacroStabilityInwardsSoilProfileUnderSurfaceLine profileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create( profile, surfaceLine); // Assert CollectionAssert.IsEmpty(profileUnderSurfaceLine.PreconsolidationStresses); }
public void SoilProfile1DCreate_SurfaceLineEndsBelowLayerTopButAboveBottom_ReturnsSoilLayerPointsAsRectangleFollowingSurfaceLine() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 3.0), new Point3D(1, 0, 2.0), new Point3D(2, 0, 2.0) }); const double bottom = 1.5; const double top = 2.5; var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] { soilLayer }); // Call MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); // Assert Assert.AreEqual(1, areas.Layers.Count()); CollectionAssert.AreEqual(new[] { new Point2D(0.5, top), new Point2D(1, 2.0), new Point2D(2, 2.0), new Point2D(2, bottom), new Point2D(0, bottom), new Point2D(0, top) }, areas.Layers.ElementAt(0).OuterRing.Points); }
public void SoilProfile1DCreate_SurfaceLineOnTopOrAboveSoilLayer_ReturnsSoilLayerPointsAsRectangle() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 4), new Point3D(0, 0, 3.2), new Point3D(2, 0, 4) }); var soilLayer = new MacroStabilityInwardsSoilLayer1D(3.2); var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[] { soilLayer }); // Call MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); // Assert Assert.AreEqual(1, areas.Layers.Count()); CollectionAssert.AreEqual(new[] { new Point2D(2, 3.2), new Point2D(2, 2), new Point2D(0, 2), new Point2D(0, 3.2) }, areas.Layers.ElementAt(0).OuterRing.Points); }
public void Read_WithNullValues_ReturnsSoilProfileWithNaNValues() { // Setup var entity = new MacroStabilityInwardsSoilProfileOneDEntity { Name = nameof(MacroStabilityInwardsSoilProfileOneDEntity), Bottom = null, MacroStabilityInwardsSoilLayerOneDEntities = { new MacroStabilityInwardsSoilLayerOneDEntity { MaterialName = nameof(MacroStabilityInwardsSoilLayerOneDEntity) } } }; var collector = new ReadConversionCollector(); // Call MacroStabilityInwardsSoilProfile1D profile = entity.Read(collector); // Assert Assert.IsNotNull(profile); Assert.AreEqual(entity.Name, profile.Name); Assert.IsNaN(profile.Bottom); Assert.AreEqual(entity.MacroStabilityInwardsSoilLayerOneDEntities.Count, profile.Layers.Count()); MacroStabilityInwardsSoilLayer1D layer = profile.Layers.ElementAt(0); Assert.AreEqual(entity.MacroStabilityInwardsSoilLayerOneDEntities.First().MaterialName, layer.Data.MaterialName); }
public void VisibleProperties_WithSoilProfile1D_ExpectedAttributesValues() { // Setup var layer = new MacroStabilityInwardsSoilLayer1D(-2); var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.142, new MacroStabilityInwardsSoilProfile1D("<some name>", -5.0, new[] { layer })); // Call var properties = new MacroStabilityInwardsStochasticSoilProfileProperties(stochasticSoilProfile); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(5, dynamicProperties.Count); PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategoryName, "Naam", "De naam van de ondergrondschematisatie.", true); PropertyDescriptor contributionProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty, generalCategoryName, "Aandeel [%]", "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel.", true); PropertyDescriptor layersProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(layersProperty, generalCategoryName, "Grondlagen", "", true); PropertyDescriptor bottomProperty = dynamicProperties[3]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bottomProperty, generalCategoryName, "Bodemniveau", "Het niveau van de onderkant van de ondergrondschematisatie.", true); PropertyDescriptor typeProperty = dynamicProperties[4]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(typeProperty, generalCategoryName, "Type", "Het type van de ondergrondschematisatie.", true); }
public void Constructor_ValidMacroStabilityInwardsSoilLayer1D_ExpectedValues() { // Setup var soilLayer = new MacroStabilityInwardsSoilLayer1D(2.0); // Call var properties = new MacroStabilityInwardsSoilLayer1DProperties(soilLayer); // Assert Assert.IsInstanceOf <ObjectProperties <MacroStabilityInwardsSoilLayer1D> >(properties); Assert.AreSame(soilLayer, properties.Data); }
public void SoilLayer1DTransform_ValidUsePopValue_ReturnMacroStabilityInwardSoilLayer1D(double?usePop, bool transformedUsePopValue) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.UsePop = usePop; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedUsePopValue, soilLayer1D.Data.UsePop); }
public void Constructor_WithTop_ReturnsNewInstance() { // Setup double top = new Random(22).NextDouble(); // Call var layer = new MacroStabilityInwardsSoilLayer1D(top); // Assert Assert.IsInstanceOf <IMacroStabilityInwardsSoilLayer>(layer); Assert.AreEqual(top, layer.Top); Assert.IsNotNull(layer.Data); }
public void SoilLayer1DTransform_ValidIsAquifer_ReturnsMacroStabilityInwardsSoilLayer1D(double isAquifer, bool transformedIsAquifer) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedIsAquifer, soilLayer1D.Data.IsAquifer); }
public void SoilLayer1DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer1D(double?color, Color transformedColor) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.Color = color; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedColor, soilLayer1D.Data.Color); }
public void SoilLayer1DTransform_ValidShearStrengthModelValue_ReturnMacroStabilityInwardSoilLayer1D(double?sheartStrengthModel, MacroStabilityInwardsShearStrengthModel transformedShearStrengthModel) { // Setup SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.ShearStrengthModel = sheartStrengthModel; // Call MacroStabilityInwardsSoilLayer1D soilLayer1D = MacroStabilityInwardsSoilLayerTransformer.Transform(layer); // Assert Assert.AreEqual(transformedShearStrengthModel, soilLayer1D.Data.ShearStrengthModel); }
public void GetProperties_WithDataEmptyName_ReturnExpectedValues() { // Setup var layer = new MacroStabilityInwardsSoilLayer1D(-2.9) { Data = { MaterialName = string.Empty } }; // Call var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Assert Assert.AreEqual("Onbekend", properties.Name); }
public void Create_SurfaceLineNull_ThrowArgumentNullException() { // Setup var soilLayer = new MacroStabilityInwardsSoilLayer1D(3.2); var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[] { soilLayer }); // Call TestDelegate test = () => MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, null); // Assert var exception = Assert.Throws <ArgumentNullException>(test); Assert.AreEqual("surfaceLine", exception.ParamName); }
public void Create_StringPropertiesDoNotShareReference() { // Setup const string materialName = "MaterialName"; var soilLayer = new MacroStabilityInwardsSoilLayer1D(0) { Data = { MaterialName = materialName } }; // Call MacroStabilityInwardsSoilLayerOneDEntity entity = soilLayer.Create(0); // Assert TestHelper.AssertAreEqualButNotSame(materialName, entity.MaterialName); }
public void ToString_ValidName_ReturnsMaterialName() { // Setup var layer = new MacroStabilityInwardsSoilLayer1D(-2.9) { Data = { MaterialName = "Layer A" } }; var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Call string name = properties.ToString(); // Assert Assert.AreEqual(layer.Data.MaterialName, name); }
public void ToString_EmptyName_ReturnsDefaultName() { // Setup var layer = new MacroStabilityInwardsSoilLayer1D(-2.9) { Data = { MaterialName = string.Empty } }; var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Call string name = properties.ToString(); // Assert Assert.AreEqual("Onbekend", name); }
public void Read_WithNullValues_ReturnsMacroStabilityInwardsSoilLayer1DWithNaNValues() { // Setup var entity = new MacroStabilityInwardsSoilLayerOneDEntity { MaterialName = nameof(MacroStabilityInwardsSoilLayerOneDEntity) }; // Call MacroStabilityInwardsSoilLayer1D layer = entity.Read(); // Assert Assert.IsNotNull(layer); MacroStabilityInwardsSoilLayerData data = layer.Data; Assert.AreEqual(entity.MaterialName, data.MaterialName); Assert.IsNaN(layer.Top); Assert.IsNaN(data.AbovePhreaticLevel.Mean); Assert.IsNaN(data.AbovePhreaticLevel.CoefficientOfVariation); Assert.IsNaN(data.AbovePhreaticLevel.Shift); Assert.IsNaN(data.BelowPhreaticLevel.Mean); Assert.IsNaN(data.BelowPhreaticLevel.CoefficientOfVariation); Assert.IsNaN(data.BelowPhreaticLevel.Shift); Assert.IsNaN(data.Cohesion.Mean); Assert.IsNaN(data.Cohesion.CoefficientOfVariation); Assert.IsNaN(data.FrictionAngle.Mean); Assert.IsNaN(data.FrictionAngle.CoefficientOfVariation); Assert.IsNaN(data.ShearStrengthRatio.Mean); Assert.IsNaN(data.ShearStrengthRatio.CoefficientOfVariation); Assert.IsNaN(data.StrengthIncreaseExponent.Mean); Assert.IsNaN(data.StrengthIncreaseExponent.CoefficientOfVariation); Assert.IsNaN(data.Pop.Mean); Assert.IsNaN(data.Pop.CoefficientOfVariation); }
public void SoilProfile1DCreate_SurfaceLineZigZagsThroughSoilLayer_ReturnsSoilLayerPointsSplitInMultipleAreas() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 4.0), new Point3D(4, 0, 0.0), new Point3D(8, 0, 4.0) }); const int bottom = 1; const int top = 3; var soilLayer = new MacroStabilityInwardsSoilLayer1D(top); var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", bottom, new[] { soilLayer }); // Call MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); // Assert Assert.AreEqual(2, areas.Layers.Count()); CollectionAssert.AreEqual(new[] { new Point2D(1, top), new Point2D(3, bottom), new Point2D(0, bottom), new Point2D(0, top) }, areas.Layers.ElementAt(0).OuterRing.Points); CollectionAssert.AreEqual(new[] { new Point2D(5, bottom), new Point2D(7, top), new Point2D(8, top), new Point2D(8, bottom) }, areas.Layers.ElementAt(1).OuterRing.Points); }
public void SoilProfile1DCreate_SurfaceLineBelowSoilLayer_ReturnsEmptyAreasCollection() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 2.0), new Point3D(2, 0, 2.0) }); var soilLayer = new MacroStabilityInwardsSoilLayer1D(3.2); var soilProfile = new MacroStabilityInwardsSoilProfile1D("name", 2.0, new[] { soilLayer }); // Call MacroStabilityInwardsSoilProfileUnderSurfaceLine areas = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(soilProfile, surfaceLine); // Assert CollectionAssert.IsEmpty(areas.Layers); }
public void Constructor_ValidData_PropertiesHaveExpectedAttributeValues() { // Setup var layer = new MacroStabilityInwardsSoilLayer1D(-2.9); // Call var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); const string generalCategoryName = "Algemeen"; PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategoryName, "Naam", "De naam van de grondlaag.", true); PropertyDescriptor topLevelProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(topLevelProperty, generalCategoryName, "Topniveau", "Het niveau van de bovenkant van deze grondlaag binnen de ondergrondschematisatie.", true); PropertyDescriptor isAquiferProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isAquiferProperty, generalCategoryName, "Is aquifer", "Geeft aan of deze grondlaag een watervoerende laag betreft.", true); }
/// <summary> /// Creates a <see cref="MacroStabilityInwardsSoilLayerOneDEntity"/> based on the information /// of the <see cref="MacroStabilityInwardsSoilLayer1D"/>. /// </summary> /// <param name="soilLayer">The soil layer 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="MacroStabilityInwardsSoilLayerOneDEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="soilLayer"/> is <c>null</c>.</exception> public static MacroStabilityInwardsSoilLayerOneDEntity Create(this MacroStabilityInwardsSoilLayer1D soilLayer, int order) { if (soilLayer == null) { throw new ArgumentNullException(nameof(soilLayer)); } MacroStabilityInwardsSoilLayerData data = soilLayer.Data; return(new MacroStabilityInwardsSoilLayerOneDEntity { Top = soilLayer.Top.ToNaNAsNull(), IsAquifer = Convert.ToByte(data.IsAquifer), MaterialName = data.MaterialName.DeepClone(), Color = data.Color.ToInt64(), UsePop = Convert.ToByte(data.UsePop), ShearStrengthModel = Convert.ToByte(data.ShearStrengthModel), AbovePhreaticLevelMean = data.AbovePhreaticLevel.Mean.ToNaNAsNull(), AbovePhreaticLevelCoefficientOfVariation = data.AbovePhreaticLevel.CoefficientOfVariation.ToNaNAsNull(), AbovePhreaticLevelShift = data.AbovePhreaticLevel.Shift.ToNaNAsNull(), BelowPhreaticLevelMean = data.BelowPhreaticLevel.Mean.ToNaNAsNull(), BelowPhreaticLevelCoefficientOfVariation = data.BelowPhreaticLevel.CoefficientOfVariation.ToNaNAsNull(), BelowPhreaticLevelShift = data.BelowPhreaticLevel.Shift.ToNaNAsNull(), CohesionMean = data.Cohesion.Mean.ToNaNAsNull(), CohesionCoefficientOfVariation = data.Cohesion.CoefficientOfVariation.ToNaNAsNull(), FrictionAngleMean = data.FrictionAngle.Mean.ToNaNAsNull(), FrictionAngleCoefficientOfVariation = data.FrictionAngle.CoefficientOfVariation.ToNaNAsNull(), ShearStrengthRatioMean = data.ShearStrengthRatio.Mean.ToNaNAsNull(), ShearStrengthRatioCoefficientOfVariation = data.ShearStrengthRatio.CoefficientOfVariation.ToNaNAsNull(), StrengthIncreaseExponentMean = data.StrengthIncreaseExponent.Mean.ToNaNAsNull(), StrengthIncreaseExponentCoefficientOfVariation = data.StrengthIncreaseExponent.CoefficientOfVariation.ToNaNAsNull(), PopMean = data.Pop.Mean.ToNaNAsNull(), PopCoefficientOfVariation = data.Pop.CoefficientOfVariation.ToNaNAsNull(), Order = order }); }
public void GetProperties_WithSoilProfile1D_ReturnExpectedValues() { // Setup var random = new Random(21); double bottom = random.NextDouble(); double probability = random.NextDouble(); var layerOne = new MacroStabilityInwardsSoilLayer1D(4); var layerTwo = new MacroStabilityInwardsSoilLayer1D(2); IEnumerable <MacroStabilityInwardsSoilLayer1D> layers = new[] { layerOne, layerTwo }; var soilProfile = new MacroStabilityInwardsSoilProfile1D("<some name>", bottom, layers); 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(2, properties.Layers1D.Length); Assert.AreSame(layerOne, properties.Layers1D[0].Data); Assert.AreSame(layerTwo, properties.Layers1D[1].Data); CollectionAssert.IsEmpty(properties.Layers2D); Assert.AreEqual(2, properties.Bottom.NumberOfDecimalPlaces); Assert.AreEqual(bottom, properties.Bottom, properties.Bottom.GetAccuracy()); Assert.AreEqual(2, properties.Probability.NumberOfDecimalPlaces); Assert.AreEqual(probability * 100, properties.Probability, properties.Probability.GetAccuracy()); Assert.AreEqual("1D profiel", properties.Type); }
public void GetProperties_WithData_ReturnExpectedValues() { // Setup var random = new Random(21); double topLevel = random.NextDouble(); var layer = new MacroStabilityInwardsSoilLayer1D(topLevel) { Data = { MaterialName = "Test Name", IsAquifer = true } }; // Call var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Assert Assert.AreEqual(layer.Data.MaterialName, properties.Name); Assert.AreEqual(layer.Data.IsAquifer, properties.IsAquifer); Assert.AreEqual(2, properties.TopLevel.NumberOfDecimalPlaces); Assert.AreEqual(topLevel, properties.TopLevel, properties.TopLevel.GetAccuracy()); }
public void Read_WithValues_ReturnsMacroStabilityInwardsSoilLayer1DWithDoubleParameterValues() { // Setup var random = new Random(31); double top = random.NextDouble(); Color color = Color.FromKnownColor(random.NextEnumValue <KnownColor>()); bool isAquifer = random.NextBoolean(); const double abovePhreaticLevelMean = 0.3; const double abovePhreaticLevelCoefficientOfVariation = 0.2; const double abovePhreaticLevelShift = 0.1; const double belowPhreaticLevelMean = 0.6; const double belowPhreaticLevelCoefficientOfVariation = 0.5; const double belowPhreaticLevelShift = 0.4; 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 entity = new MacroStabilityInwardsSoilLayerOneDEntity { Top = top, IsAquifer = Convert.ToByte(isAquifer), Color = color.ToInt64(), MaterialName = random.Next().ToString(), 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 layer = entity.Read(); // Assert Assert.IsNotNull(layer); Assert.AreEqual(top, layer.Top); MacroStabilityInwardsSoilLayerData data = layer.Data; Assert.AreEqual(isAquifer, data.IsAquifer); Assert.IsNotNull(color); Assert.AreEqual(color.ToArgb(), data.Color.ToArgb()); Assert.AreEqual(entity.MaterialName, data.MaterialName); 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()); }
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()); }
public void Create_WithNaNProperties_ReturnsEntityWithPropertiesSetToNull() { // Setup var soilLayer = new MacroStabilityInwardsSoilLayer1D(double.NaN) { Data = { AbovePhreaticLevel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN, Shift = RoundedDouble.NaN }, BelowPhreaticLevel = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN, Shift = RoundedDouble.NaN }, Cohesion = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, FrictionAngle = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, ShearStrengthRatio = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, StrengthIncreaseExponent = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN }, Pop = { Mean = RoundedDouble.NaN, CoefficientOfVariation = RoundedDouble.NaN } } }; // Call MacroStabilityInwardsSoilLayerOneDEntity entity = soilLayer.Create(0); // Assert Assert.IsNotNull(entity); Assert.IsNull(entity.Top); Assert.IsNull(entity.AbovePhreaticLevelMean); Assert.IsNull(entity.AbovePhreaticLevelCoefficientOfVariation); Assert.IsNull(entity.AbovePhreaticLevelShift); Assert.IsNull(entity.BelowPhreaticLevelMean); Assert.IsNull(entity.BelowPhreaticLevelCoefficientOfVariation); Assert.IsNull(entity.BelowPhreaticLevelShift); Assert.IsNull(entity.CohesionMean); Assert.IsNull(entity.CohesionCoefficientOfVariation); Assert.IsNull(entity.FrictionAngleMean); Assert.IsNull(entity.FrictionAngleCoefficientOfVariation); Assert.IsNull(entity.ShearStrengthRatioMean); Assert.IsNull(entity.ShearStrengthRatioCoefficientOfVariation); Assert.IsNull(entity.StrengthIncreaseExponentMean); Assert.IsNull(entity.StrengthIncreaseExponentCoefficientOfVariation); Assert.IsNull(entity.PopMean); Assert.IsNull(entity.PopCoefficientOfVariation); }
public void Create_WithValidProperties_ReturnsEntityWithPropertiesSet() { // Setup var random = new Random(31); var soilLayer = new MacroStabilityInwardsSoilLayer1D(random.NextDouble()) { Data = { IsAquifer = random.NextBoolean(), MaterialName = "MaterialName", Color = Color.FromKnownColor(random.NextEnumValue <KnownColor>()), UsePop = random.NextBoolean(), ShearStrengthModel = random.NextEnumValue <MacroStabilityInwardsShearStrengthModel>(), AbovePhreaticLevel = { Mean = (RoundedDouble)0.3, CoefficientOfVariation = (RoundedDouble)0.2, Shift = (RoundedDouble)0.1 }, BelowPhreaticLevel = { Mean = (RoundedDouble)10, CoefficientOfVariation = (RoundedDouble)0.5, Shift = (RoundedDouble)2 }, Cohesion = { Mean = (RoundedDouble)10, CoefficientOfVariation = (RoundedDouble)1 }, FrictionAngle = { Mean = (RoundedDouble)12, CoefficientOfVariation = (RoundedDouble)0.8 }, ShearStrengthRatio = { Mean = (RoundedDouble)10, CoefficientOfVariation = (RoundedDouble)0.6 }, StrengthIncreaseExponent = { Mean = (RoundedDouble)11, CoefficientOfVariation = (RoundedDouble)0.7 }, Pop = { Mean = (RoundedDouble)14, CoefficientOfVariation = (RoundedDouble)0.9 } } }; int order = random.Next(); // Call MacroStabilityInwardsSoilLayerOneDEntity entity = soilLayer.Create(order); // Assert Assert.IsNotNull(entity); Assert.AreEqual(soilLayer.Top, entity.Top); MacroStabilityInwardsSoilLayerData data = soilLayer.Data; Assert.AreEqual(Convert.ToByte(data.IsAquifer), entity.IsAquifer); Assert.AreEqual(data.MaterialName, entity.MaterialName); Assert.AreEqual(data.Color.ToInt64(), Convert.ToInt64(entity.Color)); Assert.AreEqual(Convert.ToByte(data.UsePop), entity.UsePop); Assert.AreEqual(Convert.ToByte(data.ShearStrengthModel), entity.ShearStrengthModel); VariationCoefficientLogNormalDistribution abovePhreaticLevelDistribution = data.AbovePhreaticLevel; Assert.AreEqual(abovePhreaticLevelDistribution.Mean, entity.AbovePhreaticLevelMean, abovePhreaticLevelDistribution.GetAccuracy()); Assert.AreEqual(abovePhreaticLevelDistribution.CoefficientOfVariation, entity.AbovePhreaticLevelCoefficientOfVariation, abovePhreaticLevelDistribution.GetAccuracy()); Assert.AreEqual(abovePhreaticLevelDistribution.Shift, entity.AbovePhreaticLevelShift, abovePhreaticLevelDistribution.GetAccuracy()); VariationCoefficientLogNormalDistribution belowPhreaticLevelDistribution = data.BelowPhreaticLevel; Assert.AreEqual(belowPhreaticLevelDistribution.Mean, entity.BelowPhreaticLevelMean, belowPhreaticLevelDistribution.GetAccuracy()); Assert.AreEqual(belowPhreaticLevelDistribution.CoefficientOfVariation, entity.BelowPhreaticLevelCoefficientOfVariation, belowPhreaticLevelDistribution.GetAccuracy()); Assert.AreEqual(belowPhreaticLevelDistribution.Shift, entity.BelowPhreaticLevelShift, belowPhreaticLevelDistribution.GetAccuracy()); VariationCoefficientLogNormalDistribution cohesionDistribution = data.Cohesion; Assert.AreEqual(cohesionDistribution.Mean, entity.CohesionMean, cohesionDistribution.GetAccuracy()); Assert.AreEqual(cohesionDistribution.CoefficientOfVariation, entity.CohesionCoefficientOfVariation, cohesionDistribution.GetAccuracy()); VariationCoefficientLogNormalDistribution frictionAngleDistribution = data.FrictionAngle; Assert.AreEqual(frictionAngleDistribution.Mean, entity.FrictionAngleMean, frictionAngleDistribution.GetAccuracy()); Assert.AreEqual(frictionAngleDistribution.CoefficientOfVariation, entity.FrictionAngleCoefficientOfVariation, frictionAngleDistribution.GetAccuracy()); VariationCoefficientLogNormalDistribution shearStrengthRatioDistribution = data.ShearStrengthRatio; Assert.AreEqual(shearStrengthRatioDistribution.Mean, entity.ShearStrengthRatioMean, shearStrengthRatioDistribution.GetAccuracy()); Assert.AreEqual(shearStrengthRatioDistribution.CoefficientOfVariation, entity.ShearStrengthRatioCoefficientOfVariation, shearStrengthRatioDistribution.GetAccuracy()); VariationCoefficientLogNormalDistribution strengthIncreaseExponentDistribution = data.StrengthIncreaseExponent; Assert.AreEqual(strengthIncreaseExponentDistribution.Mean, entity.StrengthIncreaseExponentMean, strengthIncreaseExponentDistribution.GetAccuracy()); Assert.AreEqual(strengthIncreaseExponentDistribution.CoefficientOfVariation, entity.StrengthIncreaseExponentCoefficientOfVariation, strengthIncreaseExponentDistribution.GetAccuracy()); VariationCoefficientLogNormalDistribution popDistribution = data.Pop; Assert.AreEqual(popDistribution.Mean, entity.PopMean, popDistribution.GetAccuracy()); Assert.AreEqual(popDistribution.CoefficientOfVariation, entity.PopCoefficientOfVariation, popDistribution.GetAccuracy()); Assert.AreEqual(order, entity.Order); }
public void SoilProfile1DCreate_WithData_ReturnsData() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 4.0), new Point3D(4, 0, 0.0), new Point3D(8, 0, 4.0) }); var random = new Random(21); bool usePop = random.NextBoolean(); bool isAquifer = random.NextBoolean(); var shearStrengthModel = random.NextEnumValue <MacroStabilityInwardsShearStrengthModel>(); const double abovePhreaticLevelMean = 10; const double abovePhreaticLevelCoefficientOfVariation = 0.2; const double abovePhreaticLevelShift = 0.1; const double belowPhreaticLevelMean = 9; const double belowPhreaticLevelCoefficientOfVariation = 0.4; 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(); const string material = "Clay"; var layer = new MacroStabilityInwardsSoilLayer1D(1) { Data = { UsePop = usePop, IsAquifer = isAquifer, ShearStrengthModel = shearStrengthModel, MaterialName = material, AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)abovePhreaticLevelMean, CoefficientOfVariation = (RoundedDouble)abovePhreaticLevelCoefficientOfVariation, Shift = (RoundedDouble)abovePhreaticLevelShift }, BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)belowPhreaticLevelMean, CoefficientOfVariation = (RoundedDouble)belowPhreaticLevelCoefficientOfVariation, Shift = (RoundedDouble)belowPhreaticLevelShift }, Cohesion = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)cohesionMean, CoefficientOfVariation = (RoundedDouble)cohesionCoefficientOfVariation }, FrictionAngle = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)frictionAngleMean, CoefficientOfVariation = (RoundedDouble)frictionAngleCoefficientOfVariation }, ShearStrengthRatio = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)shearStrengthRatioMean, CoefficientOfVariation = (RoundedDouble)shearStrengthRatioCoefficientOfVariation }, StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)strengthIncreaseExponentMean, CoefficientOfVariation = (RoundedDouble)strengthIncreaseExponentCoefficientOfVariation }, Pop = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)popMean, CoefficientOfVariation = (RoundedDouble)popCoefficientOfVariation } } }; var profile = new MacroStabilityInwardsSoilProfile1D("name", 0, new[] { layer }); // Call MacroStabilityInwardsSoilProfileUnderSurfaceLine profileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create( profile, surfaceLine); // Assert Assert.AreSame(layer.Data, profileUnderSurfaceLine.Layers.First().Data); }