public void GetLayerForPreconsolidationStress_PreconsolidationStressNull_ThrowsArgumentNullException() { // Call void Call() => PersistableStateHelper.GetLayerForPreconsolidationStress(Enumerable.Empty <MacroStabilityInwardsSoilLayer2D>(), null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("preconsolidationStress", exception.ParamName); }
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 GetLayerForPreconsolidationStress_LayersNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var preconsolidationStress = mocks.Stub <IMacroStabilityInwardsPreconsolidationStress>(); mocks.ReplayAll(); // Call void Call() => PersistableStateHelper.GetLayerForPreconsolidationStress(null, preconsolidationStress); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("layers", exception.ParamName); mocks.VerifyAll(); }
private static PersistableState Create(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile, MacroStabilityInwardsExportStageType stageType, IdFactory idFactory, MacroStabilityInwardsExportRegistry registry) { MacroStabilityInwardsSoilLayer2D[] layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers).ToArray(); var statePoints = new List <PersistableStatePoint>(); if (PersistableStateHelper.HasValidStatePoints(soilProfile)) { statePoints.AddRange(layers.Where(l => l.Data.UsePop && PersistableStateHelper.HasValidPop(l.Data.Pop)) .Select(l => CreatePOPStatePoint(l, stageType, idFactory, registry)) .ToArray()); var preconsolidationStressPoints = new List <PersistableStatePoint>(); foreach (IMacroStabilityInwardsPreconsolidationStress preconsolidationStress in soilProfile.PreconsolidationStresses) { MacroStabilityInwardsSoilLayer2D layer = PersistableStateHelper.GetLayerForPreconsolidationStress(layers, preconsolidationStress); if (layer != null) { preconsolidationStressPoints.Add( CreateYieldStressStatePoint(layer, preconsolidationStress, stageType, idFactory, registry)); } } statePoints.AddRange(preconsolidationStressPoints); } var state = new PersistableState { Id = idFactory.Create(), StateLines = Enumerable.Empty <PersistableStateLine>(), StatePoints = statePoints }; registry.AddState(stageType, state.Id); return(state); }