public void CreateExtremeWaternetForUpliftVan_ValidData_ReturnMacroStabilityInput() { // Setup UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> _); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan( input, soils, surfaceLine, soilProfile); // Assert CollectionAssert.AreEqual(soils, macroStabilityInput.StabilityModel.Soils, new SoilComparer()); Assert.AreSame(soilProfile, macroStabilityInput.StabilityModel.ConstructionStages.Single().SoilProfile); PreConstructionStage preConstructionStage = macroStabilityInput.PreprocessingInput.PreConstructionStages.Single(); Assert.AreSame(surfaceLine, preConstructionStage.SurfaceLine); Assert.IsTrue(preConstructionStage.CreateWaternet); KernelInputAssert.AssertWaternetCreatorInput(UpliftVanWaternetCreatorInputCreator.CreateExtreme(input), preConstructionStage.WaternetCreatorInput); }
public void CreateUpliftVan_ValidDataWithManualTangentLines_ReturnMacroStabilityInput() { // Setup var random = new Random(21); double tangentZTop = random.NextDouble(); double tangentZBottom = random.NextDouble(); int tangentLineNumber = random.Next(); UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(tangentZTop, tangentZBottom, tangentLineNumber); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); var dailyWaternet = new Waternet(); var extremeWaternet = new Waternet(); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateUpliftVan( input, soils, layerLookup, surfaceLine, soilProfile, dailyWaternet, extremeWaternet); // Assert SearchAreaConditions searchAreaConditions = macroStabilityInput.PreprocessingInput.SearchAreaConditions; Assert.AreEqual(input.SlipPlane.TangentLinesAutomaticAtBoundaries, searchAreaConditions.AutoTangentLines); Assert.AreEqual(input.SlipPlane.TangentLineNumber, searchAreaConditions.TangentLineNumber); Assert.AreEqual(input.SlipPlane.TangentZTop, searchAreaConditions.TangentLineZTop); Assert.AreEqual(input.SlipPlane.TangentZBottom, searchAreaConditions.TangentLineZBottom); }
private IUpliftVanKernel CreateUpliftVanKernel() { LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); MacroStabilityInput waternetDailyKernelInput = MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); MacroStabilityInput waternetExtremeKernelInput = MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, soils, surfaceLine, soilProfile); IWaternetKernel waternetDailyKernel = factory.CreateWaternetDailyKernel(waternetDailyKernelInput); waternetDailyKernel.Calculate(); IWaternetKernel waternetExtremeKernel = factory.CreateWaternetExtremeKernel(waternetExtremeKernelInput); waternetExtremeKernel.Calculate(); MacroStabilityInput kernelInput = MacroStabilityInputCreator.CreateUpliftVan(input, soils, layerLookup, surfaceLine, soilProfile, waternetDailyKernel.Waternet, waternetExtremeKernel.Waternet); return(factory.CreateUpliftVanKernel(kernelInput)); }
public void Create_SoilProfileNull_ThrowsArgumentNullException() { // Call void Call() => LayerWithSoilCreator.Create(null, out IDictionary <SoilLayer, LayerWithSoil> _); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("soilProfile", exception.ParamName); }
public void Create_ValidWaterPressureInterpolationModel_ExpectedWaterPressureInterpolationModel( WaterPressureInterpolationModel waterPressureInterpolationModel, CSharpWrapperWaterPressureInterpolationModel expectedWaterPressureInterpolationModel) { // Setup var profile = new SoilProfile(new[] { new SoilLayer(new Point2D[0], new SoilLayer.ConstructionProperties { WaterPressureInterpolationModel = waterPressureInterpolationModel }, Enumerable.Empty <SoilLayer>()) }, Enumerable.Empty <PreconsolidationStress>()); // Call LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(profile, out IDictionary <SoilLayer, LayerWithSoil> _); // Assert Assert.AreEqual(expectedWaterPressureInterpolationModel, layersWithSoil[0].WaterPressureInterpolationModel); }
public void CreateWaternet_ValidData_ReturnMacroStabilityInput() { // Setup WaternetCalculatorInput input = WaternetCalculatorInputTestFactory.CreateValidCalculatorInput(); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateWaternet(input); // Assert LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> _); CollectionAssert.AreEqual(layersWithSoil.Select(lws => lws.Soil).ToList(), macroStabilityInput.StabilityModel.Soils, new SoilComparer()); KernelInputAssert.AssertSoilProfile(SoilProfileCreator.Create(layersWithSoil), macroStabilityInput.StabilityModel.ConstructionStages.Single().SoilProfile); PreConstructionStage preConstructionStage = macroStabilityInput.PreprocessingInput.PreConstructionStages.Single(); KernelInputAssert.AssertSurfaceLine(SurfaceLineCreator.Create(input.SurfaceLine), preConstructionStage.SurfaceLine); Assert.IsTrue(preConstructionStage.CreateWaternet); KernelInputAssert.AssertWaternetCreatorInput(WaternetCreatorInputCreator.Create(input), preConstructionStage.WaternetCreatorInput); }
public void Create_InvalidWaterPressureInterpolationModel_ThrowInvalidEnumArgumentException() { // Setup var profile = new SoilProfile(new[] { new SoilLayer(new Point2D[0], new SoilLayer.ConstructionProperties { WaterPressureInterpolationModel = (WaterPressureInterpolationModel)99 }, Enumerable.Empty <SoilLayer>()) }, Enumerable.Empty <PreconsolidationStress>()); // Call void Call() => LayerWithSoilCreator.Create(profile, out IDictionary <SoilLayer, LayerWithSoil> _); // Assert string message = $"The value of argument 'waterPressureInterpolationModel' ({99}) is invalid for Enum type '{nameof(WaterPressureInterpolationModel)}'."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, message); }
public void Create_ValidShearStrengthModel_ExpectedShearStrengthModel( ShearStrengthModel shearStrengthModel, ShearStrengthModelType expectedShearStrengthAbovePhreaticLevelModel, ShearStrengthModelType expectedShearStrengthBelowPhreaticLevelModel) { // Setup var profile = new SoilProfile(new[] { new SoilLayer(new Point2D[0], new SoilLayer.ConstructionProperties { ShearStrengthModel = shearStrengthModel }, Enumerable.Empty <SoilLayer>()) }, Enumerable.Empty <PreconsolidationStress>()); // Call LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(profile, out IDictionary <SoilLayer, LayerWithSoil> _); // Assert Assert.AreEqual(expectedShearStrengthAbovePhreaticLevelModel, layersWithSoil[0].Soil.ShearStrengthAbovePhreaticLevelModel); Assert.AreEqual(expectedShearStrengthBelowPhreaticLevelModel, layersWithSoil[0].Soil.ShearStrengthBelowPhreaticLevelModel); }
public void Calculate_CalculatorWithCompleteInput_InputCorrectlySetToKernel() { // Setup UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(); using (new MacroStabilityInwardsKernelFactoryConfig()) { var factory = (TestMacroStabilityInwardsKernelFactory)MacroStabilityInwardsKernelWrapperFactory.Instance; UpliftVanKernelStub upliftVanKernel = factory.LastCreatedUpliftVanKernel; WaternetKernelStub waternetDailyKernel = factory.LastCreatedWaternetDailyKernel; WaternetKernelStub waternetExtremeKernel = factory.LastCreatedWaternetExtremeKernel; SetValidKernelOutput(waternetDailyKernel); SetValidKernelOutput(waternetExtremeKernel); SetValidKernelOutput(upliftVanKernel); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); CSharpWrapperSoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); // Call new UpliftVanCalculator(input, factory).Calculate(); // Assert WaternetKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateDailyWaternetForUpliftVan(input, soils, surfaceLine, soilProfile), waternetDailyKernel.KernelInput); WaternetKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateExtremeWaternetForUpliftVan(input, soils, surfaceLine, soilProfile), waternetExtremeKernel.KernelInput); UpliftVanKernelInputAssert.AssertMacroStabilityInput( MacroStabilityInputCreator.CreateUpliftVan( input, soils, layerLookup, surfaceLine, soilProfile, waternetDailyKernel.Waternet, waternetExtremeKernel.Waternet), upliftVanKernel.KernelInput); } }
public void Create_SoilProfile_ExpectedLayersWithSoil() { // Setup var outerRing1 = new Point2D[0]; var outerRing2 = new Point2D[0]; var outerRing3 = new Point2D[0]; var outerRing4 = new Point2D[0]; var outerRing5 = new Point2D[0]; var outerRing6 = new Point2D[0]; var soilProfile = new SoilProfile ( new[] { new SoilLayer(outerRing1, CreateRandomConstructionProperties(21, "Material 1"), new[] { new SoilLayer(outerRing2, CreateRandomConstructionProperties(22, "Material 2"), new[] { new SoilLayer(outerRing3, CreateRandomConstructionProperties(22, "Material 3"), Enumerable.Empty <SoilLayer>()) }), new SoilLayer(outerRing4, CreateRandomConstructionProperties(23, "Material 4"), Enumerable.Empty <SoilLayer>()) }), new SoilLayer(outerRing5, CreateRandomConstructionProperties(24, "Material 5"), new[] { new SoilLayer(outerRing6, CreateRandomConstructionProperties(25, "Material 6"), Enumerable.Empty <SoilLayer>()) }) }, Enumerable.Empty <PreconsolidationStress>() ); // Call LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(soilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); // Assert SoilLayer layer1 = soilProfile.Layers.ElementAt(0); SoilLayer layer2 = layer1.NestedLayers.ElementAt(0); SoilLayer layer3 = layer2.NestedLayers.ElementAt(0); SoilLayer layer4 = layer1.NestedLayers.ElementAt(1); SoilLayer layer5 = soilProfile.Layers.ElementAt(1); SoilLayer layer6 = layer5.NestedLayers.ElementAt(0); Assert.AreEqual(6, layersWithSoil.Length); Assert.AreEqual(outerRing1, layersWithSoil[0].OuterRing); CollectionAssert.AreEqual(new[] { outerRing2, outerRing3, outerRing4 }, layersWithSoil[0].InnerRings); AssertSoilLayerProperties(layer1, layersWithSoil[0]); Assert.AreEqual(outerRing2, layersWithSoil[1].OuterRing); CollectionAssert.AreEqual(new[] { outerRing3 }, layersWithSoil[1].InnerRings); AssertSoilLayerProperties(layer2, layersWithSoil[1]); Assert.AreEqual(outerRing3, layersWithSoil[2].OuterRing); CollectionAssert.IsEmpty(layersWithSoil[2].InnerRings); AssertSoilLayerProperties(layer3, layersWithSoil[2]); Assert.AreEqual(outerRing4, layersWithSoil[3].OuterRing); CollectionAssert.IsEmpty(layersWithSoil[3].InnerRings); AssertSoilLayerProperties(layer4, layersWithSoil[3]); Assert.AreEqual(outerRing5, layersWithSoil[4].OuterRing); CollectionAssert.AreEqual(new[] { outerRing6 }, layersWithSoil[4].InnerRings); AssertSoilLayerProperties(layer5, layersWithSoil[4]); Assert.AreEqual(outerRing6, layersWithSoil[5].OuterRing); CollectionAssert.IsEmpty(layersWithSoil[5].InnerRings); AssertSoilLayerProperties(layer6, layersWithSoil[5]); SoilLayer[] originalSoilLayers = { layer1, layer2, layer3, layer4, layer5, layer6 }; Assert.AreEqual(layersWithSoil.Length, layerLookup.Count); for (var i = 0; i < layersWithSoil.Length; i++) { Assert.AreSame(originalSoilLayers[i], layerLookup.ElementAt(i).Key); Assert.AreSame(layersWithSoil.ElementAt(i), layerLookup.ElementAt(i).Value); } }
public void CreateUpliftVan_ValidData_ReturnMacroStabilityInput() { // Setup UpliftVanCalculatorInput input = UpliftVanCalculatorInputTestFactory.Create(); LayerWithSoil[] layersWithSoil = LayerWithSoilCreator.Create(input.SoilProfile, out IDictionary <SoilLayer, LayerWithSoil> layerLookup); List <Soil> soils = layersWithSoil.Select(lws => lws.Soil).ToList(); SurfaceLine surfaceLine = SurfaceLineCreator.Create(input.SurfaceLine); SoilProfile soilProfile = SoilProfileCreator.Create(layersWithSoil); var dailyWaternet = new Waternet(); var extremeWaternet = new Waternet(); // Call MacroStabilityInput macroStabilityInput = MacroStabilityInputCreator.CreateUpliftVan( input, soils, layerLookup, surfaceLine, soilProfile, dailyWaternet, extremeWaternet); // Assert StabilityInput stabilityModel = macroStabilityInput.StabilityModel; Assert.AreEqual(Orientation.Inwards, stabilityModel.Orientation); Assert.AreEqual(SearchAlgorithm.Grid, stabilityModel.SearchAlgorithm); Assert.AreEqual(StabilityModelOptionType.UpliftVan, stabilityModel.ModelOption); CollectionAssert.AreEqual(soils, stabilityModel.Soils, new SoilComparer()); Assert.AreEqual(input.MoveGrid, stabilityModel.MoveGrid); Assert.AreEqual(input.MaximumSliceWidth, stabilityModel.MaximumSliceWidth); UpliftVanKernelInputAssert.AssertUpliftVanCalculationGrid( UpliftVanCalculationGridCreator.Create(input.SlipPlane), stabilityModel.UpliftVanCalculationGrid); UpliftVanKernelInputAssert.AssertSlipPlaneConstraints( SlipPlaneConstraintsCreator.Create(input.SlipPlaneConstraints), stabilityModel.SlipPlaneConstraints); AssertConstructionStages(input, stabilityModel, soilProfile, dailyWaternet, extremeWaternet, layerLookup); Assert.AreEqual(input.SlipPlane.GridNumberOfRefinements, stabilityModel.NumberOfRefinementsGrid); Assert.AreEqual(input.SlipPlane.TangentLineNumberOfRefinements, stabilityModel.NumberOfRefinementsTangentLines); SearchAreaConditions searchAreaConditions = macroStabilityInput.PreprocessingInput.SearchAreaConditions; Assert.AreEqual(0.8, searchAreaConditions.MaxSpacingBetweenBoundaries); Assert.IsTrue(searchAreaConditions.OnlyAbovePleistoceen); Assert.AreEqual(input.SlipPlane.GridAutomaticDetermined, searchAreaConditions.AutoSearchArea); Assert.AreEqual(input.SlipPlane.TangentLinesAutomaticAtBoundaries, searchAreaConditions.AutoTangentLines); Assert.AreEqual(1, searchAreaConditions.TangentLineNumber); Assert.AreEqual(0, searchAreaConditions.TangentLineZTop); Assert.AreEqual(0, searchAreaConditions.TangentLineZBottom); Assert.AreEqual(input.SlipPlaneConstraints.AutomaticForbiddenZones, searchAreaConditions.AutomaticForbiddenZones); Assert.AreEqual(2, macroStabilityInput.PreprocessingInput.PreConstructionStages.Count); foreach (PreConstructionStage preConstructionStage in macroStabilityInput.PreprocessingInput.PreConstructionStages) { Assert.IsFalse(preConstructionStage.CreateWaternet); Assert.AreSame(surfaceLine, preConstructionStage.SurfaceLine); Assert.IsNull(preConstructionStage.WaternetCreatorInput); // Not needed as Waternet is already calculated } AssertIrrelevantValues(stabilityModel, searchAreaConditions); }