Exemplo n.º 1
0
        private static void ReadInputParameters(StabilityPointStructuresInput inputParameters,
                                                StabilityPointStructuresCalculationEntity entity,
                                                ReadConversionCollector collector)
        {
            if (entity.StabilityPointStructureEntity != null)
            {
                inputParameters.Structure = entity.StabilityPointStructureEntity.Read(collector);
            }

            entity.Read(inputParameters, collector);

            inputParameters.InsideWaterLevel.Mean = (RoundedDouble)entity.InsideWaterLevelMean.ToNullAsNaN();
            inputParameters.InsideWaterLevel.StandardDeviation        = (RoundedDouble)entity.InsideWaterLevelStandardDeviation.ToNullAsNaN();
            inputParameters.ThresholdHeightOpenWeir.Mean              = (RoundedDouble)entity.ThresholdHeightOpenWeirMean.ToNullAsNaN();
            inputParameters.ThresholdHeightOpenWeir.StandardDeviation = (RoundedDouble)entity.ThresholdHeightOpenWeirStandardDeviation.ToNullAsNaN();
            inputParameters.ConstructiveStrengthLinearLoadModel.Mean  = (RoundedDouble)entity.ConstructiveStrengthLinearLoadModelMean.ToNullAsNaN();
            inputParameters.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation = (RoundedDouble)entity.ConstructiveStrengthLinearLoadModelCoefficientOfVariation.ToNullAsNaN();
            inputParameters.ConstructiveStrengthQuadraticLoadModel.Mean = (RoundedDouble)entity.ConstructiveStrengthQuadraticLoadModelMean.ToNullAsNaN();
            inputParameters.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation = (RoundedDouble)entity.ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation.ToNullAsNaN();
            inputParameters.BankWidth.Mean = (RoundedDouble)entity.BankWidthMean.ToNullAsNaN();
            inputParameters.BankWidth.StandardDeviation = (RoundedDouble)entity.BankWidthStandardDeviation.ToNullAsNaN();
            inputParameters.InsideWaterLevelFailureConstruction.Mean = (RoundedDouble)entity.InsideWaterLevelFailureConstructionMean.ToNullAsNaN();
            inputParameters.InsideWaterLevelFailureConstruction.StandardDeviation = (RoundedDouble)entity.InsideWaterLevelFailureConstructionStandardDeviation.ToNullAsNaN();
            inputParameters.EvaluationLevel          = (RoundedDouble)entity.EvaluationLevel.ToNullAsNaN();
            inputParameters.LevelCrestStructure.Mean = (RoundedDouble)entity.LevelCrestStructureMean.ToNullAsNaN();
            inputParameters.LevelCrestStructure.StandardDeviation = (RoundedDouble)entity.LevelCrestStructureStandardDeviation.ToNullAsNaN();
            inputParameters.VerticalDistance = (RoundedDouble)entity.VerticalDistance.ToNullAsNaN();
            inputParameters.FailureProbabilityRepairClosure = entity.FailureProbabilityRepairClosure;
            inputParameters.FailureCollisionEnergy.Mean     = (RoundedDouble)entity.FailureCollisionEnergyMean.ToNullAsNaN();
            inputParameters.FailureCollisionEnergy.CoefficientOfVariation = (RoundedDouble)entity.FailureCollisionEnergyCoefficientOfVariation.ToNullAsNaN();
            inputParameters.ShipMass.Mean = (RoundedDouble)entity.ShipMassMean.ToNullAsNaN();
            inputParameters.ShipMass.CoefficientOfVariation = (RoundedDouble)entity.ShipMassCoefficientOfVariation.ToNullAsNaN();
            inputParameters.ShipVelocity.Mean = (RoundedDouble)entity.ShipVelocityMean.ToNullAsNaN();
            inputParameters.ShipVelocity.CoefficientOfVariation = (RoundedDouble)entity.ShipVelocityCoefficientOfVariation.ToNullAsNaN();
            inputParameters.LevellingCount = entity.LevellingCount;
            inputParameters.ProbabilityCollisionSecondaryStructure             = entity.ProbabilityCollisionSecondaryStructure;
            inputParameters.FlowVelocityStructureClosable.Mean                 = (RoundedDouble)entity.FlowVelocityStructureClosableMean.ToNullAsNaN();
            inputParameters.StabilityLinearLoadModel.Mean                      = (RoundedDouble)entity.StabilityLinearLoadModelMean.ToNullAsNaN();
            inputParameters.StabilityLinearLoadModel.CoefficientOfVariation    = (RoundedDouble)entity.StabilityLinearLoadModelCoefficientOfVariation.ToNullAsNaN();
            inputParameters.StabilityQuadraticLoadModel.Mean                   = (RoundedDouble)entity.StabilityQuadraticLoadModelMean.ToNullAsNaN();
            inputParameters.StabilityQuadraticLoadModel.CoefficientOfVariation = (RoundedDouble)entity.StabilityQuadraticLoadModelCoefficientOfVariation.ToNullAsNaN();
            inputParameters.AreaFlowApertures.Mean = (RoundedDouble)entity.AreaFlowAperturesMean.ToNullAsNaN();
            inputParameters.AreaFlowApertures.StandardDeviation = (RoundedDouble)entity.AreaFlowAperturesStandardDeviation.ToNullAsNaN();
            inputParameters.InflowModelType                    = (StabilityPointStructureInflowModelType)entity.InflowModelType;
            inputParameters.LoadSchematizationType             = (LoadSchematizationType)entity.LoadSchematizationType;
            inputParameters.VolumicWeightWater                 = (RoundedDouble)entity.VolumicWeightWater.ToNullAsNaN();
            inputParameters.FactorStormDurationOpenStructure   = (RoundedDouble)entity.FactorStormDurationOpenStructure.ToNullAsNaN();
            inputParameters.DrainCoefficient.Mean              = (RoundedDouble)entity.DrainCoefficientMean.ToNullAsNaN();
            inputParameters.DrainCoefficient.StandardDeviation = (RoundedDouble)entity.DrainCoefficientStandardDeviation.ToNullAsNaN();
        }
        public void Read_EntityWithCalculationOutputEntityWithBlocksAndColumns_CalculationWithOutput()
        {
            // Setup
            const double outputALevel = 5.4;
            const double outputBLevel = 2.3;
            const double outputCLevel = 13.2;
            var          entity       = new StabilityStoneCoverWaveConditionsCalculationEntity
            {
                StabilityStoneCoverWaveConditionsOutputEntities =
                {
                    new StabilityStoneCoverWaveConditionsOutputEntity
                    {
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        WaterLevel             = outputBLevel,
                        Order      = 1,
                        OutputType = Convert.ToByte(StabilityStoneCoverWaveConditionsOutputType.Columns)
                    },
                    new StabilityStoneCoverWaveConditionsOutputEntity
                    {
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        WaterLevel             = outputCLevel,
                        Order      = 2,
                        OutputType = Convert.ToByte(StabilityStoneCoverWaveConditionsOutputType.Blocks)
                    },
                    new StabilityStoneCoverWaveConditionsOutputEntity
                    {
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        WaterLevel             = outputALevel,
                        Order      = 0,
                        OutputType = Convert.ToByte(StabilityStoneCoverWaveConditionsOutputType.Columns)
                    }
                }
            };

            var collector = new ReadConversionCollector();

            // Call
            StabilityStoneCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.IsNotNull(calculation.Output);
            double accuracy = calculation.Output.ColumnsOutput.ElementAt(0).WaterLevel.GetAccuracy();

            Assert.AreEqual(2, calculation.Output.ColumnsOutput.Count());
            Assert.AreEqual(outputALevel, calculation.Output.ColumnsOutput.ElementAt(0).WaterLevel, accuracy);
            Assert.AreEqual(outputBLevel, calculation.Output.ColumnsOutput.ElementAt(1).WaterLevel, accuracy);

            Assert.AreEqual(1, calculation.Output.BlocksOutput.Count());
            Assert.AreEqual(outputCLevel, calculation.Output.BlocksOutput.ElementAt(0).WaterLevel, accuracy);
        }
        public void Read_EntityWithCalculationOutputEntityWithWaveRunUpAndWaveImpactWithWaveDirection_CalculationWithOutput()
        {
            // Setup
            const double outputALevel = 0;
            const double outputBLevel = 1.1;
            const double outputCLevel = 2.2;
            var          entity       = new GrassCoverErosionOutwardsWaveConditionsCalculationEntity
            {
                GrassCoverErosionOutwardsWaveConditionsOutputEntities =
                {
                    new GrassCoverErosionOutwardsWaveConditionsOutputEntity
                    {
                        WaterLevel             = outputBLevel,
                        Order                  = 1,
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        OutputType             = Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveRunUp)
                    },
                    new GrassCoverErosionOutwardsWaveConditionsOutputEntity
                    {
                        WaterLevel             = outputALevel,
                        Order                  = 0,
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        OutputType             = Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveRunUp)
                    },
                    new GrassCoverErosionOutwardsWaveConditionsOutputEntity
                    {
                        WaterLevel             = outputCLevel,
                        Order                  = 2,
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        OutputType             = Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveImpactWithWaveDirection)
                    }
                }
            };

            var collector = new ReadConversionCollector();

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.IsNotNull(calculation.Output);
            double accuracy = calculation.Output.WaveImpactWithWaveDirectionOutput.First().WaterLevel.GetAccuracy();

            Assert.AreEqual(2, calculation.Output.WaveRunUpOutput.Count());
            Assert.AreEqual(outputALevel, calculation.Output.WaveRunUpOutput.ElementAt(0).WaterLevel, accuracy);
            Assert.AreEqual(outputBLevel, calculation.Output.WaveRunUpOutput.ElementAt(1).WaterLevel, accuracy);

            Assert.AreEqual(1, calculation.Output.WaveImpactWithWaveDirectionOutput.Count());
            Assert.AreEqual(outputCLevel, calculation.Output.WaveImpactWithWaveDirectionOutput.ElementAt(0).WaterLevel, accuracy);
        }
        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();
        }
        public void Read_EntityWithStochasticSoilProfileEntityNotYetInCollector_CalculationWithCreatedStochasticSoilProfileAndRegisteredNewEntities()
        {
            // Setup
            var stochasticSoilProfileEntity = new PipingStochasticSoilProfileEntity
            {
                PipingSoilProfileEntity = new PipingSoilProfileEntity
                {
                    Name = "SoilProfile",
                    PipingSoilLayerEntities =
                    {
                        new PipingSoilLayerEntity()
                    }
                }
            };

            var random   = new Random(21);
            var geometry = new[]
            {
                new Point2D(random.NextDouble(), random.NextDouble())
            };
            var stochasticSoilModelEntity = new StochasticSoilModelEntity
            {
                Name = "StochasticSoilModel",
                StochasticSoilModelSegmentPointXml  = new Point2DCollectionXmlSerializer().ToXml(geometry),
                PipingStochasticSoilProfileEntities =
                {
                    stochasticSoilProfileEntity
                }
            };

            stochasticSoilProfileEntity.StochasticSoilModelEntity = stochasticSoilModelEntity;

            var entity = new ProbabilisticPipingCalculationEntity
            {
                PipingStochasticSoilProfileEntity = stochasticSoilProfileEntity,
                EntryPointL           = 1,
                ExitPointL            = 2,
                DampingFactorExitMean = 1
            };

            var collector = new ReadConversionCollector();

            // Call
            entity.Read(collector);

            // Assert
            Assert.IsTrue(collector.Contains(stochasticSoilProfileEntity));
            Assert.IsTrue(collector.ContainsPipingStochasticSoilModel(stochasticSoilModelEntity));
        }
