public void Create_CalculationWithAlreadyRegisteredStochasticSoilProfile_ReturnsEntityWithStochasticSoilModelEntity() { // Setup var random = new Random(21); var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(), MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D()); var scenario = new MacroStabilityInwardsCalculationScenario { InputParameters = { StochasticSoilProfile = stochasticSoilProfile } }; var registry = new PersistenceRegistry(); var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity(); registry.Register(stochasticSoilProfileEntity, stochasticSoilProfile); // Call MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, 0); // Assert Assert.IsNotNull(entity); MacroStabilityInwardsStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = registry.Get(stochasticSoilProfile); Assert.AreSame(expectedStochasticSoilProfileEntity, entity.MacroStabilityInwardsStochasticSoilProfileEntity); }
public void Read_EntityWithOutput_ReturnsCalculationScenarioWithOutput() { // Setup var random = new Random(31); var tangentLines = new RoundedDouble[0]; var slices = new MacroStabilityInwardsSlice[0]; var calculationOutputEntity = new MacroStabilityInwardsCalculationOutputEntity { SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(tangentLines), SlidingCurveSliceXML = new MacroStabilityInwardsSliceCollectionXmlSerializer().ToXml(slices), SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(1, 100), SlipPlaneLeftGridNrOfVerticalPoints = random.Next(1, 100), SlipPlaneRightGridNrOfHorizontalPoints = random.Next(1, 100), SlipPlaneRightGridNrOfVerticalPoints = random.Next(1, 100) }; MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); entity.MacroStabilityInwardsCalculationOutputEntities.Add(calculationOutputEntity); var collector = new ReadConversionCollector(); // Call MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector); // Assert MacroStabilityInwardsOutput output = calculation.Output; Assert.IsNotNull(output); MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, calculationOutputEntity); }
public void Read_EntityWithStochasticSoilModel_ReturnCalculationScenarioWithInputObjectWithStochasticSoilModelPropertiesSet() { // Setup var random = new Random(21); MacroStabilityInwardsStochasticSoilModel stochasticSoilModel = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(); var stochasticSoilModelEntity = new StochasticSoilModelEntity(); var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(), MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D()); var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity { StochasticSoilModelEntity = stochasticSoilModelEntity }; var collector = new ReadConversionCollector(); collector.Read(stochasticSoilModelEntity, stochasticSoilModel); collector.Read(stochasticSoilProfileEntity, stochasticSoilProfile); MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); entity.MacroStabilityInwardsStochasticSoilProfileEntity = stochasticSoilProfileEntity; // Call MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector); // Assert MacroStabilityInwardsInput inputParameters = calculation.InputParameters; Assert.AreSame(stochasticSoilModel, inputParameters.StochasticSoilModel); Assert.AreSame(stochasticSoilProfile, inputParameters.StochasticSoilProfile); }
public void Create_GroupWithChildMacroStabilityInwardsCalculationsAndChildCalculationGroups_CreateEntities() { // Setup var group = new CalculationGroup { Children = { new CalculationGroup { Name = "A" }, new MacroStabilityInwardsCalculationScenario { Name = "B" }, new CalculationGroup { Name = "C" }, new MacroStabilityInwardsCalculationScenario { Name = "D" } } }; var registry = new PersistenceRegistry(); // Call CalculationGroupEntity entity = group.Create(registry, 0); // Assert CalculationGroupEntity[] childGroupEntities = entity.CalculationGroupEntity1.ToArray(); MacroStabilityInwardsCalculationEntity[] childCalculationEntities = entity.MacroStabilityInwardsCalculationEntities.ToArray(); Assert.AreEqual(2, childGroupEntities.Length); Assert.AreEqual(2, childCalculationEntities.Length); CalculationGroupEntity childEntity1 = childGroupEntities[0]; Assert.AreEqual("A", childEntity1.Name); Assert.AreEqual(0, childEntity1.Order); CollectionAssert.IsEmpty(childEntity1.CalculationGroupEntity1); MacroStabilityInwardsCalculationEntity childEntity2 = childCalculationEntities[0]; Assert.AreEqual("B", childEntity2.Name); Assert.AreEqual(1, childEntity2.Order); CalculationGroupEntity childEntity3 = childGroupEntities[1]; Assert.AreEqual("C", childEntity3.Name); Assert.AreEqual(2, childEntity3.Order); CollectionAssert.IsEmpty(childEntity3.CalculationGroupEntity1); MacroStabilityInwardsCalculationEntity childEntity4 = childCalculationEntities[1]; Assert.AreEqual("D", childEntity4.Name); Assert.AreEqual(3, childEntity4.Order); }
private static void AddEntityForMacroStabilityInwardsOutput(MacroStabilityInwardsCalculationEntity entity, MacroStabilityInwardsOutput output) { if (output != null) { entity.MacroStabilityInwardsCalculationOutputEntities.Add(output.Create()); } }
private static void SetSurfaceLineToInput(MacroStabilityInwardsInput inputParameters, MacroStabilityInwardsCalculationEntity entity, ReadConversionCollector collector) { if (entity.SurfaceLineEntity != null) { inputParameters.SurfaceLine = entity.SurfaceLineEntity.ReadAsMacroStabilityInwardsSurfaceLine(collector); } }
private static void SetInputParametersToEntity(MacroStabilityInwardsCalculationEntity entity, MacroStabilityInwardsInput inputParameters, PersistenceRegistry registry) { if (inputParameters.SurfaceLine != null) { entity.SurfaceLineEntity = registry.Get(inputParameters.SurfaceLine); } if (inputParameters.StochasticSoilProfile != null) { entity.MacroStabilityInwardsStochasticSoilProfileEntity = registry.Get(inputParameters.StochasticSoilProfile); } SetHydraulicBoundaryLocationInputToEntity(entity, inputParameters, registry); entity.SlipPlaneMinimumDepth = inputParameters.SlipPlaneMinimumDepth.ToNaNAsNull(); entity.SlipPlaneMinimumLength = inputParameters.SlipPlaneMinimumLength.ToNaNAsNull(); entity.MaximumSliceWidth = inputParameters.MaximumSliceWidth.ToNaNAsNull(); entity.MoveGrid = Convert.ToByte(inputParameters.MoveGrid); entity.DikeSoilScenario = Convert.ToByte(inputParameters.DikeSoilScenario); entity.WaterLevelRiverAverage = inputParameters.WaterLevelRiverAverage.ToNaNAsNull(); entity.DrainageConstructionPresent = Convert.ToByte(inputParameters.DrainageConstructionPresent); entity.DrainageConstructionCoordinateX = inputParameters.XCoordinateDrainageConstruction.ToNaNAsNull(); entity.DrainageConstructionCoordinateZ = inputParameters.ZCoordinateDrainageConstruction.ToNaNAsNull(); entity.MinimumLevelPhreaticLineAtDikeTopRiver = inputParameters.MinimumLevelPhreaticLineAtDikeTopRiver.ToNaNAsNull(); entity.MinimumLevelPhreaticLineAtDikeTopPolder = inputParameters.MinimumLevelPhreaticLineAtDikeTopPolder.ToNaNAsNull(); SetLocationInputExtremeParametersToEntity(entity, inputParameters.LocationInputExtreme); SetLocationInputDailyParametersToEntity(entity, inputParameters.LocationInputDaily); entity.AdjustPhreaticLine3And4ForUplift = Convert.ToByte(inputParameters.AdjustPhreaticLine3And4ForUplift); entity.LeakageLengthOutwardsPhreaticLine4 = inputParameters.LeakageLengthOutwardsPhreaticLine4.ToNaNAsNull(); entity.LeakageLengthInwardsPhreaticLine4 = inputParameters.LeakageLengthInwardsPhreaticLine4.ToNaNAsNull(); entity.LeakageLengthOutwardsPhreaticLine3 = inputParameters.LeakageLengthOutwardsPhreaticLine3.ToNaNAsNull(); entity.LeakageLengthInwardsPhreaticLine3 = inputParameters.LeakageLengthInwardsPhreaticLine3.ToNaNAsNull(); entity.PiezometricHeadPhreaticLine2Outwards = inputParameters.PiezometricHeadPhreaticLine2Outwards.ToNaNAsNull(); entity.PiezometricHeadPhreaticLine2Inwards = inputParameters.PiezometricHeadPhreaticLine2Inwards.ToNaNAsNull(); entity.GridDeterminationType = Convert.ToByte(inputParameters.GridDeterminationType); entity.TangentLineDeterminationType = Convert.ToByte(inputParameters.TangentLineDeterminationType); entity.TangentLineZTop = inputParameters.TangentLineZTop.ToNaNAsNull(); entity.TangentLineZBottom = inputParameters.TangentLineZBottom.ToNaNAsNull(); entity.TangentLineNumber = inputParameters.TangentLineNumber; SetGridParametersToEntity(entity, inputParameters.LeftGrid, inputParameters.RightGrid); entity.CreateZones = Convert.ToByte(inputParameters.CreateZones); entity.ZoningBoundariesDeterminationType = Convert.ToByte(inputParameters.ZoningBoundariesDeterminationType); entity.ZoneBoundaryLeft = inputParameters.ZoneBoundaryLeft.ToNaNAsNull(); entity.ZoneBoundaryRight = inputParameters.ZoneBoundaryRight.ToNaNAsNull(); }
private static void SetCalculationOutputsToScenario(MacroStabilityInwardsCalculationScenario calculationScenario, MacroStabilityInwardsCalculationEntity entity) { MacroStabilityInwardsCalculationOutputEntity outputEntity = entity.MacroStabilityInwardsCalculationOutputEntities.SingleOrDefault(); if (outputEntity != null) { calculationScenario.Output = outputEntity.Read(); } }
private static void SetLocationInputDailyToInput(IMacroStabilityInwardsLocationInputDaily inputDaily, MacroStabilityInwardsCalculationEntity entity) { inputDaily.WaterLevelPolder = (RoundedDouble)entity.LocationInputDailyWaterLevelPolder.ToNullAsNaN(); inputDaily.UseDefaultOffsets = Convert.ToBoolean(entity.LocationInputDailyUseDefaultOffsets); inputDaily.PhreaticLineOffsetBelowDikeTopAtRiver = (RoundedDouble)entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver.ToNullAsNaN(); inputDaily.PhreaticLineOffsetBelowDikeTopAtPolder = (RoundedDouble)entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder.ToNullAsNaN(); inputDaily.PhreaticLineOffsetBelowShoulderBaseInside = (RoundedDouble)entity.LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside.ToNullAsNaN(); inputDaily.PhreaticLineOffsetBelowDikeToeAtPolder = (RoundedDouble)entity.LocationInputDailyPhreaticLineOffsetDikeToeAtPolder.ToNullAsNaN(); }
private static void SetLocationInputDailyParametersToEntity(MacroStabilityInwardsCalculationEntity entity, IMacroStabilityInwardsLocationInputDaily inputParameters) { entity.LocationInputDailyWaterLevelPolder = inputParameters.WaterLevelPolder.ToNaNAsNull(); entity.LocationInputDailyUseDefaultOffsets = Convert.ToByte(inputParameters.UseDefaultOffsets); entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver = inputParameters.PhreaticLineOffsetBelowDikeTopAtRiver.ToNaNAsNull(); entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder = inputParameters.PhreaticLineOffsetBelowDikeTopAtPolder.ToNaNAsNull(); entity.LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside = inputParameters.PhreaticLineOffsetBelowShoulderBaseInside.ToNaNAsNull(); entity.LocationInputDailyPhreaticLineOffsetDikeToeAtPolder = inputParameters.PhreaticLineOffsetBelowDikeToeAtPolder.ToNaNAsNull(); }
private static void SetHydraulicBoundaryLocationInputToEntity(MacroStabilityInwardsCalculationEntity entity, MacroStabilityInwardsInput inputParameters, PersistenceRegistry registry) { entity.UseAssessmentLevelManualInput = Convert.ToByte(inputParameters.UseAssessmentLevelManualInput); entity.AssessmentLevel = inputParameters.AssessmentLevel.ToNaNAsNull(); if (inputParameters.HydraulicBoundaryLocation != null) { entity.HydraulicLocationEntity = registry.Get(inputParameters.HydraulicBoundaryLocation); } }
private static void SetHydraulicBoundaryLocationPropertiesToInput(MacroStabilityInwardsInput inputParameters, MacroStabilityInwardsCalculationEntity entity, ReadConversionCollector collector) { inputParameters.UseAssessmentLevelManualInput = Convert.ToBoolean(entity.UseAssessmentLevelManualInput); inputParameters.AssessmentLevel = (RoundedDouble)entity.AssessmentLevel.ToNullAsNaN(); if (entity.HydraulicLocationEntity != null) { inputParameters.HydraulicBoundaryLocation = entity.HydraulicLocationEntity.Read(collector); } }
private static void SetStochasticSoilModelToInput(MacroStabilityInwardsInput inputParameters, MacroStabilityInwardsCalculationEntity entity, ReadConversionCollector collector) { if (entity.MacroStabilityInwardsStochasticSoilProfileEntity != null) { inputParameters.StochasticSoilModel = entity.MacroStabilityInwardsStochasticSoilProfileEntity .StochasticSoilModelEntity .ReadAsMacroStabilityInwardsStochasticSoilModel(collector); inputParameters.StochasticSoilProfile = entity.MacroStabilityInwardsStochasticSoilProfileEntity.Read(collector); } }
private static void SetLocationInputExtremeToInput(IMacroStabilityInwardsLocationInputExtreme inputExtreme, MacroStabilityInwardsCalculationEntity entity) { inputExtreme.WaterLevelPolder = (RoundedDouble)entity.LocationInputExtremeWaterLevelPolder.ToNullAsNaN(); inputExtreme.UseDefaultOffsets = Convert.ToBoolean(entity.LocationInputExtremeUseDefaultOffsets); inputExtreme.PhreaticLineOffsetBelowDikeTopAtRiver = (RoundedDouble)entity.LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver.ToNullAsNaN(); inputExtreme.PhreaticLineOffsetBelowDikeTopAtPolder = (RoundedDouble)entity.LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder.ToNullAsNaN(); inputExtreme.PhreaticLineOffsetBelowShoulderBaseInside = (RoundedDouble)entity.LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside.ToNullAsNaN(); inputExtreme.PhreaticLineOffsetBelowDikeToeAtPolder = (RoundedDouble)entity.LocationInputExtremePhreaticLineOffsetDikeToeAtPolder.ToNullAsNaN(); inputExtreme.PenetrationLength = (RoundedDouble)entity.LocationInputExtremePenetrationLength.ToNullAsNaN(); }
public void Read_CollectorNull_ThrowsArgumentNullException() { // Setup MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); // Call void Call() => entity.Read(null); // Assert var exception = Assert.Throws <ArgumentNullException>(Call); Assert.AreEqual("collector", exception.ParamName); }
private static void SetInputParameters(MacroStabilityInwardsInput inputParameters, MacroStabilityInwardsCalculationEntity entity, ReadConversionCollector collector) { SetHydraulicBoundaryLocationPropertiesToInput(inputParameters, entity, collector); SetSurfaceLineToInput(inputParameters, entity, collector); SetStochasticSoilModelToInput(inputParameters, entity, collector); inputParameters.SlipPlaneMinimumLength = (RoundedDouble)entity.SlipPlaneMinimumLength.ToNullAsNaN(); inputParameters.SlipPlaneMinimumDepth = (RoundedDouble)entity.SlipPlaneMinimumDepth.ToNullAsNaN(); inputParameters.MaximumSliceWidth = (RoundedDouble)entity.MaximumSliceWidth.ToNullAsNaN(); inputParameters.MoveGrid = Convert.ToBoolean(entity.MoveGrid); inputParameters.DikeSoilScenario = (MacroStabilityInwardsDikeSoilScenario)entity.DikeSoilScenario; inputParameters.WaterLevelRiverAverage = (RoundedDouble)entity.WaterLevelRiverAverage.ToNullAsNaN(); inputParameters.DrainageConstructionPresent = Convert.ToBoolean(entity.DrainageConstructionPresent); inputParameters.XCoordinateDrainageConstruction = (RoundedDouble)entity.DrainageConstructionCoordinateX.ToNullAsNaN(); inputParameters.ZCoordinateDrainageConstruction = (RoundedDouble)entity.DrainageConstructionCoordinateZ.ToNullAsNaN(); inputParameters.MinimumLevelPhreaticLineAtDikeTopRiver = (RoundedDouble)entity.MinimumLevelPhreaticLineAtDikeTopRiver.ToNullAsNaN(); inputParameters.MinimumLevelPhreaticLineAtDikeTopPolder = (RoundedDouble)entity.MinimumLevelPhreaticLineAtDikeTopPolder.ToNullAsNaN(); SetLocationInputExtremeToInput(inputParameters.LocationInputExtreme, entity); SetLocationInputDailyToInput(inputParameters.LocationInputDaily, entity); inputParameters.AdjustPhreaticLine3And4ForUplift = Convert.ToBoolean(entity.AdjustPhreaticLine3And4ForUplift); inputParameters.LeakageLengthOutwardsPhreaticLine4 = (RoundedDouble)entity.LeakageLengthOutwardsPhreaticLine4.ToNullAsNaN(); inputParameters.LeakageLengthInwardsPhreaticLine4 = (RoundedDouble)entity.LeakageLengthInwardsPhreaticLine4.ToNullAsNaN(); inputParameters.LeakageLengthOutwardsPhreaticLine3 = (RoundedDouble)entity.LeakageLengthOutwardsPhreaticLine3.ToNullAsNaN(); inputParameters.LeakageLengthInwardsPhreaticLine3 = (RoundedDouble)entity.LeakageLengthInwardsPhreaticLine3.ToNullAsNaN(); inputParameters.PiezometricHeadPhreaticLine2Outwards = (RoundedDouble)entity.PiezometricHeadPhreaticLine2Outwards.ToNullAsNaN(); inputParameters.PiezometricHeadPhreaticLine2Inwards = (RoundedDouble)entity.PiezometricHeadPhreaticLine2Inwards.ToNullAsNaN(); inputParameters.GridDeterminationType = (MacroStabilityInwardsGridDeterminationType)entity.GridDeterminationType; inputParameters.TangentLineDeterminationType = (MacroStabilityInwardsTangentLineDeterminationType)entity.TangentLineDeterminationType; inputParameters.TangentLineZTop = (RoundedDouble)entity.TangentLineZTop.ToNullAsNaN(); inputParameters.TangentLineZBottom = (RoundedDouble)entity.TangentLineZBottom.ToNullAsNaN(); inputParameters.TangentLineNumber = entity.TangentLineNumber; SetGridparametersToInput(inputParameters.LeftGrid, inputParameters.RightGrid, entity); inputParameters.CreateZones = Convert.ToBoolean(entity.CreateZones); inputParameters.ZoningBoundariesDeterminationType = (MacroStabilityInwardsZoningBoundariesDeterminationType)entity.ZoningBoundariesDeterminationType; inputParameters.ZoneBoundaryLeft = (RoundedDouble)entity.ZoneBoundaryLeft.ToNullAsNaN(); inputParameters.ZoneBoundaryRight = (RoundedDouble)entity.ZoneBoundaryRight.ToNullAsNaN(); }
private static void AssertGridInputs(MacroStabilityInwardsGrid leftGrid, MacroStabilityInwardsGrid rightGrid, MacroStabilityInwardsCalculationEntity entity) { AssertAreEqual(leftGrid.XLeft, entity.LeftGridXLeft); AssertAreEqual(leftGrid.XRight, entity.LeftGridXRight); Assert.AreEqual(leftGrid.NumberOfHorizontalPoints, entity.LeftGridNrOfHorizontalPoints); AssertAreEqual(leftGrid.ZTop, entity.LeftGridZTop); AssertAreEqual(leftGrid.ZBottom, entity.LeftGridZBottom); Assert.AreEqual(leftGrid.NumberOfVerticalPoints, entity.LeftGridNrOfVerticalPoints); AssertAreEqual(rightGrid.XLeft, entity.RightGridXLeft); AssertAreEqual(rightGrid.XRight, entity.RightGridXRight); Assert.AreEqual(rightGrid.NumberOfHorizontalPoints, entity.RightGridNrOfHorizontalPoints); AssertAreEqual(rightGrid.ZTop, entity.RightGridZTop); AssertAreEqual(rightGrid.ZBottom, entity.RightGridZBottom); Assert.AreEqual(rightGrid.NumberOfVerticalPoints, entity.RightGridNrOfVerticalPoints); }
private static void SetGridparametersToInput(MacroStabilityInwardsGrid leftGrid, MacroStabilityInwardsGrid rightGrid, MacroStabilityInwardsCalculationEntity entity) { leftGrid.XLeft = (RoundedDouble)entity.LeftGridXLeft.ToNullAsNaN(); leftGrid.XRight = (RoundedDouble)entity.LeftGridXRight.ToNullAsNaN(); leftGrid.NumberOfHorizontalPoints = entity.LeftGridNrOfHorizontalPoints; leftGrid.ZTop = (RoundedDouble)entity.LeftGridZTop.ToNullAsNaN(); leftGrid.ZBottom = (RoundedDouble)entity.LeftGridZBottom.ToNullAsNaN(); leftGrid.NumberOfVerticalPoints = entity.LeftGridNrOfVerticalPoints; rightGrid.XLeft = (RoundedDouble)entity.RightGridXLeft.ToNullAsNaN(); rightGrid.XRight = (RoundedDouble)entity.RightGridXRight.ToNullAsNaN(); rightGrid.NumberOfHorizontalPoints = entity.RightGridNrOfHorizontalPoints; rightGrid.ZTop = (RoundedDouble)entity.RightGridZTop.ToNullAsNaN(); rightGrid.ZBottom = (RoundedDouble)entity.RightGridZBottom.ToNullAsNaN(); rightGrid.NumberOfVerticalPoints = entity.RightGridNrOfVerticalPoints; }
private static void SetGridParametersToEntity(MacroStabilityInwardsCalculationEntity entity, MacroStabilityInwardsGrid leftGrid, MacroStabilityInwardsGrid rightGrid) { entity.LeftGridXLeft = leftGrid.XLeft.ToNaNAsNull(); entity.LeftGridXRight = leftGrid.XRight.ToNaNAsNull(); entity.LeftGridNrOfHorizontalPoints = leftGrid.NumberOfHorizontalPoints; entity.LeftGridZTop = leftGrid.ZTop.ToNaNAsNull(); entity.LeftGridZBottom = leftGrid.ZBottom.ToNaNAsNull(); entity.LeftGridNrOfVerticalPoints = leftGrid.NumberOfVerticalPoints; entity.RightGridXLeft = rightGrid.XLeft.ToNaNAsNull(); entity.RightGridXRight = rightGrid.XRight.ToNaNAsNull(); entity.RightGridNrOfHorizontalPoints = rightGrid.NumberOfHorizontalPoints; entity.RightGridZTop = rightGrid.ZTop.ToNaNAsNull(); entity.RightGridZBottom = rightGrid.ZBottom.ToNaNAsNull(); entity.RightGridNrOfVerticalPoints = rightGrid.NumberOfVerticalPoints; }
private static void AssertLocationInputs(IMacroStabilityInwardsLocationInputExtreme locationInputExtreme, IMacroStabilityInwardsLocationInputDaily locationInputDaily, MacroStabilityInwardsCalculationEntity entity) { AssertAreEqual(locationInputExtreme.WaterLevelPolder, entity.LocationInputExtremeWaterLevelPolder); Assert.AreEqual(Convert.ToByte(locationInputExtreme.UseDefaultOffsets), entity.LocationInputExtremeUseDefaultOffsets); AssertAreEqual(locationInputExtreme.PhreaticLineOffsetBelowDikeTopAtRiver, entity.LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver); AssertAreEqual(locationInputExtreme.PhreaticLineOffsetBelowDikeTopAtPolder, entity.LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder); AssertAreEqual(locationInputExtreme.PhreaticLineOffsetBelowShoulderBaseInside, entity.LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside); AssertAreEqual(locationInputExtreme.PhreaticLineOffsetBelowDikeToeAtPolder, entity.LocationInputExtremePhreaticLineOffsetDikeToeAtPolder); AssertAreEqual(locationInputExtreme.PenetrationLength, entity.LocationInputExtremePenetrationLength); AssertAreEqual(locationInputDaily.WaterLevelPolder, entity.LocationInputDailyWaterLevelPolder); Assert.AreEqual(Convert.ToByte(locationInputDaily.UseDefaultOffsets), entity.LocationInputDailyUseDefaultOffsets); AssertAreEqual(locationInputDaily.PhreaticLineOffsetBelowDikeTopAtRiver, entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver); AssertAreEqual(locationInputDaily.PhreaticLineOffsetBelowDikeTopAtPolder, entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder); AssertAreEqual(locationInputDaily.PhreaticLineOffsetBelowShoulderBaseInside, entity.LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside); AssertAreEqual(locationInputDaily.PhreaticLineOffsetBelowDikeToeAtPolder, entity.LocationInputDailyPhreaticLineOffsetDikeToeAtPolder); }
public void Create_HasMacroStabilityInwardsOutput_ReturnsEntityWithOutputEntity() { // Setup var scenario = new MacroStabilityInwardsCalculationScenario { Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() }; var registry = new PersistenceRegistry(); // Call MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, 0); // Assert Assert.IsNotNull(entity); MacroStabilityInwardsCalculationOutputEntity outputEntity = entity.MacroStabilityInwardsCalculationOutputEntities.SingleOrDefault(); Assert.IsNotNull(outputEntity); MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(scenario.Output, outputEntity); }
public void Read_EntityWithHydraulicBoundaryLocationEntity_ReturnsCalculationScenarioWithInputObjectWithLocationSet() { // Setup var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); var hydraulicLocationEntity = new HydraulicLocationEntity(); var collector = new ReadConversionCollector(); collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation); MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); entity.HydraulicLocationEntity = hydraulicLocationEntity; // Call MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation); }
public void Read_EntityWithSurfaceLineEntity_ReturnsCalculationScenarioWithInputObjectWithSurfaceLineSet() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); var surfaceLineEntity = new SurfaceLineEntity(); var collector = new ReadConversionCollector(); collector.Read(surfaceLineEntity, surfaceLine); MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); entity.SurfaceLineEntity = surfaceLineEntity; // Call MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreSame(surfaceLine, calculation.InputParameters.SurfaceLine); }
public void Read_EntityWithNullValues_ReturnsCalculationScenarioWithNaNValues() { // Setup MacroStabilityInwardsCalculationEntity entity = CreateValidCalculationEntity(); var collector = new ReadConversionCollector(); // Call MacroStabilityInwardsCalculationScenario calculation = entity.Read(collector); // Assert Assert.IsNull(calculation.Output); Assert.IsNull(calculation.Comments.Body); MacroStabilityInwardsInput inputParameters = calculation.InputParameters; Assert.IsNull(inputParameters.StochasticSoilModel); Assert.IsNull(inputParameters.StochasticSoilProfile); Assert.IsNull(inputParameters.SurfaceLine); MacroStabilityInwardsCalculationEntityTestHelper.AssertCalculationScenarioPropertyValues(calculation, entity); }
private static void AssertInputParameters(MacroStabilityInwardsInput input, MacroStabilityInwardsCalculationEntity entity) { AssertAreEqual(input.AssessmentLevel, entity.AssessmentLevel); Assert.AreEqual(Convert.ToByte(input.UseAssessmentLevelManualInput), entity.UseAssessmentLevelManualInput); AssertAreEqual(input.SlipPlaneMinimumDepth, entity.SlipPlaneMinimumDepth); AssertAreEqual(input.SlipPlaneMinimumLength, entity.SlipPlaneMinimumLength); AssertAreEqual(input.MaximumSliceWidth, entity.MaximumSliceWidth); Assert.AreEqual(Convert.ToByte(input.MoveGrid), entity.MoveGrid); Assert.AreEqual(Convert.ToByte(input.DikeSoilScenario), entity.DikeSoilScenario); AssertAreEqual(input.WaterLevelRiverAverage, entity.WaterLevelRiverAverage); Assert.AreEqual(Convert.ToByte(input.DrainageConstructionPresent), entity.DrainageConstructionPresent); AssertAreEqual(input.XCoordinateDrainageConstruction, entity.DrainageConstructionCoordinateX); AssertAreEqual(input.ZCoordinateDrainageConstruction, entity.DrainageConstructionCoordinateZ); AssertAreEqual(input.MinimumLevelPhreaticLineAtDikeTopRiver, entity.MinimumLevelPhreaticLineAtDikeTopRiver); AssertAreEqual(input.MinimumLevelPhreaticLineAtDikeTopPolder, entity.MinimumLevelPhreaticLineAtDikeTopPolder); AssertLocationInputs(input.LocationInputExtreme, input.LocationInputDaily, entity); Assert.AreEqual(Convert.ToByte(input.AdjustPhreaticLine3And4ForUplift), entity.AdjustPhreaticLine3And4ForUplift); AssertAreEqual(input.LeakageLengthOutwardsPhreaticLine3, entity.LeakageLengthOutwardsPhreaticLine3); AssertAreEqual(input.LeakageLengthInwardsPhreaticLine3, entity.LeakageLengthInwardsPhreaticLine3); AssertAreEqual(input.LeakageLengthOutwardsPhreaticLine4, entity.LeakageLengthOutwardsPhreaticLine4); AssertAreEqual(input.LeakageLengthInwardsPhreaticLine4, entity.LeakageLengthInwardsPhreaticLine4); AssertAreEqual(input.PiezometricHeadPhreaticLine2Outwards, entity.PiezometricHeadPhreaticLine2Outwards); AssertAreEqual(input.PiezometricHeadPhreaticLine2Inwards, entity.PiezometricHeadPhreaticLine2Inwards); Assert.AreEqual(Convert.ToByte(input.GridDeterminationType), entity.GridDeterminationType); Assert.AreEqual(Convert.ToByte(input.TangentLineDeterminationType), entity.TangentLineDeterminationType); AssertAreEqual(input.TangentLineZTop, entity.TangentLineZTop); AssertAreEqual(input.TangentLineZBottom, entity.TangentLineZBottom); Assert.AreEqual(input.TangentLineNumber, entity.TangentLineNumber); AssertGridInputs(input.LeftGrid, input.RightGrid, entity); Assert.AreEqual(Convert.ToByte(input.CreateZones), entity.CreateZones); Assert.AreEqual(Convert.ToByte(input.ZoningBoundariesDeterminationType), entity.ZoningBoundariesDeterminationType); AssertAreEqual(input.ZoneBoundaryLeft, entity.ZoneBoundaryLeft); AssertAreEqual(input.ZoneBoundaryRight, entity.ZoneBoundaryRight); }
/// <summary> /// Creates a <see cref="MacroStabilityInwardsCalculationEntity"/> based on the information of the <see cref="MacroStabilityInwardsCalculationScenario"/>. /// </summary> /// <param name="calculation">The macro stability inwards calculation to create a database entity for.</param> /// <param name="registry">The object keeping track of create operations.</param> /// <param name="order">The index at which <paramref name="calculation"/> resides within its parent.</param> /// <returns>A new <see cref="MacroStabilityInwardsCalculationEntity"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception> public static MacroStabilityInwardsCalculationEntity Create(this MacroStabilityInwardsCalculationScenario calculation, PersistenceRegistry registry, int order) { if (registry == null) { throw new ArgumentNullException(nameof(registry)); } var entity = new MacroStabilityInwardsCalculationEntity { Name = calculation.Name.DeepClone(), Comment = calculation.Comments.Body.DeepClone(), ScenarioContribution = calculation.Contribution, RelevantForScenario = Convert.ToByte(calculation.IsRelevant), Order = order }; SetInputParametersToEntity(entity, calculation.InputParameters, registry); AddEntityForMacroStabilityInwardsOutput(entity, calculation.Output); return(entity); }
public void Create_GroupWithMacroStabilityInwardsCalculations_CreatesEntities() { // Setup var group = new CalculationGroup { Children = { new MacroStabilityInwardsCalculationScenario { Name = "A" }, new MacroStabilityInwardsCalculationScenario { Name = "B" } } }; var registry = new PersistenceRegistry(); // Call CalculationGroupEntity entity = group.Create(registry, 0); // Assert MacroStabilityInwardsCalculationEntity[] childCalculationEntities = entity.MacroStabilityInwardsCalculationEntities.ToArray(); Assert.AreEqual(2, childCalculationEntities.Length); MacroStabilityInwardsCalculationEntity childEntity1 = childCalculationEntities[0]; Assert.AreEqual("A", childEntity1.Name); Assert.AreEqual(0, childEntity1.Order); MacroStabilityInwardsCalculationEntity childEntity2 = childCalculationEntities[1]; Assert.AreEqual("B", childEntity2.Name); Assert.AreEqual(1, childEntity2.Order); }
public void Create_WithCalculationGroup_ReturnFailureMechanismWithCalculationGroupEntities() { // Setup var calculationGroup = new CalculationGroup(); var calculation = new MacroStabilityInwardsCalculationScenario(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculationGroup); failureMechanism.CalculationsGroup.Children.Add(calculation); // Call FailureMechanismEntity entity = failureMechanism.Create(new PersistenceRegistry()); // Assert Assert.IsNotNull(entity); Assert.AreEqual(failureMechanism.CalculationsGroup.Name, entity.CalculationGroupEntity.Name); Assert.AreEqual(0, entity.CalculationGroupEntity.Order); CalculationGroupEntity[] childGroupEntities = entity.CalculationGroupEntity.CalculationGroupEntity1 .OrderBy(cge => cge.Order) .ToArray(); Assert.AreEqual(1, childGroupEntities.Length); CalculationGroupEntity childGroupEntity = childGroupEntities[0]; Assert.AreEqual(calculationGroup.Name, childGroupEntity.Name); Assert.AreEqual(0, childGroupEntity.Order); MacroStabilityInwardsCalculationEntity[] calculationEntities = entity.CalculationGroupEntity.MacroStabilityInwardsCalculationEntities .OrderBy(ce => ce.Order) .ToArray(); Assert.AreEqual(1, calculationEntities.Length); MacroStabilityInwardsCalculationEntity calculationEntity = calculationEntities[0]; Assert.AreEqual(calculation.Name, calculationEntity.Name); Assert.AreEqual(1, calculationEntity.Order); }
public void Create_CalculationWithAlreadyRegisteredSurfaceLine_ReturnsEntityWithSurfaceLineEntity() { // Setup var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); var scenario = new MacroStabilityInwardsCalculationScenario { InputParameters = { SurfaceLine = surfaceLine } }; var registry = new PersistenceRegistry(); var surfaceLineEntity = new SurfaceLineEntity(); registry.Register(surfaceLineEntity, surfaceLine); // Call MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, 0); // Assert Assert.IsNotNull(entity); Assert.AreSame(surfaceLineEntity, entity.SurfaceLineEntity); }
/// <summary> /// Read the <see cref="MacroStabilityInwardsCalculationEntity"/> and use the information to /// construct a <see cref="MacroStabilityInwardsCalculationScenario"/>. /// </summary> /// <param name="entity">The <see cref="MacroStabilityInwardsCalculationEntity"/> to create /// <see cref="MacroStabilityInwardsCalculationScenario"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsCalculationScenario"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> public static MacroStabilityInwardsCalculationScenario Read(this MacroStabilityInwardsCalculationEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } var calculationScenario = new MacroStabilityInwardsCalculationScenario { Name = entity.Name, IsRelevant = Convert.ToBoolean(entity.RelevantForScenario), Contribution = (RoundedDouble)entity.ScenarioContribution, Comments = { Body = entity.Comment } }; SetInputParameters(calculationScenario.InputParameters, entity, collector); SetCalculationOutputsToScenario(calculationScenario, entity); return(calculationScenario); }