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 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 Create_WithSoilProfile_ReturnsPersistableSoilCollection(MacroStabilityInwardsShearStrengthModel shearStrengthModel) { // Setup var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }) }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); var registry = new MacroStabilityInwardsExportRegistry(); IEnumerable <MacroStabilityInwardsSoilLayer2D> originalLayers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers); originalLayers.ForEachElementDo(layer => layer.Data.ShearStrengthModel = shearStrengthModel); // Call PersistableSoilCollection soilCollection = PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry); // Assert IEnumerable <PersistableSoil> actualSoils = soilCollection.Soils; PersistableDataModelTestHelper.AssertPersistableSoils(originalLayers, actualSoils); Assert.AreEqual(actualSoils.Count(), registry.Soils.Count); for (var i = 0; i < originalLayers.Count(); i++) { KeyValuePair <MacroStabilityInwardsSoilLayer2D, string> registrySoil = registry.Soils.ElementAt(i); Assert.AreSame(originalLayers.ElementAt(i), registrySoil.Key); Assert.AreEqual(actualSoils.ElementAt(i).Id, registrySoil.Value); } }
public void HasValidStatePoints_SoilProfileWithPOPAndPreconsolidationStressOnOneLayer_ReturnsFalse() { // Setup MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, 1)) }); IMacroStabilityInwardsSoilLayer firstLayer = stochasticSoilProfile.SoilProfile.Layers.First(); firstLayer.Data.UsePop = true; firstLayer.Data.Pop = new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)1, CoefficientOfVariation = (RoundedDouble)2 }; MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile, CreateSurfaceLine()); // Call bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine); // Assert Assert.IsFalse(hasValidStatePoints); }
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 Constructor_WithValidParameters_NewInstanceWithPropertiesSet() { // Call IEnumerable <MacroStabilityInwardsSoilLayer2D> layers = Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>(); IEnumerable <MacroStabilityInwardsPreconsolidationStress> preconsolidationStresses = Enumerable.Empty <MacroStabilityInwardsPreconsolidationStress>(); // Setup var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(layers, preconsolidationStresses); // Assert Assert.AreSame(layers, profile.Layers); Assert.AreSame(preconsolidationStresses, profile.PreconsolidationStresses); }
public void HasValidStatePoints_SoilProfileWithPreconsolidationStressOutsideLayers_ReturnsFalse() { // Setup MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = MacroStabilityInwardsStochasticSoilProfileTestFactory.CreateMacroStabilityInwardsStochasticSoilProfile2D(new[] { MacroStabilityInwardsPreconsolidationStressTestFactory.CreateMacroStabilityInwardsPreconsolidationStress(new Point2D(2, -50)) }); MacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurfaceLine = MacroStabilityInwardsSoilProfileUnderSurfaceLineFactory.Create(stochasticSoilProfile.SoilProfile, CreateSurfaceLine()); // Call bool hasValidStatePoints = PersistableStateHelper.HasValidStatePoints(soilProfileUnderSurfaceLine); // Assert Assert.IsFalse(hasValidStatePoints); }
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); }
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); }
public void Convert_WithSoilProfile_ReturnSoilProfile() { // Setup var random = new Random(22); MacroStabilityInwardsSoilLayer2D soilLayer1 = CreateRandomSoilLayer(22, new[] { CreateRandomSoilLayer(23, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>()), CreateRandomSoilLayer(24, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>()) }); MacroStabilityInwardsSoilLayer2D soilLayer2 = CreateRandomSoilLayer(25, new[] { CreateRandomSoilLayer(26, new[] { CreateRandomSoilLayer(27, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>()) }) }); var preconsolidationStress = new MacroStabilityInwardsPreconsolidationStress(new Point2D(random.NextDouble(), random.NextDouble()), new VariationCoefficientLogNormalDistribution { Mean = (RoundedDouble)0.05, CoefficientOfVariation = random.NextRoundedDouble() }); var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { soilLayer1, soilLayer2 }, new[] { preconsolidationStress }); // Call SoilProfile soilProfile = SoilProfileConverter.Convert(profile); // Assert CalculatorInputAssert.AssertSoilProfile(profile, soilProfile); }
public void Convert_ValidShearStrengthModel_ReturnExpectedShearStrengthModel(MacroStabilityInwardsShearStrengthModel originalShearStrengthModel, ShearStrengthModel expectedShearStrengthModel) { // Setup var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { ShearStrengthModel = originalShearStrengthModel } } }, new MacroStabilityInwardsPreconsolidationStress[0]); // Call SoilProfile soilProfile = SoilProfileConverter.Convert(profile); // Assert Assert.AreEqual(expectedShearStrengthModel, soilProfile.Layers.First().ShearStrengthModel); }
public void Convert_SoilProfileWithSoilLayerWithEmptyName_ReturnSoilProfile() { // Setup MacroStabilityInwardsSoilLayer2D soilLayer = CreateRandomSoilLayer(22, Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>()); soilLayer.Data.MaterialName = string.Empty; var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { soilLayer }, new IMacroStabilityInwardsPreconsolidationStress[0]); // Call SoilProfile soilProfile = SoilProfileConverter.Convert(profile); // Assert Assert.AreEqual(1, soilProfile.Layers.Count()); Assert.AreEqual("Onbekend", soilProfile.Layers.First().MaterialName); }
public void Create_WithValidData_ReturnsNull() { // Setup var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }) }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); var registry = new MacroStabilityInwardsExportRegistry(); // Call IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, new IdFactory(), registry); // Assert IEnumerable <MacroStabilityInwardsSoilLayer2D> layersRecursively = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers); PersistableDataModelTestHelper.AssertPersistableGeometry(layersRecursively, geometries); AssertRegistry(registry, geometries, layersRecursively); }
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 Convert_InvalidShearStrengthModel_ThrowInvalidEnumArgumentException() { // Setup var profile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine(new[] { new MacroStabilityInwardsSoilLayer2D(RingTestFactory.CreateRandomRing()) { Data = { ShearStrengthModel = (MacroStabilityInwardsShearStrengthModel)99 } } }, new MacroStabilityInwardsPreconsolidationStress[0]); // Call TestDelegate test = () => SoilProfileConverter.Convert(profile); // Assert const string message = "The value of argument 'shearStrengthModel' (99) is invalid for Enum type 'MacroStabilityInwardsShearStrengthModel'."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(test, message); }
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 Create_WithValidData_ReturnsPersistableSoilLayerCollectionCollection() { // Setup var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }) }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); var idFactory = new IdFactory(); var registry = new MacroStabilityInwardsExportRegistry(); PersistableSoilCollection soils = PersistableSoilCollectionFactory.Create(soilProfile, idFactory, registry); IEnumerable <PersistableGeometry> geometries = PersistableGeometryFactory.Create(soilProfile, idFactory, registry); // Call IEnumerable <PersistableSoilLayerCollection> soilLayerCollections = PersistableSoilLayerCollectionFactory.Create(soilProfile, idFactory, registry); // Assert PersistableDataModelTestHelper.AssertPersistableSoilLayers(soilProfile.Layers, soilLayerCollections, soils.Soils, geometries); var stages = new[] { MacroStabilityInwardsExportStageType.Daily, MacroStabilityInwardsExportStageType.Extreme }; Assert.AreEqual(2, registry.SoilLayers.Count); for (var i = 0; i < stages.Length; i++) { Assert.AreEqual(registry.SoilLayers[stages[i]], soilLayerCollections.ElementAt(i).Id); } }
public void Create_InvalidShearStrengthType_ThrowsInvalidEnumArgumentException() { // Setup var registry = new MacroStabilityInwardsExportRegistry(); var soilProfile = new MacroStabilityInwardsSoilProfileUnderSurfaceLine( new[] { MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D() }, Enumerable.Empty <IMacroStabilityInwardsPreconsolidationStress>()); const MacroStabilityInwardsShearStrengthModel shearStrengthModel = (MacroStabilityInwardsShearStrengthModel)99; soilProfile.Layers.First().Data.ShearStrengthModel = shearStrengthModel; // Call void Call() => PersistableSoilCollectionFactory.Create(soilProfile, new IdFactory(), registry); // Assert string message = $"The value of argument 'shearStrengthModel' ({shearStrengthModel}) is invalid for Enum type '{nameof(MacroStabilityInwardsShearStrengthModel)}'."; var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message); Assert.AreEqual("shearStrengthModel", exception.ParamName); }
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); }