Exemplo n.º 6
0
        public void Read_NullValues_ReturnHeightStructureWithNaN()
        {
            // Setup
            var entity = new HeightStructureEntity
            {
                Name = "A",
                Id   = "B",
                X    = null,
                Y    = null,
                StructureNormalOrientation                         = null,
                LevelCrestStructureMean                            = null,
                LevelCrestStructureStandardDeviation               = null,
                FlowWidthAtBottomProtectionMean                    = null,
                FlowWidthAtBottomProtectionStandardDeviation       = null,
                CriticalOvertoppingDischargeMean                   = null,
                CriticalOvertoppingDischargeCoefficientOfVariation = null,
                WidthFlowAperturesMean = null,
                WidthFlowAperturesStandardDeviation    = null,
                FailureProbabilityStructureWithErosion = null,
                StorageStructureAreaMean = null,
                StorageStructureAreaCoefficientOfVariation   = null,
                AllowedLevelIncreaseStorageMean              = null,
                AllowedLevelIncreaseStorageStandardDeviation = null
            };

            var collector = new ReadConversionCollector();

            // Call
            HeightStructure structure = entity.Read(collector);

            // Assert
            Assert.IsNaN(structure.Location.X);
            Assert.IsNaN(structure.Location.Y);
            Assert.IsNaN(structure.StructureNormalOrientation);

            Assert.IsNaN(structure.LevelCrestStructure.Mean.Value);
            Assert.IsNaN(structure.LevelCrestStructure.StandardDeviation.Value);
            Assert.IsNaN(structure.FlowWidthAtBottomProtection.Mean.Value);
            Assert.IsNaN(structure.FlowWidthAtBottomProtection.StandardDeviation.Value);
            Assert.IsNaN(structure.CriticalOvertoppingDischarge.Mean.Value);
            Assert.IsNaN(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value);
            Assert.IsNaN(structure.WidthFlowApertures.Mean.Value);
            Assert.IsNaN(structure.WidthFlowApertures.StandardDeviation.Value);
            Assert.IsNaN(structure.FailureProbabilityStructureWithErosion);
            Assert.IsNaN(structure.StorageStructureArea.Mean.Value);
            Assert.IsNaN(structure.StorageStructureArea.CoefficientOfVariation.Value);
            Assert.IsNaN(structure.AllowedLevelIncreaseStorage.Mean.Value);
            Assert.IsNaN(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Read the <see cref="AssessmentSectionEntity"/> and use the information to construct a <see cref="AssessmentSection"/>.
        /// </summary>
        /// <param name="entity">The <see cref="AssessmentSectionEntity"/> to create <see cref="AssessmentSection"/> for.</param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <returns>A new <see cref="AssessmentSection"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="collector"/> is <c>null</c>.</exception>
        internal static AssessmentSection Read(this AssessmentSectionEntity entity, ReadConversionCollector collector)
        {
            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            var assessmentSection = new AssessmentSection((AssessmentSectionComposition)entity.Composition,
                                                          entity.MaximumAllowableFloodingProbability,
                                                          entity.SignalFloodingProbability)
            {
                Id       = entity.Id,
                Name     = entity.Name,
                Comments =
                {
                    Body = entity.Comments
                },
                FailureMechanismContribution =
                {
                    NormativeProbabilityType = (NormativeProbabilityType)entity.NormativeProbabilityType
                }
            };

            entity.ReadBackgroundData(assessmentSection);

            entity.ReadHydraulicDatabase(assessmentSection, collector);
            entity.ReadHydraulicLocationCalculationsForTargetProbabilities(assessmentSection, collector);
            entity.ReadReferenceLine(assessmentSection);

            entity.ReadPipingFailureMechanism(assessmentSection, collector);
            entity.ReadGrassCoverErosionInwardsFailureMechanism(assessmentSection, collector);
            entity.ReadHeightStructuresFailureMechanism(assessmentSection, collector);
            entity.ReadWaterPressureAsphaltCoverFailureMechanism(assessmentSection, collector);
            entity.ReadClosingStructuresFailureMechanism(assessmentSection, collector);
            entity.ReadMacroStabilityInwardsFailureMechanism(assessmentSection, collector);
            entity.ReadWaveImpactAsphaltCoverFailureMechanism(assessmentSection, collector);
            entity.ReadGrassCoverErosionOutwardsFailureMechanism(assessmentSection, collector);
            entity.ReadGrassCoverSlipOffInwardsFailureMechanism(assessmentSection, collector);
            entity.ReadGrassCoverSlipOffOutwardsFailureMechanism(assessmentSection, collector);
            entity.ReadMicrostabilityFailureMechanism(assessmentSection, collector);
            entity.ReadPipingStructureFailureMechanism(assessmentSection, collector);
            entity.ReadDuneErosionFailureMechanism(assessmentSection, collector);
            entity.ReadStabilityStoneCoverFailureMechanism(assessmentSection, collector);
            entity.ReadStabilityPointStructuresFailureMechanism(assessmentSection, collector);

            entity.ReadSpecificFailureMechanisms(assessmentSection, collector);

            return(assessmentSection);
        }
Exemplo n.º 8
0
        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_EntityWithNoAssessmentSections_ThrowsEntityReadException()
        {
            // Setup
            var entity    = new ProjectEntity();
            var collector = new ReadConversionCollector();

            // Call
            void Call() => entity.Read(collector);

            // Assert
            var          exception = Assert.Throws <EntityReadException>(Call);
            const string message   = "Het project bevat geen traject. Dit bestand is mogelijk een gemigreerd project met geen trajecten.";

            Assert.AreEqual(message, exception.Message);
        }
Exemplo n.º 11
0
            public void Get_DataModelAdded_ReturnsEntity()
            {
                // Setup
                var        collector = new ReadConversionCollector();
                TDataModel dataModel = CreateDataModel();
                var        entity    = new TEntity();

                registerToCollector(collector, entity, dataModel);

                // Call
                TDataModel result = getFromCollector(collector, entity);

                // Assert
                Assert.AreSame(dataModel, result);
            }
Exemplo n.º 12
0
        public void ReadAsPipingSurfaceLine_SurfaceLineEntityWithPointsAndAllCharacteristicPointsSetToSamePoint_ReturnsExpectedSurfaceLine()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var random    = new Random(31);

            Point3D[] points =
            {
                CreatePoint3D(random),
                CreatePoint3D(random)
            };

            var entity = new SurfaceLineEntity
            {
                Name = "Better name.",
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points),
                PipingCharacteristicPointEntities =
                {
                    CreatePipingCharacteristicPointEntity(points[0], PipingCharacteristicPointType.BottomDitchDikeSide),
                    CreatePipingCharacteristicPointEntity(points[0], PipingCharacteristicPointType.BottomDitchPolderSide),
                    CreatePipingCharacteristicPointEntity(points[0], PipingCharacteristicPointType.DikeToeAtPolder),
                    CreatePipingCharacteristicPointEntity(points[0], PipingCharacteristicPointType.DikeToeAtRiver),
                    CreatePipingCharacteristicPointEntity(points[0], PipingCharacteristicPointType.DitchDikeSide),
                    CreatePipingCharacteristicPointEntity(points[0], PipingCharacteristicPointType.DitchPolderSide)
                }
            };

            // Call
            PipingSurfaceLine surfaceLine = entity.ReadAsPipingSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.AreEqual(entity.ReferenceLineIntersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.AreEqual(entity.ReferenceLineIntersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            Point3D[] geometry = surfaceLine.Points.ToArray();
            Assert.AreEqual(2, geometry.Length);
            Point3D geometryPoint = geometry[0];

            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.BottomDitchPolderSide);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtPolder);
            Assert.AreSame(geometryPoint, surfaceLine.DikeToeAtRiver);
            Assert.AreSame(geometryPoint, surfaceLine.DitchDikeSide);
            Assert.AreSame(geometryPoint, surfaceLine.DitchPolderSide);
        }
        private static void ReadInputParameters(HeightStructuresInput inputParameters,
                                                HeightStructuresCalculationEntity entity,
                                                ReadConversionCollector collector)
        {
            if (entity.HeightStructureEntity != null)
            {
                inputParameters.Structure = entity.HeightStructureEntity.Read(collector);
            }

            entity.Read(inputParameters, collector);

            inputParameters.DeviationWaveDirection                = (RoundedDouble)entity.DeviationWaveDirection.ToNullAsNaN();
            inputParameters.ModelFactorSuperCriticalFlow.Mean     = (RoundedDouble)entity.ModelFactorSuperCriticalFlowMean.ToNullAsNaN();
            inputParameters.LevelCrestStructure.Mean              = (RoundedDouble)entity.LevelCrestStructureMean.ToNullAsNaN();
            inputParameters.LevelCrestStructure.StandardDeviation = (RoundedDouble)entity.LevelCrestStructureStandardDeviation.ToNullAsNaN();
        }
