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 Read_EntityWithStochasticSoilModelEntityInCollector_CalculationHasAlreadyReadStochasticSoilModel() { // Setup PipingStochasticSoilModel stochasticSoilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel(); var stochasticSoilModelEntity = new StochasticSoilModelEntity(); var stochasticSoilProfile = new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); var stochasticSoilProfileEntity = new PipingStochasticSoilProfileEntity { StochasticSoilModelEntity = stochasticSoilModelEntity }; var entity = new SemiProbabilisticPipingCalculationEntity { PipingStochasticSoilProfileEntity = stochasticSoilProfileEntity, EntryPointL = 1, ExitPointL = 2, DampingFactorExitMean = 1, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(stochasticSoilProfileEntity, stochasticSoilProfile); collector.Read(stochasticSoilModelEntity, stochasticSoilModel); // Call SemiProbabilisticPipingCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreSame(stochasticSoilProfile, calculation.InputParameters.StochasticSoilProfile); Assert.AreSame(stochasticSoilModel, calculation.InputParameters.StochasticSoilModel); }
public void Read_EntityWithValidValues_SetsCalculationsWithExpectedValues() { // Setup var random = new Random(21); var duneLocationEntityOne = new DuneLocationEntity(); var calculationEntityWithoutOutput = new DuneLocationCalculationEntity { DuneLocationEntity = duneLocationEntityOne }; var duneLocationEntityTwo = new DuneLocationEntity(); var calculationEntityWithOutput = new DuneLocationCalculationEntity { DuneLocationEntity = duneLocationEntityTwo, DuneLocationCalculationOutputEntities = { new DuneLocationCalculationOutputEntity() } }; var collectionEntity = new DuneLocationCalculationForTargetProbabilityCollectionEntity { TargetProbability = random.NextDouble(0, 0.1), DuneLocationCalculationEntities = { calculationEntityWithoutOutput, calculationEntityWithOutput } }; var duneLocationOne = new TestDuneLocation("1"); var duneLocationTwo = new TestDuneLocation("2"); var collector = new ReadConversionCollector(); collector.Read(duneLocationEntityOne, duneLocationOne); collector.Read(duneLocationEntityTwo, duneLocationTwo); // Call DuneLocationCalculationsForTargetProbability calculations = collectionEntity.Read(collector); // Assert Assert.AreEqual(collectionEntity.TargetProbability, calculations.TargetProbability); IEnumerable <DuneLocationCalculation> duneLocationCalculations = calculations.DuneLocationCalculations; Assert.AreEqual(collectionEntity.DuneLocationCalculationEntities.Count, duneLocationCalculations.Count()); DuneLocationCalculation calculationOne = duneLocationCalculations.ElementAt(0); Assert.AreSame(collector.Get(duneLocationEntityOne), calculationOne.DuneLocation); Assert.IsNull(calculationOne.Output); DuneLocationCalculation calculationTwo = duneLocationCalculations.ElementAt(1); Assert.AreSame(collector.Get(duneLocationEntityTwo), calculationTwo.DuneLocation); Assert.IsNotNull(calculationTwo.Output); }
public void Read_EntityWithValidValues_SetsCalculationsWithExpectedValues() { // Setup var random = new Random(21); HydraulicLocationEntity hydraulicLocationEntityOne = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity(); var calculationEntityWithoutOutput = new HydraulicLocationCalculationEntity { HydraulicLocationEntity = hydraulicLocationEntityOne, ShouldIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()) }; HydraulicLocationEntity hydraulicLocationEntityTwo = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity(); var calculationEntityWithOutput = new HydraulicLocationCalculationEntity { HydraulicLocationEntity = hydraulicLocationEntityTwo, ShouldIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean()), HydraulicLocationOutputEntities = { new HydraulicLocationOutputEntity() } }; var collectionEntity = new HydraulicLocationCalculationCollectionEntity { HydraulicLocationCalculationEntities = { calculationEntityWithoutOutput, calculationEntityWithOutput } }; var hydraulicBoundaryLocationOne = new TestHydraulicBoundaryLocation("1"); var hydraulicBoundaryLocationTwo = new TestHydraulicBoundaryLocation("2"); var collector = new ReadConversionCollector(); collector.Read(hydraulicLocationEntityOne, hydraulicBoundaryLocationOne); collector.Read(hydraulicLocationEntityTwo, hydraulicBoundaryLocationTwo); var calculationOne = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocationOne); var calculationTwo = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocationTwo); // Call collectionEntity.Read(new[] { calculationOne, calculationTwo }, collector); // Assert Assert.AreEqual(Convert.ToBoolean(calculationEntityWithoutOutput.ShouldIllustrationPointsBeCalculated), calculationOne.InputParameters.ShouldIllustrationPointsBeCalculated); Assert.IsNull(calculationOne.Output); Assert.AreEqual(Convert.ToBoolean(calculationEntityWithOutput.ShouldIllustrationPointsBeCalculated), calculationTwo.InputParameters.ShouldIllustrationPointsBeCalculated); Assert.IsNotNull(calculationTwo.Output); }
/// <summary> /// Reads the <see cref="StochasticSoilModelEntity"/> and use the information to construct /// a <see cref="MacroStabilityInwardsStochasticSoilModel"/>. /// </summary> /// <param name="entity">The <see cref="StochasticSoilModelEntity"/> to create <see cref="MacroStabilityInwardsStochasticSoilModel"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsStochasticSoilModel"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="StochasticSoilModelEntity.StochasticSoilModelSegmentPointXml"/> /// of <paramref name="entity"/> is empty.</exception> public static MacroStabilityInwardsStochasticSoilModel ReadAsMacroStabilityInwardsStochasticSoilModel(this StochasticSoilModelEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.ContainsMacroStabilityInwardsStochasticSoilModel(entity)) { return(collector.GetMacroStabilityInwardsStochasticSoilModel(entity)); } Point2D[] geometry = ReadSegmentPoints(entity.StochasticSoilModelSegmentPointXml).ToArray(); MacroStabilityInwardsStochasticSoilProfile[] stochasticSoilProfiles = entity.ReadMacroStabilityInwardsStochasticSoilProfiles(collector) .ToArray(); var model = new MacroStabilityInwardsStochasticSoilModel(entity.Name, geometry, stochasticSoilProfiles); collector.Read(entity, model); return(model); }
/// <summary> /// Read the <see cref="ForeshoreProfileEntity"/> and use the information to construct a <see cref="ForeshoreProfile"/>. /// </summary> /// <param name="entity">The <see cref="ForeshoreProfileEntity"/> to create <see cref="ForeshoreProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="ForeshoreProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="ForeshoreProfileEntity.GeometryXml"/> /// of <paramref name="entity"/> is <c>null</c> or empty.</exception> internal static ForeshoreProfile Read(this ForeshoreProfileEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } Point2D[] points = new Point2DCollectionXmlSerializer().FromXml(entity.GeometryXml); var foreshoreProfile = new ForeshoreProfile(new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), points, CreateBreakWater(entity.BreakWaterType, entity.BreakWaterHeight), new ForeshoreProfile.ConstructionProperties { Id = entity.Id.DeepClone(), Name = entity.Name.DeepClone(), Orientation = entity.Orientation.ToNullAsNaN(), X0 = entity.X0.ToNullAsNaN() }); collector.Read(entity, foreshoreProfile); return(foreshoreProfile); }
/// <summary> /// Reads the <see cref="PipingStochasticSoilProfileEntity"/> and use the information to /// construct a <see cref="PipingStochasticSoilProfile"/>. /// </summary> /// <param name="entity">The <see cref="PipingStochasticSoilProfileEntity"/> to create /// <see cref="PipingStochasticSoilProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="PipingStochasticSoilProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static PipingStochasticSoilProfile Read(this PipingStochasticSoilProfileEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } PipingSoilProfile soilProfile = entity.ReadSoilProfile(collector); var stochasticSoilProfile = new PipingStochasticSoilProfile(entity.Probability, soilProfile); collector.Read(entity, stochasticSoilProfile); return(stochasticSoilProfile); }
/// <summary> /// Read the <see cref="SurfaceLineEntity"/> and use the information to construct /// a <see cref="PipingSurfaceLine"/>. /// </summary> /// <param name="entity">The <see cref="SurfaceLineEntity"/> to create /// <see cref="PipingSurfaceLine"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="PipingSurfaceLine"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="SurfaceLineEntity.PointsXml"/> /// of <paramref name="entity"/> is empty.</exception> /// <exception cref="InvalidEnumArgumentException">Thrown when the <paramref name="entity"/> /// contains an invalid type of characteristic point.</exception> /// <exception cref="NotSupportedException">Thrown when the <paramref name="entity"/> contains a /// characteristic point that is not supported.</exception> public static PipingSurfaceLine ReadAsPipingSurfaceLine(this SurfaceLineEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.ContainsPipingSurfaceLine(entity)) { return(collector.GetPipingSurfaceLine(entity)); } var surfaceLine = new PipingSurfaceLine(entity.Name) { ReferenceLineIntersectionWorldPoint = GetReferenceLineIntersectionWorldPoint(entity) }; surfaceLine.SetGeometry(ReadGeometryPoints(entity.PointsXml)); entity.ReadCharacteristicPoints(surfaceLine); collector.Read(entity, surfaceLine); return(surfaceLine); }
/// <summary> /// Read the <see cref="DuneLocationEntity"/> and use the information to construct a <see cref="DuneLocation"/>. /// </summary> /// <param name="entity">The <see cref="DuneLocationEntity"/> to create <see cref="DuneLocation"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="DuneLocation"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static DuneLocation Read(this DuneLocationEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var duneLocation = new DuneLocation(entity.LocationId, entity.Name, new Point2D(entity.LocationX.ToNullAsNaN(), entity.LocationY.ToNullAsNaN()), new DuneLocation.ConstructionProperties { CoastalAreaId = entity.CoastalAreaId, Offset = entity.Offset.ToNullAsNaN(), Orientation = entity.Orientation.ToNullAsNaN(), D50 = entity.D50.ToNullAsNaN() }); collector.Read(entity, duneLocation); return(duneLocation); }
/// <summary> /// Reads the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> and use the information /// to construct a <see cref="MacroStabilityInwardsSoilProfile2D"/>. /// </summary> /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> to /// create <see cref="MacroStabilityInwardsSoilProfile2D"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsSoilProfile2D"/> or one from the <paramref name="collector"/> /// if the <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> has been read before.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static MacroStabilityInwardsSoilProfile2D Read(this MacroStabilityInwardsSoilProfileTwoDEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } IEnumerable <MacroStabilityInwardsSoilLayer2D> layers = entity.MacroStabilityInwardsSoilLayerTwoDEntities .OrderBy(sl => sl.Order) .Select(sl => sl.Read()) .ToArray(); IEnumerable <MacroStabilityInwardsPreconsolidationStress> preconsolidationStresses = entity.MacroStabilityInwardsPreconsolidationStressEntities .OrderBy(stressEntity => stressEntity.Order) .Select(stressEntity => stressEntity.Read()) .ToArray(); var soilProfile = new MacroStabilityInwardsSoilProfile2D(entity.Name, layers, preconsolidationStresses); collector.Read(entity, soilProfile); return(soilProfile); }
/// <summary> /// Read the <see cref="HydraulicLocationEntity"/> and use the information to construct a <see cref="HydraulicBoundaryLocation"/>. /// </summary> /// <param name="entity">The <see cref="HydraulicLocationEntity"/> to create <see cref="HydraulicBoundaryLocation"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="HydraulicBoundaryLocation"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> internal static HydraulicBoundaryLocation Read(this HydraulicLocationEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(entity.LocationId, entity.Name, entity.LocationX.ToNullAsNaN(), entity.LocationY.ToNullAsNaN()); collector.Read(entity, hydraulicBoundaryLocation); return(hydraulicBoundaryLocation); }
/// <summary> /// Reads the <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> and use the information /// to construct a <see cref="MacroStabilityInwardsSoilProfile1D"/>. /// </summary> /// <param name="entity">The <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> to /// create <see cref="MacroStabilityInwardsSoilProfile1D"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="MacroStabilityInwardsSoilProfile1D"/> or one from the <paramref name="collector"/> /// if the <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> has been read before.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static MacroStabilityInwardsSoilProfile1D Read(this MacroStabilityInwardsSoilProfileOneDEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } IEnumerable <MacroStabilityInwardsSoilLayer1D> layers = entity.MacroStabilityInwardsSoilLayerOneDEntities.OrderBy(sl => sl.Order) .Select(sl => sl.Read()) .ToArray(); var macroStabilityInwardsSoilProfile = new MacroStabilityInwardsSoilProfile1D(entity.Name, entity.Bottom.ToNullAsNaN(), layers); collector.Read(entity, macroStabilityInwardsSoilProfile); return(macroStabilityInwardsSoilProfile); }
public void Read_EntityWithHydraulicBoundaryLocationInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocation() { // Setup var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); var hydraulicLocationEntity = new HydraulicLocationEntity(); var entity = new SemiProbabilisticPipingCalculationEntity { HydraulicLocationEntity = hydraulicLocationEntity, EntryPointL = 1, ExitPointL = 2, DampingFactorExitMean = 1, AssessmentLevel = 5.81, UseAssessmentLevelManualInput = Convert.ToByte(false), ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation); // Call SemiProbabilisticPipingCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation); }
/// <summary> /// Reads the <see cref="PipingSoilProfileEntity"/> and use the information to construct a <see cref="PipingSoilProfile"/>. /// </summary> /// <param name="entity">The <see cref="PipingSoilProfileEntity"/> to create <see cref="PipingSoilProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="PipingSoilProfile"/> or one from the <paramref name="collector"/> if the /// <see cref="PipingSoilProfileEntity"/> has been read before.</returns> /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception> public static PipingSoilProfile Read(this PipingSoilProfileEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } IEnumerable <PipingSoilLayer> layers = entity.PipingSoilLayerEntities.OrderBy(sl => sl.Order) .Select(sl => sl.Read()) .ToArray(); var pipingSoilProfile = new PipingSoilProfile(entity.Name, entity.Bottom.ToNullAsNaN(), layers, (SoilProfileType)entity.SourceType); collector.Read(entity, pipingSoilProfile); return(pipingSoilProfile); }
public void Read_EntityWithSurfaceLineInCollector_CalculationHasAlreadyReadSurfaceLine() { // Setup var surfaceLine = new PipingSurfaceLine(string.Empty); surfaceLine.SetGeometry(new[] { new Point3D(1, 2, 3), new Point3D(4, 5, 6) }); var surfaceLineEntity = new SurfaceLineEntity(); var entity = new SemiProbabilisticPipingCalculationEntity { SurfaceLineEntity = surfaceLineEntity, EntryPointL = 1, ExitPointL = 2, DampingFactorExitMean = 1, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(surfaceLineEntity, surfaceLine); // Call SemiProbabilisticPipingCalculationScenario calculation = entity.Read(collector); // Assert Assert.AreSame(surfaceLine, calculation.InputParameters.SurfaceLine); Assert.AreEqual(1, calculation.InputParameters.EntryPointL, 1e-6); Assert.AreEqual(2, calculation.InputParameters.ExitPointL, 1e-6); }
/// <summary> /// Reads the <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/> and uses /// the information to create a <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>. /// </summary> /// <param name="entity">The <see cref="HydraulicLocationCalculationForTargetProbabilityCollectionEntity"/> to create the /// <see cref="HydraulicBoundaryLocationCalculationsForTargetProbability"/>.</param> /// <param name="collector">The object keeping track of the read operations.</param> /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception> internal static HydraulicBoundaryLocationCalculationsForTargetProbability Read( this HydraulicLocationCalculationForTargetProbabilityCollectionEntity entity, ReadConversionCollector collector) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var calculations = new HydraulicBoundaryLocationCalculationsForTargetProbability(entity.TargetProbability); IEnumerable <HydraulicBoundaryLocationCalculation> hydraulicBoundaryLocationCalculations = entity.HydraulicLocationCalculationEntities .Select(hlce => CreateHydraulicBoundaryLocationCalculation(hlce, collector)) .ToArray(); calculations.HydraulicBoundaryLocationCalculations.AddRange(hydraulicBoundaryLocationCalculations); collector.Read(entity, calculations); return(calculations); }
/// <summary> /// Reads the <see cref="HeightStructureEntity"/> and use the information to update a /// <see cref="HeightStructure"/>. /// </summary> /// <param name="entity">The <see cref="HeightStructureEntity"/> to create <see cref="HeightStructure"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="HeightStructure"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> internal static HeightStructure Read(this HeightStructureEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var structure = new HeightStructure(new HeightStructure.ConstructionProperties { Name = entity.Name, Id = entity.Id, Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), StructureNormalOrientation = (RoundedDouble)entity.StructureNormalOrientation.ToNullAsNaN(), LevelCrestStructure = { Mean = (RoundedDouble)entity.LevelCrestStructureMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.LevelCrestStructureStandardDeviation.ToNullAsNaN() }, FlowWidthAtBottomProtection = { Mean = (RoundedDouble)entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN() }, CriticalOvertoppingDischarge = { Mean = (RoundedDouble)entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN() }, WidthFlowApertures = { Mean = (RoundedDouble)entity.WidthFlowAperturesMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN() }, FailureProbabilityStructureWithErosion = entity.FailureProbabilityStructureWithErosion.ToNullAsNaN(), StorageStructureArea = { Mean = (RoundedDouble)entity.StorageStructureAreaMean.ToNullAsNaN(), CoefficientOfVariation = (RoundedDouble)entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN() }, AllowedLevelIncreaseStorage = { Mean = (RoundedDouble)entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(), StandardDeviation = (RoundedDouble)entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN() } }); collector.Read(entity, structure); return(structure); }
/// <summary> /// Read the <see cref="FailureMechanismSectionEntity"/> and use the information to construct a <see cref="FailureMechanismSection"/>. /// </summary> /// <param name="entity">The <see cref="FailureMechanismSectionEntity"/> to create <see cref="FailureMechanismSection"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="FailureMechanismSection"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="FailureMechanismSectionEntity.FailureMechanismSectionPointXml"/> /// of <paramref name="entity"/> is <c>null</c> or empty.</exception> internal static FailureMechanismSection Read(this FailureMechanismSectionEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } Point2D[] points = new Point2DCollectionXmlSerializer().FromXml(entity.FailureMechanismSectionPointXml); var mechanismSection = new FailureMechanismSection(entity.Name, points); collector.Read(entity, mechanismSection); return(mechanismSection); }
public void Read_AlreadyReadDikeProfileEntity_ReturnDikeProfile() { // Setup var registeredEntity = new DikeProfileEntity(); DikeProfile registeredProfile = DikeProfileTestFactory.CreateDikeProfile(); var collector = new ReadConversionCollector(); collector.Read(registeredEntity, registeredProfile); // Call DikeProfile returnedProfile = registeredEntity.Read(collector); // Assert Assert.AreSame(registeredProfile, returnedProfile); }
public void Read_EntityRegistered_ReturnRegisteredStructure() { // Setup var entity = new ClosingStructureEntity(); ClosingStructure registeredStructure = new TestClosingStructure(); var collector = new ReadConversionCollector(); collector.Read(entity, registeredStructure); // Call ClosingStructure readStructure = entity.Read(collector); // Assert Assert.AreSame(registeredStructure, readStructure); }
public void Read_EntityWithHydraulicBoundaryLocationInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocation() { // Setup var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 1.1, 2.2); var hydraulicLocationEntity = new HydraulicLocationEntity(); var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity { HydraulicLocationEntity = hydraulicLocationEntity }; var collector = new ReadConversionCollector(); collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation); // Call WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector); // Assert Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation); }
public void Read_EntityWithHydraulicBoundaryLocationInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocation() { // Setup var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); HydraulicLocationEntity hydraulicLocationEntity = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity(); var entity = new GrassCoverErosionOutwardsWaveConditionsCalculationEntity { HydraulicLocationEntity = hydraulicLocationEntity }; var collector = new ReadConversionCollector(); collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation); // Call GrassCoverErosionOutwardsWaveConditionsCalculation calculation = entity.Read(collector); // Assert Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation); }
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_EntityWithStructureEntity_ReturnCalculationWithStructure() { // Setup StabilityPointStructure structure = new TestStabilityPointStructure(); var structureEntity = new StabilityPointStructureEntity(); var entity = new StabilityPointStructuresCalculationEntity { StabilityPointStructureEntity = structureEntity, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(structureEntity, structure); // Call StructuresCalculationScenario <StabilityPointStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreSame(structure, calculation.InputParameters.Structure); }
public void Read_EntityWithForeshoreProfileEntity_ReturnCalculationWithForeshoreProfile() { // Setup var profile = new TestForeshoreProfile(); var profileEntity = new ForeshoreProfileEntity(); var entity = new StabilityPointStructuresCalculationEntity { ForeshoreProfileEntity = profileEntity, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(profileEntity, profile); // Call StructuresCalculationScenario <StabilityPointStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreSame(profile, calculation.InputParameters.ForeshoreProfile); }
public void Read_EntityWithHydraulicLocationEntity_ReturnCalculationWithHydraulicBoundaryLocation() { // Setup var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 2, 3); var hydraulicLocationEntity = new HydraulicLocationEntity(); var entity = new StabilityPointStructuresCalculationEntity { HydraulicLocationEntity = hydraulicLocationEntity, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation); // Call StructuresCalculationScenario <StabilityPointStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation); }
public void Read_EntityWithStructureEntity_ReturnCalculationWithStructure() { // Setup ClosingStructure structure = new TestClosingStructure(); var structureEntity = new ClosingStructureEntity(); var entity = new ClosingStructuresCalculationEntity { ClosingStructureEntity = structureEntity, IdenticalApertures = 1, ScenarioContribution = 0 }; var collector = new ReadConversionCollector(); collector.Read(structureEntity, structure); // Call StructuresCalculationScenario <ClosingStructuresInput> calculation = entity.Read(collector); // Assert Assert.AreSame(structure, calculation.InputParameters.Structure); }
public void Read_EntityWithHydraulicBoundaryLocationCalculationsForTargetProbabilityInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocationCalculationsForTargetProbability() { // Setup var hydraulicBoundaryLocationCalculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.05); HydraulicLocationCalculationForTargetProbabilityCollectionEntity calculationForTargetProbabilityCollectionEntity = HydraulicLocationCalculationForTargetProbabilityCollectionEntityTestFactory.CreateHydraulicLocationCalculationForTargetProbabilityCollectionEntity(); var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity { HydraulicLocationCalculationForTargetProbabilityCollectionEntity = calculationForTargetProbabilityCollectionEntity }; var collector = new ReadConversionCollector(); collector.Read(calculationForTargetProbabilityCollectionEntity, hydraulicBoundaryLocationCalculationsForTargetProbability); // Call WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector); // Assert Assert.AreSame(hydraulicBoundaryLocationCalculationsForTargetProbability, calculation.InputParameters.CalculationsTargetProbability); }
/// <summary> /// Reads the <see cref="DikeProfileEntity"/> and use the information to update a /// <see cref="DikeProfile"/>. /// </summary> /// <param name="entity">The <see cref="DikeProfileEntity"/> to create <see cref="DikeProfile"/> for.</param> /// <param name="collector">The object keeping track of read operations.</param> /// <returns>A new <see cref="DikeProfile"/>.</returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception> /// <exception cref="ArgumentException">Thrown when <see cref="DikeProfileEntity.DikeGeometryXml"/> /// or <see cref="DikeProfileEntity.ForeshoreXml"/> of <paramref name="entity"/> is <c>null</c> or empty.</exception> internal static DikeProfile Read(this DikeProfileEntity entity, ReadConversionCollector collector) { if (collector == null) { throw new ArgumentNullException(nameof(collector)); } if (collector.Contains(entity)) { return(collector.Get(entity)); } var dikeProfile = new DikeProfile(new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), new RoughnessPointCollectionXmlSerializer().FromXml(entity.DikeGeometryXml), new Point2DCollectionXmlSerializer().FromXml(entity.ForeshoreXml), CreateBreakWater(entity), CreateProperties(entity)); collector.Read(entity, dikeProfile); return(dikeProfile); }