Ejemplo n.º 1
0
        public void HasValidPop_PopNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => PersistableStateHelper.HasValidPop(null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("pop", exception.ParamName);
        }
Ejemplo n.º 2
0
        public void HasValidPop_DistributionWithValidValues_ReturnsTrue()
        {
            // Setup
            var mocks = new MockRepository();
            var pop   = mocks.Stub <IVariationCoefficientDistribution>();

            mocks.ReplayAll();

            pop.Mean = new RoundedDouble(2);
            pop.CoefficientOfVariation = new RoundedDouble(2);

            // Call
            bool hasValidPop = PersistableStateHelper.HasValidPop(pop);

            // Assert
            Assert.IsTrue(hasValidPop);
            mocks.VerifyAll();
        }
Ejemplo n.º 3
0
        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);
        }