Exemplo n.º 14
0
        public void Read_EntityWithNullValues_ReturnSpecificFailureMechanism()
        {
            // Setup
            var entity = new SpecificFailureMechanismEntity
            {
                N = 1.1
            };
            var collector = new ReadConversionCollector();

            // Call
            SpecificFailureMechanism specificFailureMechanism = entity.Read(collector);

            // Assert
            FailureMechanismAssemblyResult assemblyResult = specificFailureMechanism.AssemblyResult;

            Assert.IsNaN(assemblyResult.ManualFailureMechanismAssemblyProbability);
        }
        public void Read_EntityWithHydraulicBoundaryLocationNotYetInCollector_CalculationWithCreatedHydraulicBoundaryLocationAndRegisteredNewEntities()
        {
            // Setup
            HydraulicLocationEntity hydraulicLocationEntity = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity();
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                HydraulicLocationEntity = hydraulicLocationEntity
            };

            var collector = new ReadConversionCollector();

            // Call
            entity.Read(collector);

            // Assert
            Assert.IsTrue(collector.Contains(hydraulicLocationEntity));
        }
Exemplo n.º 16
0
        public void Read_SameHydraulicLocationEntityTwice_ReturnSameHydraulicBoundaryLocation()
        {
            // Setup
            var entity = new HydraulicLocationEntity
            {
                Name = "A"
            };

            var collector = new ReadConversionCollector();

            // Call
            HydraulicBoundaryLocation location1 = entity.Read(collector);
            HydraulicBoundaryLocation location2 = entity.Read(collector);

            // Assert
            Assert.AreSame(location1, location2);
        }
        public void Read_WithGeometryAndBreakWaterTypeAndValues_CompleteForeshoreProfile()
        {
            // Setup
            const string         name           = "testName";
            const string         id             = "testId";
            var                  random         = new Random(21);
            int                  order          = random.Next();
            double               orientation    = random.NextDouble();
            double               x0             = random.NextDouble();
            double               height         = random.NextDouble();
            const BreakWaterType breakWaterType = BreakWaterType.Wall;

            var points = new[]
            {
                new Point2D(0, 0)
            };
            string pointXml = new Point2DCollectionXmlSerializer().ToXml(points);
            var    entity   = new ForeshoreProfileEntity
            {
                Order            = order,
                Id               = id,
                Name             = name,
                Orientation      = orientation,
                X0               = x0,
                BreakWaterType   = Convert.ToByte(breakWaterType),
                BreakWaterHeight = height,
                GeometryXml      = pointXml
            };

            var readConversionCollector = new ReadConversionCollector();

            // Call
            ForeshoreProfile foreshoreProfile = entity.Read(readConversionCollector);

            // Assert
            Assert.IsNotNull(foreshoreProfile);
            Assert.AreEqual(name, foreshoreProfile.Name);
            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(id, foreshoreProfile.Id);
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(orientation, foreshoreProfile.Orientation, foreshoreProfile.Orientation.GetAccuracy());
            Assert.AreEqual(x0, entity.X0);
            Assert.AreEqual(breakWaterType, foreshoreProfile.BreakWater.Type);
            Assert.IsTrue(foreshoreProfile.HasBreakWater);
            CollectionAssert.AreEqual(points, foreshoreProfile.Geometry);
        }
