Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Factories/PersistableDataModelFactory.cs =================================================================== diff -u -re27af65f41dd115eb01e4c69b0c20318662f0307 -r6ff01e7ca7bcb0fefcef033ae31738c401bcf24f --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Factories/PersistableDataModelFactory.cs (.../PersistableDataModelFactory.cs) (revision e27af65f41dd115eb01e4c69b0c20318662f0307) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Factories/PersistableDataModelFactory.cs (.../PersistableDataModelFactory.cs) (revision 6ff01e7ca7bcb0fefcef033ae31738c401bcf24f) @@ -1,4 +1,4 @@ -// Copyright (C) Stichting Deltares 2019. All rights reserved. +// Copyright (C) Stichting Deltares 2019. All rights reserved. // // This file is part of Riskeer. // @@ -81,6 +81,7 @@ DerivedMacroStabilityInwardsInput.GetWaternetExtreme(input, GetAssessmentLevel(input, getNormativeAssessmentLevelFunc)), idFactory, registry), WaternetCreatorSettings = PersistableWaternetCreatorSettingsFactory.Create(input, GetAssessmentLevel(input, getNormativeAssessmentLevelFunc), idFactory, registry), + States = PersistableStateFactory.Create(soilProfile, idFactory, registry), Stages = PersistableStageFactory.Create(idFactory, registry) }; } Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Factories/PersistableStateFactoryTest.cs =================================================================== diff -u -r8717913cf7befbb647a6be23f9493e99435d0d4a -r6ff01e7ca7bcb0fefcef033ae31738c401bcf24f --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Factories/PersistableStateFactoryTest.cs (.../PersistableStateFactoryTest.cs) (revision 8717913cf7befbb647a6be23f9493e99435d0d4a) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.Test/Factories/PersistableStateFactoryTest.cs (.../PersistableStateFactoryTest.cs) (revision 6ff01e7ca7bcb0fefcef033ae31738c401bcf24f) @@ -104,40 +104,8 @@ IEnumerable states = PersistableStateFactory.Create(soilProfile, idFactory, registry); // Assert - Assert.AreEqual(2, states.Count()); + PersistableDataModelTestHelper.AssertStates(soilProfile, states); - IEnumerable layersWithPop = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers) - .Where(l => l.Data.UsePop); - - for (var i = 0; i < states.Count(); i++) - { - PersistableState state = states.ElementAt(i); - - Assert.IsNotNull(state.Id); - CollectionAssert.IsEmpty(state.StateLines); - - Assert.AreEqual(layersWithPop.Count(), state.StatePoints.Count()); - - for (var j = 0; j < layersWithPop.Count(); j++) - { - MacroStabilityInwardsSoilLayer2D layerWithPop = layersWithPop.ElementAt(j); - PersistableStatePoint statePoint = state.StatePoints.ElementAt(j); - - Assert.IsNotNull(statePoint.Id); - Assert.IsEmpty(statePoint.Label); - Assert.IsNotNull(statePoint.LayerId); - Assert.IsTrue(statePoint.IsProbabilistic); - - Point2D interiorPoint = AdvancedMath2D.GetPolygonInteriorPoint(layerWithPop.OuterRing.Points, layerWithPop.NestedLayers.Select(layers => layers.OuterRing.Points)); - Assert.AreEqual(interiorPoint.X, statePoint.Point.X); - Assert.AreEqual(interiorPoint.Y, statePoint.Point.Z); - - Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerWithPop.Data).GetDesignValue(), statePoint.Stress.Pop); - PersistableDataModelTestHelper.AssertStochasticParameter(layerWithPop.Data.Pop, statePoint.Stress.PopStochasticParameter); - Assert.AreEqual(PersistableStateType.Pop, statePoint.Stress.StateType); - } - } - AssertRegistry(registry, new [] { MacroStabilityInwardsExportStageType.Daily, Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.TestUtil/PersistableDataModelTestHelper.cs =================================================================== diff -u -r62a7251bc3af8d2358abc6f563ac7597a24e6355 -r6ff01e7ca7bcb0fefcef033ae31738c401bcf24f --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.TestUtil/PersistableDataModelTestHelper.cs (.../PersistableDataModelTestHelper.cs) (revision 62a7251bc3af8d2358abc6f563ac7597a24e6355) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.IO.TestUtil/PersistableDataModelTestHelper.cs (.../PersistableDataModelTestHelper.cs) (revision 6ff01e7ca7bcb0fefcef033ae31738c401bcf24f) @@ -25,6 +25,8 @@ using System.Reflection; using Components.Persistence.Stability.Data; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.Geometry; using Core.Common.Util.Reflection; using NUnit.Framework; using Riskeer.Common.Data.Probabilistics; @@ -70,6 +72,7 @@ MacroStabilityInwardsExportStageType.Daily, MacroStabilityInwardsExportStageType.Extreme }); + AssertStates(calculation.InputParameters.SoilProfileUnderSurfaceLine, persistableDataModel.States); Assert.IsNull(persistableDataModel.AssessmentResults); Assert.IsNull(persistableDataModel.Decorations); @@ -79,7 +82,6 @@ Assert.IsNull(persistableDataModel.SoilCorrelations); Assert.IsNull(persistableDataModel.SoilVisualizations); Assert.IsNull(persistableDataModel.StateCorrelations); - Assert.IsNull(persistableDataModel.States); AssertStages(persistableDataModel.Stages, persistableDataModel.CalculationSettings, persistableDataModel.Geometry, persistableDataModel.SoilLayers, persistableDataModel.Waternets, persistableDataModel.WaternetCreatorSettings); @@ -390,6 +392,52 @@ } /// + /// Asserts whether the contains the data + /// that is representative for the . + /// + /// The input that contains the original data. + /// The + /// that needs to be asserted. + /// Thrown when the data in + /// is not correct. + public static void AssertStates(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfile, IEnumerable states) + { + Assert.AreEqual(2, states.Count()); + + IEnumerable layersWithPop = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfile.Layers) + .Where(l => l.Data.UsePop); + + for (var i = 0; i < states.Count(); i++) + { + PersistableState state = states.ElementAt(i); + + Assert.IsNotNull(state.Id); + CollectionAssert.IsEmpty(state.StateLines); + + Assert.AreEqual(layersWithPop.Count(), state.StatePoints.Count()); + + for (var j = 0; j < layersWithPop.Count(); j++) + { + MacroStabilityInwardsSoilLayer2D layerWithPop = layersWithPop.ElementAt(j); + PersistableStatePoint statePoint = state.StatePoints.ElementAt(j); + + Assert.IsNotNull(statePoint.Id); + Assert.IsEmpty(statePoint.Label); + Assert.IsNotNull(statePoint.LayerId); + Assert.IsTrue(statePoint.IsProbabilistic); + + Point2D interiorPoint = AdvancedMath2D.GetPolygonInteriorPoint(layerWithPop.OuterRing.Points, layerWithPop.NestedLayers.Select(layers => layers.OuterRing.Points)); + Assert.AreEqual(interiorPoint.X, statePoint.Point.X); + Assert.AreEqual(interiorPoint.Y, statePoint.Point.Z); + + Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(layerWithPop.Data).GetDesignValue(), statePoint.Stress.Pop); + AssertStochasticParameter(layerWithPop.Data.Pop, statePoint.Stress.PopStochasticParameter); + Assert.AreEqual(PersistableStateType.Pop, statePoint.Stress.StateType); + } + } + } + + /// /// Asserts whether the contains the correct data. /// /// The stages that needs to be asserted.