Exemplo n.º 18
0
        public void Read_DikeProfileEntityWithBreakWater_ReturnDikeProfileWithBreakWater(BreakWaterType type, double height)
        {
            // Setup
            var foreshorePoints = new Point2D[0];
            var roughnessPoints = new[]
            {
                new RoughnessPoint(new Point2D(1.1, 2.2), 1.0),
                new RoughnessPoint(new Point2D(3.3, 4.4), 0.6),
                new RoughnessPoint(new Point2D(5.5, 6.6), 1.0),
                new RoughnessPoint(new Point2D(7.7, 8.8), 0.5)
            };
            var entity = new DikeProfileEntity
            {
                Id               = "with_breakwater",
                Name             = "I have a Breakwater!",
                Orientation      = 360.0,
                BreakWaterHeight = height,
                BreakWaterType   = Convert.ToByte(type),
                ForeshoreXml     = new Point2DCollectionXmlSerializer().ToXml(foreshorePoints),
                DikeGeometryXml  = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints),
                DikeHeight       = 4.5,
                X  = 93.0,
                Y  = 945.6,
                X0 = 9.34
            };

            var collector = new ReadConversionCollector();

            // Call
            DikeProfile dikeProfile = entity.Read(collector);

            // Assert
            Assert.AreEqual(entity.Id, dikeProfile.Id);
            Assert.AreEqual(entity.Name, dikeProfile.Name);
            Assert.AreEqual(entity.Orientation, dikeProfile.Orientation.Value);
            CollectionAssert.AreEqual(foreshorePoints, dikeProfile.ForeshoreGeometry);
            CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry, new RoughnessPointComparer());
            Assert.AreEqual(entity.X, dikeProfile.WorldReferencePoint.X);
            Assert.AreEqual(entity.Y, dikeProfile.WorldReferencePoint.Y);
            Assert.AreEqual(entity.X0, dikeProfile.X0);

            Assert.AreEqual(height, dikeProfile.BreakWater.Height.Value);
            Assert.AreEqual(type, dikeProfile.BreakWater.Type);

            Assert.IsTrue(collector.Contains(entity));
        }
Exemplo n.º 19
0
        public void Read_ValidEntityWithoutSections_ReturnSpecificFailureMechanism()
        {
            // Setup
            var entity = new SpecificFailureMechanismEntity
            {
                N = 1.1
            };

            var collector = new ReadConversionCollector();

            // Call
            SpecificFailureMechanism specificFailureMechanism = entity.Read(collector);

            // Assert
            Assert.AreEqual(entity.FailureMechanismSectionEntities.Count, specificFailureMechanism.Sections.Count());
            Assert.IsNull(specificFailureMechanism.FailureMechanismSectionSourcePath);
        }
        public void Read_SameDuneLocationEntityTwice_ReturnSameDuneLocation()
        {
            // Setup
            var entity = new DuneLocationEntity
            {
                Name = "A"
            };

            var collector = new ReadConversionCollector();

            // Call
            DuneLocation location1 = entity.Read(collector);
            DuneLocation location2 = entity.Read(collector);

            // Assert
            Assert.AreSame(location1, location2);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Reads all the information from the entity and updated the given input object,
        /// with the exception of the <see cref="StructuresInputBase{T}.Structure"/> property.
        /// </summary>
        /// <typeparam name="T">The type of structure residing in <paramref name="inputToUpdate"/>.</typeparam>
        /// <param name="entity">The entity.</param>
        /// <param name="inputToUpdate">The input object to update.</param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="inputToUpdate"/>
        /// or <paramref name="collector"/> is <c>null</c>.</exception>
        internal static void Read <T>(this IStructuresCalculationEntity entity,
                                      StructuresInputBase <T> inputToUpdate,
                                      ReadConversionCollector collector) where T : StructureBase
        {
            if (inputToUpdate == null)
            {
                throw new ArgumentNullException(nameof(inputToUpdate));
            }

            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            if (entity.ForeshoreProfileEntity != null)
            {
                inputToUpdate.ForeshoreProfile = entity.ForeshoreProfileEntity.Read(collector);
            }

            if (entity.HydraulicLocationEntity != null)
            {
                inputToUpdate.HydraulicBoundaryLocation = entity.HydraulicLocationEntity.Read(collector);
            }

            inputToUpdate.StructureNormalOrientation       = (RoundedDouble)entity.StructureNormalOrientation.ToNullAsNaN();
            inputToUpdate.AllowedLevelIncreaseStorage.Mean = (RoundedDouble)entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN();
            inputToUpdate.AllowedLevelIncreaseStorage.StandardDeviation = (RoundedDouble)entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN();
            inputToUpdate.StorageStructureArea.Mean = (RoundedDouble)entity.StorageStructureAreaMean.ToNullAsNaN();
            inputToUpdate.StorageStructureArea.CoefficientOfVariation         = (RoundedDouble)entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN();
            inputToUpdate.FlowWidthAtBottomProtection.Mean                    = (RoundedDouble)entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN();
            inputToUpdate.FlowWidthAtBottomProtection.StandardDeviation       = (RoundedDouble)entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN();
            inputToUpdate.CriticalOvertoppingDischarge.Mean                   = (RoundedDouble)entity.CriticalOvertoppingDischargeMean.ToNullAsNaN();
            inputToUpdate.CriticalOvertoppingDischarge.CoefficientOfVariation = (RoundedDouble)entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN();
            inputToUpdate.FailureProbabilityStructureWithErosion              = entity.FailureProbabilityStructureWithErosion;
            inputToUpdate.WidthFlowApertures.Mean = (RoundedDouble)entity.WidthFlowAperturesMean.ToNullAsNaN();
            inputToUpdate.WidthFlowApertures.StandardDeviation = (RoundedDouble)entity.WidthFlowAperturesStandardDeviation.ToNullAsNaN();
            inputToUpdate.StormDuration.Mean = (RoundedDouble)entity.StormDurationMean.ToNullAsNaN();

            inputToUpdate.UseBreakWater     = Convert.ToBoolean(entity.UseBreakWater);
            inputToUpdate.BreakWater.Type   = (BreakWaterType)entity.BreakWaterType;
            inputToUpdate.BreakWater.Height = (RoundedDouble)entity.BreakWaterHeight.ToNullAsNaN();
            inputToUpdate.UseForeshore      = Convert.ToBoolean(entity.UseForeshore);

            inputToUpdate.ShouldIllustrationPointsBeCalculated = Convert.ToBoolean(entity.ShouldIllustrationPointsBeCalculated);
        }
Exemplo n.º 22
0
        public void Read_DikeProfileEntityWithBreakWaterPropertiesNull_ReturnDikeProfileWithoutBreakWater()
        {
            // Setup
            var foreshorePoints = new[]
            {
                new Point2D(-9.9, 8.8),
                new Point2D(-7.7, 5.5)
            };
            var roughnessPoints = new[]
            {
                new RoughnessPoint(new Point2D(-7.7, 5.5), 1.0),
                new RoughnessPoint(new Point2D(5.5, 6.6), 0.5)
            };
            var entity = new DikeProfileEntity
            {
                Id               = "saved",
                Name             = "Just saved",
                Orientation      = 45.67,
                BreakWaterHeight = null,
                BreakWaterType   = null,
                ForeshoreXml     = new Point2DCollectionXmlSerializer().ToXml(foreshorePoints),
                DikeGeometryXml  = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints),
                DikeHeight       = 1.2,
                X  = 3.4,
                Y  = 5.6,
                X0 = -7.8
            };

            var collector = new ReadConversionCollector();

            // Call
            DikeProfile dikeProfile = entity.Read(collector);

            // Assert
            Assert.AreEqual(entity.Id, dikeProfile.Id);
            Assert.AreEqual(entity.Name, dikeProfile.Name);
            Assert.AreEqual(entity.Orientation, dikeProfile.Orientation.Value);
            CollectionAssert.AreEqual(foreshorePoints, dikeProfile.ForeshoreGeometry);
            CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry, new RoughnessPointComparer());
            Assert.AreEqual(entity.X, dikeProfile.WorldReferencePoint.X);
            Assert.AreEqual(entity.Y, dikeProfile.WorldReferencePoint.Y);
            Assert.AreEqual(entity.X0, dikeProfile.X0);

            Assert.IsFalse(dikeProfile.HasBreakWater);
        }
Exemplo n.º 23
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityReadMultipleTimes_ReturnSameSurfaceLine()
        {
            // Setup
            var collector = new ReadConversionCollector();

            var entity = new SurfaceLineEntity
            {
                Name      = "surface line",
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(new Point3D[0])
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine1 = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);
            MacroStabilityInwardsSurfaceLine surfaceLine2 = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreSame(surfaceLine1, surfaceLine2);
        }
Exemplo n.º 24
0
        public void Read_SameHydraulicLocationCalculationForTargetProbabilityCollectionEntityTwice_ReturnsSameHydraulicBoundaryLocationCalculationsForTargetProbability()
        {
            // Setup
            var random           = new Random(21);
            var collectionEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity
            {
                TargetProbability = random.NextDouble(0, 0.1)
            };

            var collector = new ReadConversionCollector();

            // Call
            HydraulicBoundaryLocationCalculationsForTargetProbability calculationsOne = collectionEntity.Read(collector);
            HydraulicBoundaryLocationCalculationsForTargetProbability calculationsTwo = collectionEntity.Read(collector);

            // Assert
            Assert.AreSame(calculationsOne, calculationsTwo);
        }
        public void Read_EntityWithHydraulicBoundaryLocationCalculationsForTargetProbabilityNotYetInCollector_CalculationWithCreatedHydraulicBoundaryLocationCalculationsForTargetProbabilityAndRegisteredNewEntities()
        {
            // Setup
            HydraulicLocationCalculationForTargetProbabilityCollectionEntity calculationForTargetProbabilityCollectionEntity =
                HydraulicLocationCalculationForTargetProbabilityCollectionEntityTestFactory.CreateHydraulicLocationCalculationForTargetProbabilityCollectionEntity();
            var entity = new StabilityStoneCoverWaveConditionsCalculationEntity
            {
                HydraulicLocationCalculationForTargetProbabilityCollectionEntity = calculationForTargetProbabilityCollectionEntity
            };

            var collector = new ReadConversionCollector();

            // Call
            entity.Read(collector);

            // Assert
            Assert.IsTrue(collector.Contains(calculationForTargetProbabilityCollectionEntity));
        }
        public void Read_EntityWithForeshoreProfile_ReturnCalculation(bool flagUsage, BreakWaterType type, int randomSeed)
        {
            // Setup
            var random = new Random(randomSeed);

            double breakWaterHeight = random.NextDouble();
            var    points           = new[]
            {
                new Point2D(0, 0)
            };
            string pointXml        = new Point2DCollectionXmlSerializer().ToXml(points);
            var    foreshoreEntity = new ForeshoreProfileEntity
            {
                Id = "id",
                BreakWaterHeight = breakWaterHeight,
                BreakWaterType   = Convert.ToByte(type),
                GeometryXml      = pointXml
            };

            var entity = new HeightStructuresCalculationEntity
            {
                UseForeshore           = Convert.ToByte(flagUsage),
                UseBreakWater          = Convert.ToByte(!flagUsage),
                ForeshoreProfileEntity = foreshoreEntity,
                BreakWaterType         = Convert.ToByte(type),
                BreakWaterHeight       = breakWaterHeight,
                ScenarioContribution   = 0
            };

            var collector = new ReadConversionCollector();

            // Call
            StructuresCalculationScenario <HeightStructuresInput> calculation = entity.Read(collector);

            // Assert
            HeightStructuresInput input = calculation.InputParameters;

            Assert.AreEqual(flagUsage, input.UseForeshore);
            Assert.AreEqual(!flagUsage, input.UseBreakWater);
            Assert.AreEqual(type, input.BreakWater.Type);
            Assert.AreEqual(breakWaterHeight, input.BreakWater.Height, input.BreakWater.Height.GetAccuracy());
            CollectionAssert.AreEqual(points, input.ForeshoreProfile.Geometry);
            Assert.IsNotNull(input.ForeshoreProfile);
        }
        public void Read_EntityWithNullParameters_ReturnHeightStructuresCalculationWithInputParametersNaN()
        {
            // Setup
            var entity = new HeightStructuresCalculationEntity
            {
                ScenarioContribution                               = 0,
                StructureNormalOrientation                         = null,
                ModelFactorSuperCriticalFlowMean                   = null,
                AllowedLevelIncreaseStorageMean                    = null,
                AllowedLevelIncreaseStorageStandardDeviation       = null,
                FlowWidthAtBottomProtectionMean                    = null,
                FlowWidthAtBottomProtectionStandardDeviation       = null,
                CriticalOvertoppingDischargeMean                   = null,
                CriticalOvertoppingDischargeCoefficientOfVariation = null,
                WidthFlowAperturesMean                             = null,
                WidthFlowAperturesStandardDeviation                = null,
                StormDurationMean       = null,
                LevelCrestStructureMean = null,
                LevelCrestStructureStandardDeviation = null,
                DeviationWaveDirection = null
            };
            var collector = new ReadConversionCollector();

            // Call
            StructuresCalculationScenario <HeightStructuresInput> calculation = entity.Read(collector);

            // Assert
            HeightStructuresInput inputParameters = calculation.InputParameters;

            Assert.IsNaN(inputParameters.StructureNormalOrientation);
            Assert.IsNaN(inputParameters.ModelFactorSuperCriticalFlow.Mean);
            Assert.IsNaN(inputParameters.AllowedLevelIncreaseStorage.Mean);
            Assert.IsNaN(inputParameters.AllowedLevelIncreaseStorage.StandardDeviation);
            Assert.IsNaN(inputParameters.FlowWidthAtBottomProtection.Mean);
            Assert.IsNaN(inputParameters.FlowWidthAtBottomProtection.StandardDeviation);
            Assert.IsNaN(inputParameters.CriticalOvertoppingDischarge.Mean);
            Assert.IsNaN(inputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation);
            Assert.IsNaN(inputParameters.WidthFlowApertures.Mean);
            Assert.IsNaN(inputParameters.WidthFlowApertures.StandardDeviation);
            Assert.IsNaN(inputParameters.StormDuration.Mean);
            Assert.IsNaN(inputParameters.LevelCrestStructure.Mean);
            Assert.IsNaN(inputParameters.LevelCrestStructure.StandardDeviation);
            Assert.IsNaN(inputParameters.DeviationWaveDirection);
        }
Exemplo n.º 28
0
        public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityWithGeometryPointXmlButNoCharacteristicPoints_ReturnSurfaceLineWithGeometry()
        {
            // Setup
            var collector = new ReadConversionCollector();
            var random    = new Random(31);

            Point3D[] points =
            {
                CreatePoint3D(random),
                CreatePoint3D(random),
                CreatePoint3D(random)
            };

            var entity = new SurfaceLineEntity
            {
                Name = nameof(SurfaceLineEntity),
                ReferenceLineIntersectionX = random.NextDouble(),
                ReferenceLineIntersectionY = random.NextDouble(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(points)
            };

            // Call
            MacroStabilityInwardsSurfaceLine surfaceLine = entity.ReadAsMacroStabilityInwardsSurfaceLine(collector);

            // Assert
            Assert.AreEqual(entity.Name, surfaceLine.Name);
            Assert.AreEqual(entity.ReferenceLineIntersectionX, surfaceLine.ReferenceLineIntersectionWorldPoint.X);
            Assert.AreEqual(entity.ReferenceLineIntersectionY, surfaceLine.ReferenceLineIntersectionWorldPoint.Y);

            CollectionAssert.AreEqual(points, surfaceLine.Points);

            Assert.IsNull(surfaceLine.SurfaceLevelOutside);
            Assert.IsNull(surfaceLine.DikeToeAtRiver);
            Assert.IsNull(surfaceLine.DikeTopAtPolder);
            Assert.IsNull(surfaceLine.DikeTopAtRiver);
            Assert.IsNull(surfaceLine.ShoulderBaseInside);
            Assert.IsNull(surfaceLine.ShoulderTopInside);
            Assert.IsNull(surfaceLine.DikeToeAtPolder);
            Assert.IsNull(surfaceLine.DitchDikeSide);
            Assert.IsNull(surfaceLine.BottomDitchDikeSide);
            Assert.IsNull(surfaceLine.BottomDitchPolderSide);
            Assert.IsNull(surfaceLine.DitchPolderSide);
            Assert.IsNull(surfaceLine.SurfaceLevelInside);
        }
Exemplo n.º 29
0
        private static void ReadHydraulicLocationCalculationsForTargetProbabilities(this AssessmentSectionEntity entity,
                                                                                    IAssessmentSection assessmentSection,
                                                                                    ReadConversionCollector collector)
        {
            IEnumerable <HydraulicLocationCalculationForTargetProbabilityCollectionEntity> waterLevelHydraulicLocationCalculationForTargetProbabilityCollectionEntities =
                entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntities
                .Where(e => e.HydraulicBoundaryLocationCalculationType == (short)HydraulicBoundaryLocationCalculationType.WaterLevel)
                .OrderBy(e => e.Order);

            assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.AddRange(waterLevelHydraulicLocationCalculationForTargetProbabilityCollectionEntities.Select(e => e.Read(collector))
                                                                                               .ToArray());
            IEnumerable <HydraulicLocationCalculationForTargetProbabilityCollectionEntity> waveHeightHydraulicLocationCalculationForTargetProbabilityCollectionEntities =
                entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntities
                .Where(e => e.HydraulicBoundaryLocationCalculationType == (short)HydraulicBoundaryLocationCalculationType.WaveHeight)
                .OrderBy(e => e.Order);

            assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities.AddRange(waveHeightHydraulicLocationCalculationForTargetProbabilityCollectionEntities.Select(e => e.Read(collector))
                                                                                               .ToArray());
        }
Exemplo n.º 30
0
        public void Read_ValidEntity_ReturnSpecificFailureMechanism()
        {
            // Setup
            var  random                = new Random(21);
            bool inAssembly            = random.NextBoolean();
            var  probabilityResultType = random.NextEnumValue <FailureMechanismAssemblyProbabilityResultType>();

            const string filePath = "failureMechanismSections/File/Path";
            var          entity   = new SpecificFailureMechanismEntity
            {
                Name = "Specific failure mechanism name",
                Code = "FAALMECHANISME",
                N    = random.NextDouble(1.0, 20.0),
                ApplyLengthEffectInSection = Convert.ToByte(random.NextBoolean()),
                InAssembly = Convert.ToByte(inAssembly),
                InAssemblyInputComments  = "Some input text",
                InAssemblyOutputComments = "Some output text",
                NotInAssemblyComments    = "Some not in assembly text",
                FailureMechanismSectionCollectionSourcePath         = filePath,
                FailureMechanismAssemblyResultProbabilityResultType = Convert.ToByte(probabilityResultType),
                FailureMechanismAssemblyResultManualFailureMechanismAssemblyProbability = random.NextDouble(),
                FailureMechanismSectionEntities =
                {
                    CreateSimpleFailureMechanismSectionEntity()
                }
            };

            var collector = new ReadConversionCollector();

            // Call
            SpecificFailureMechanism specificFailureMechanism = entity.Read(collector);

            // Assert
            FailureMechanismEntityTestHelper.AssertIFailureMechanismEntityProperties(entity, specificFailureMechanism);

            Assert.AreEqual(entity.Name, specificFailureMechanism.Name);
            Assert.AreEqual(entity.Code, specificFailureMechanism.Code);
            Assert.AreEqual(entity.FailureMechanismSectionEntities.Count, specificFailureMechanism.Sections.Count());
            Assert.AreEqual(filePath, specificFailureMechanism.FailureMechanismSectionSourcePath);

            Assert.AreEqual(entity.N, specificFailureMechanism.GeneralInput.N, specificFailureMechanism.GeneralInput.N.GetAccuracy());
            Assert.AreEqual(Convert.ToBoolean(entity.ApplyLengthEffectInSection), specificFailureMechanism.GeneralInput.ApplyLengthEffectInSection);
        }