Esempio n. 1
0
        /// <summary>
        /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="DuneErosionFailureMechanism"/>.
        /// </summary>
        /// <param name="mechanism">The failure mechanism to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static FailureMechanismEntity Create(this DuneErosionFailureMechanism mechanism, PersistenceRegistry registry)
        {
            FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.DuneErosion, registry);

            entity.CalculationsInputComments = mechanism.CalculationsInputComments.Body.DeepClone();

            AddEntitiesForSectionResults(mechanism.SectionResults, registry);
            AddEntitiesForDuneLocations(mechanism.DuneLocations, entity, registry);
            AddEntitiesForFailureMechanismMeta(mechanism, entity, registry);
            return(entity);
        }
Esempio n. 2
0
        private static void SetInputValues(GrassCoverErosionInwardsCalculationEntity entity, GrassCoverErosionInwardsInput input, PersistenceRegistry registry)
        {
            if (input.DikeProfile != null)
            {
                entity.DikeProfileEntity = registry.Get(input.DikeProfile);
            }

            if (input.HydraulicBoundaryLocation != null)
            {
                entity.HydraulicLocationEntity = registry.Get(input.HydraulicBoundaryLocation);
            }

            entity.Orientation          = input.Orientation.ToNaNAsNull();
            entity.DikeHeight           = input.DikeHeight.ToNaNAsNull();
            entity.UseForeshore         = Convert.ToByte(input.UseForeshore);
            entity.UseBreakWater        = Convert.ToByte(input.UseBreakWater);
            entity.BreakWaterType       = Convert.ToByte(input.BreakWater.Type);
            entity.BreakWaterHeight     = input.BreakWater.Height.ToNaNAsNull();
            entity.CriticalFlowRateMean = input.CriticalFlowRate.Mean.ToNaNAsNull();
            entity.CriticalFlowRateStandardDeviation = input.CriticalFlowRate.StandardDeviation.ToNaNAsNull();
            entity.ShouldOvertoppingOutputIllustrationPointsBeCalculated = Convert.ToByte(input.ShouldOvertoppingOutputIllustrationPointsBeCalculated);
            entity.ShouldDikeHeightBeCalculated = Convert.ToByte(input.ShouldDikeHeightBeCalculated);
            entity.DikeHeightTargetProbability  = input.DikeHeightTargetProbability;
            entity.ShouldDikeHeightIllustrationPointsBeCalculated = Convert.ToByte(input.ShouldDikeHeightIllustrationPointsBeCalculated);
            entity.ShouldOvertoppingRateBeCalculated = Convert.ToByte(input.ShouldOvertoppingRateBeCalculated);
            entity.OvertoppingRateTargetProbability  = input.OvertoppingRateTargetProbability;
            entity.ShouldOvertoppingRateIllustrationPointsBeCalculated = Convert.ToByte(input.ShouldOvertoppingRateIllustrationPointsBeCalculated);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a <see cref="StabilityPointStructureEntity"/> based on the information
        /// of the <see cref="StabilityPointStructure"/>.
        /// </summary>
        /// <param name="structure">The structure 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="structure"/> resides within its parent.</param>
        /// <returns>A new <see cref="StabilityPointStructureEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static StabilityPointStructureEntity Create(this StabilityPointStructure structure, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(structure))
            {
                return(registry.Get(structure));
            }

            var entity = new StabilityPointStructureEntity
            {
                Name = structure.Name.DeepClone(),
                Id   = structure.Id.DeepClone(),
                X    = structure.Location.X.ToNaNAsNull(),
                Y    = structure.Location.Y.ToNaNAsNull(),
                StructureNormalOrientation = structure.StructureNormalOrientation.ToNaNAsNull(),
                StorageStructureAreaMean   = structure.StorageStructureArea.Mean.ToNaNAsNull(),
                StorageStructureAreaCoefficientOfVariation   = structure.StorageStructureArea.CoefficientOfVariation.ToNaNAsNull(),
                AllowedLevelIncreaseStorageMean              = structure.AllowedLevelIncreaseStorage.Mean.ToNaNAsNull(),
                AllowedLevelIncreaseStorageStandardDeviation = structure.AllowedLevelIncreaseStorage.StandardDeviation.ToNaNAsNull(),
                WidthFlowAperturesMean = structure.WidthFlowApertures.Mean.ToNaNAsNull(),
                WidthFlowAperturesStandardDeviation = structure.WidthFlowApertures.StandardDeviation.ToNaNAsNull(),
                InsideWaterLevelMean = structure.InsideWaterLevel.Mean.ToNaNAsNull(),
                InsideWaterLevelStandardDeviation                            = structure.InsideWaterLevel.StandardDeviation.ToNaNAsNull(),
                ThresholdHeightOpenWeirMean                                  = structure.ThresholdHeightOpenWeir.Mean.ToNaNAsNull(),
                ThresholdHeightOpenWeirStandardDeviation                     = structure.ThresholdHeightOpenWeir.StandardDeviation.ToNaNAsNull(),
                CriticalOvertoppingDischargeMean                             = structure.CriticalOvertoppingDischarge.Mean.ToNaNAsNull(),
                CriticalOvertoppingDischargeCoefficientOfVariation           = structure.CriticalOvertoppingDischarge.CoefficientOfVariation.ToNaNAsNull(),
                FlowWidthAtBottomProtectionMean                              = structure.FlowWidthAtBottomProtection.Mean.ToNaNAsNull(),
                FlowWidthAtBottomProtectionStandardDeviation                 = structure.FlowWidthAtBottomProtection.StandardDeviation.ToNaNAsNull(),
                ConstructiveStrengthLinearLoadModelMean                      = structure.ConstructiveStrengthLinearLoadModel.Mean.ToNaNAsNull(),
                ConstructiveStrengthLinearLoadModelCoefficientOfVariation    = structure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation.ToNaNAsNull(),
                ConstructiveStrengthQuadraticLoadModelMean                   = structure.ConstructiveStrengthQuadraticLoadModel.Mean.ToNaNAsNull(),
                ConstructiveStrengthQuadraticLoadModelCoefficientOfVariation = structure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation.ToNaNAsNull(),
                BankWidthMean = structure.BankWidth.Mean.ToNaNAsNull(),
                BankWidthStandardDeviation = structure.BankWidth.StandardDeviation.ToNaNAsNull(),
                InsideWaterLevelFailureConstructionMean = structure.InsideWaterLevelFailureConstruction.Mean.ToNaNAsNull(),
                InsideWaterLevelFailureConstructionStandardDeviation = structure.InsideWaterLevelFailureConstruction.StandardDeviation.ToNaNAsNull(),
                EvaluationLevel         = structure.EvaluationLevel.ToNaNAsNull(),
                LevelCrestStructureMean = structure.LevelCrestStructure.Mean.ToNaNAsNull(),
                LevelCrestStructureStandardDeviation = structure.LevelCrestStructure.StandardDeviation.ToNaNAsNull(),
                VerticalDistance = structure.VerticalDistance.ToNaNAsNull(),
                FailureProbabilityRepairClosure = structure.FailureProbabilityRepairClosure.ToNaNAsNull(),
                FailureCollisionEnergyMean      = structure.FailureCollisionEnergy.Mean.ToNaNAsNull(),
                FailureCollisionEnergyCoefficientOfVariation = structure.FailureCollisionEnergy.CoefficientOfVariation.ToNaNAsNull(),
                ShipMassMean = structure.ShipMass.Mean.ToNaNAsNull(),
                ShipMassCoefficientOfVariation = structure.ShipMass.CoefficientOfVariation.ToNaNAsNull(),
                ShipVelocityMean = structure.ShipVelocity.Mean.ToNaNAsNull(),
                ShipVelocityCoefficientOfVariation = structure.ShipVelocity.CoefficientOfVariation.ToNaNAsNull(),
                LevellingCount = structure.LevellingCount,
                ProbabilityCollisionSecondaryStructure            = structure.ProbabilityCollisionSecondaryStructure.ToNaNAsNull(),
                FlowVelocityStructureClosableMean                 = structure.FlowVelocityStructureClosable.Mean.ToNaNAsNull(),
                StabilityLinearLoadModelMean                      = structure.StabilityLinearLoadModel.Mean.ToNaNAsNull(),
                StabilityLinearLoadModelCoefficientOfVariation    = structure.StabilityLinearLoadModel.CoefficientOfVariation.ToNaNAsNull(),
                StabilityQuadraticLoadModelMean                   = structure.StabilityQuadraticLoadModel.Mean.ToNaNAsNull(),
                StabilityQuadraticLoadModelCoefficientOfVariation = structure.StabilityQuadraticLoadModel.CoefficientOfVariation.ToNaNAsNull(),
                AreaFlowAperturesMean = structure.AreaFlowApertures.Mean.ToNaNAsNull(),
                AreaFlowAperturesStandardDeviation = structure.AreaFlowApertures.StandardDeviation.ToNaNAsNull(),
                InflowModelType = Convert.ToByte(structure.InflowModelType),
                Order           = order
            };

            registry.Register(entity, structure);

            return(entity);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="GrassCoverErosionOutwardsFailureMechanism"/>.
        /// </summary>
        /// <param name="mechanism">The failure mechanism to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static FailureMechanismEntity Create(this GrassCoverErosionOutwardsFailureMechanism mechanism, PersistenceRegistry registry)
        {
            FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.GrassRevetmentErosionOutwards, registry);

            AddEntitiesForSectionResults(mechanism.SectionResults, registry);
            AddEntitiesForFailureMechanismMeta(mechanism, entity);
            AddEntitiesForForeshoreProfiles(mechanism.ForeshoreProfiles, entity, registry);
            entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0);

            return(entity);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a <see cref="GrassCoverErosionInwardsCalculationEntity"/> based
        /// on the information of the <see cref="GrassCoverErosionInwardsCalculationScenario"/>.
        /// </summary>
        /// <param name="calculation">The calculation scenario to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">The index at where <paramref name="calculation"/> resides
        /// in its parent container.</param>
        /// <returns>A new <see cref="GrassCoverErosionInwardsCalculationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static GrassCoverErosionInwardsCalculationEntity Create(this GrassCoverErosionInwardsCalculationScenario calculation, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = new GrassCoverErosionInwardsCalculationEntity
            {
                Name                 = calculation.Name.DeepClone(),
                Comments             = calculation.Comments.Body.DeepClone(),
                RelevantForScenario  = Convert.ToByte(calculation.IsRelevant),
                ScenarioContribution = calculation.Contribution,
                Order                = order
            };

            SetInputValues(entity, calculation.InputParameters, registry);
            SetOutputEntity(entity, calculation);

            return(entity);
        }
        public void Create_MacroStabilityInwardsCalculationScenarioWithNaNValues_ReturnsMacroStabilityInwardsCalculationEntityWithExpectedNullProperties()
        {
            // Setup
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SlipPlaneMinimumDepth           = RoundedDouble.NaN,
                    SlipPlaneMinimumLength          = RoundedDouble.NaN,
                    MaximumSliceWidth               = RoundedDouble.NaN,
                    AssessmentLevel                 = RoundedDouble.NaN,
                    WaterLevelRiverAverage          = RoundedDouble.NaN,
                    XCoordinateDrainageConstruction = RoundedDouble.NaN,
                    ZCoordinateDrainageConstruction = RoundedDouble.NaN,
                    LocationInputExtreme            =
                    {
                        WaterLevelPolder                          = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowDikeTopAtRiver     = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowDikeTopAtPolder    = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowShoulderBaseInside = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowDikeToeAtPolder    = RoundedDouble.NaN,
                        PenetrationLength                         = RoundedDouble.NaN
                    },
                    LocationInputDaily                            =
                    {
                        WaterLevelPolder                          = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowDikeTopAtRiver     = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowDikeTopAtPolder    = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowShoulderBaseInside = RoundedDouble.NaN,
                        PhreaticLineOffsetBelowDikeToeAtPolder    = RoundedDouble.NaN
                    },
                    LeakageLengthOutwardsPhreaticLine3   = RoundedDouble.NaN,
                    LeakageLengthInwardsPhreaticLine3    = RoundedDouble.NaN,
                    LeakageLengthOutwardsPhreaticLine4   = RoundedDouble.NaN,
                    LeakageLengthInwardsPhreaticLine4    = RoundedDouble.NaN,
                    PiezometricHeadPhreaticLine2Outwards = RoundedDouble.NaN,
                    PiezometricHeadPhreaticLine2Inwards  = RoundedDouble.NaN,
                    TangentLineZTop    = RoundedDouble.NaN,
                    TangentLineZBottom = RoundedDouble.NaN,
                    LeftGrid           =
                    {
                        XLeft   = RoundedDouble.NaN,
                        XRight  = RoundedDouble.NaN,
                        ZTop    = RoundedDouble.NaN,
                        ZBottom = RoundedDouble.NaN
                    },
                    RightGrid                                     =
                    {
                        XLeft   = RoundedDouble.NaN,
                        XRight  = RoundedDouble.NaN,
                        ZTop    = RoundedDouble.NaN,
                        ZBottom = RoundedDouble.NaN
                    },
                    ZoneBoundaryLeft  = RoundedDouble.NaN,
                    ZoneBoundaryRight = RoundedDouble.NaN
                }
            };
            var registry = new PersistenceRegistry();

            // When
            MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, 0);

            // Assert
            Assert.IsNotNull(entity);

            Assert.IsNull(entity.AssessmentLevel);
            Assert.IsNull(entity.SlipPlaneMinimumDepth);
            Assert.IsNull(entity.SlipPlaneMinimumLength);
            Assert.IsNull(entity.MaximumSliceWidth);
            Assert.IsNull(entity.WaterLevelRiverAverage);
            Assert.IsNull(entity.DrainageConstructionCoordinateX);
            Assert.IsNull(entity.DrainageConstructionCoordinateZ);
            Assert.IsNull(entity.MinimumLevelPhreaticLineAtDikeTopRiver);
            Assert.IsNull(entity.MinimumLevelPhreaticLineAtDikeTopPolder);

            Assert.IsNull(entity.LocationInputExtremeWaterLevelPolder);
            Assert.IsNull(entity.LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder);
            Assert.IsNull(entity.LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder);
            Assert.IsNull(entity.LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside);
            Assert.IsNull(entity.LocationInputExtremePhreaticLineOffsetDikeToeAtPolder);
            Assert.IsNull(entity.LocationInputExtremePenetrationLength);

            Assert.IsNull(entity.LocationInputDailyWaterLevelPolder);
            Assert.IsNull(entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder);
            Assert.IsNull(entity.LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder);
            Assert.IsNull(entity.LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside);
            Assert.IsNull(entity.LocationInputDailyPhreaticLineOffsetDikeToeAtPolder);

            Assert.IsNull(entity.LeakageLengthOutwardsPhreaticLine3);
            Assert.IsNull(entity.LeakageLengthInwardsPhreaticLine3);
            Assert.IsNull(entity.LeakageLengthOutwardsPhreaticLine4);
            Assert.IsNull(entity.LeakageLengthInwardsPhreaticLine4);
            Assert.IsNull(entity.PiezometricHeadPhreaticLine2Outwards);
            Assert.IsNull(entity.PiezometricHeadPhreaticLine2Inwards);

            Assert.IsNull(entity.TangentLineZTop);
            Assert.IsNull(entity.TangentLineZBottom);

            Assert.IsNull(entity.LeftGridXLeft);
            Assert.IsNull(entity.LeftGridXRight);
            Assert.IsNull(entity.LeftGridZTop);
            Assert.IsNull(entity.LeftGridZBottom);

            Assert.IsNull(entity.RightGridXRight);
            Assert.IsNull(entity.RightGridXRight);
            Assert.IsNull(entity.RightGridZTop);
            Assert.IsNull(entity.RightGridZBottom);

            Assert.IsNull(entity.ZoneBoundaryLeft);
            Assert.IsNull(entity.ZoneBoundaryRight);
        }
Esempio n. 7
0
        public void Create_SurfaceLineWithGeometryAndCharacteristicPoints_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
        {
            // Setup
            var registry = new PersistenceRegistry();
            var random   = new Random(31);
            var geometry = new[]
            {
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()),
                new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble())
            };
            var surfaceLine = new PipingSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            surfaceLine.SetGeometry(geometry);
            const int bottomDitchDikeIndex = 1;

            surfaceLine.SetBottomDitchDikeSideAt(geometry[bottomDitchDikeIndex]);
            const int bottomDitchPolderIndex = 2;

            surfaceLine.SetBottomDitchPolderSideAt(geometry[bottomDitchPolderIndex]);
            const int toePolderIndex = 3;

            surfaceLine.SetDikeToeAtPolderAt(geometry[toePolderIndex]);
            const int toeDikeIndex = 4;

            surfaceLine.SetDikeToeAtRiverAt(geometry[toeDikeIndex]);
            const int ditchDikeIndex = 5;

            surfaceLine.SetDitchDikeSideAt(geometry[ditchDikeIndex]);
            const int ditchPolderIndex = 6;

            surfaceLine.SetDitchPolderSideAt(geometry[ditchPolderIndex]);

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, 0);

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

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.AreEqual(6, entity.PipingCharacteristicPointEntities.Count);
            foreach (PipingCharacteristicPointEntity characteristicPointEntity in entity.PipingCharacteristicPointEntities)
            {
                switch (characteristicPointEntity.Type)
                {
                case (byte)PipingCharacteristicPointType.BottomDitchDikeSide:
                    Assert.AreEqual(geometry[bottomDitchDikeIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[bottomDitchDikeIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[bottomDitchDikeIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.BottomDitchPolderSide:
                    Assert.AreEqual(geometry[bottomDitchPolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[bottomDitchPolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[bottomDitchPolderIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DikeToeAtPolder:
                    Assert.AreEqual(geometry[toePolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[toePolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[toePolderIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DikeToeAtRiver:
                    Assert.AreEqual(geometry[toeDikeIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[toeDikeIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[toeDikeIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DitchDikeSide:
                    Assert.AreEqual(geometry[ditchDikeIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[ditchDikeIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[ditchDikeIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)PipingCharacteristicPointType.DitchPolderSide:
                    Assert.AreEqual(geometry[ditchPolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[ditchPolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[ditchPolderIndex].Z, characteristicPointEntity.Z);
                    break;

                default:
                    Assert.Fail("Invalid characteristic point type found: {0}", characteristicPointEntity.Type);
                    break;
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Creates a <see cref="GrassCoverErosionOutwardsWaveConditionsCalculationEntity"/> based on the information of the
        /// <see cref="GrassCoverErosionOutwardsWaveConditionsCalculation"/>.
        /// </summary>
        /// <param name="calculation">The 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="GrassCoverErosionOutwardsWaveConditionsCalculationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static GrassCoverErosionOutwardsWaveConditionsCalculationEntity Create(this GrassCoverErosionOutwardsWaveConditionsCalculation calculation,
                                                                                        PersistenceRegistry registry, int order)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

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

            var entity = new GrassCoverErosionOutwardsWaveConditionsCalculationEntity
            {
                Order    = order,
                Name     = calculation.Name.DeepClone(),
                Comments = calculation.Comments.Body.DeepClone()
            };

            SetInputParameters(entity, calculation.InputParameters, registry);
            SetOutputEntities(entity, calculation);

            return(entity);
        }
        public void Create_MacroStabilityInwardsCalculationScenarioWithNumericAndBooleanPropertiesSet_ReturnsMacroStabilityInwardsCalculationEntity()
        {
            // Setup
            var random   = new Random(21);
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                IsRelevant      = random.NextBoolean(),
                Contribution    = random.NextRoundedDouble(),
                InputParameters =
                {
                    UseAssessmentLevelManualInput                 = random.NextBoolean(),
                    AssessmentLevel        = random.NextRoundedDouble(),
                    SlipPlaneMinimumDepth  = random.NextRoundedDouble(),
                    SlipPlaneMinimumLength = random.NextRoundedDouble(),
                    MaximumSliceWidth      = random.NextRoundedDouble(),
                    MoveGrid                                = random.NextBoolean(),
                    DikeSoilScenario                        = random.NextEnumValue <MacroStabilityInwardsDikeSoilScenario>(),
                    WaterLevelRiverAverage                  = random.NextRoundedDouble(),
                    DrainageConstructionPresent             = random.NextBoolean(),
                    XCoordinateDrainageConstruction         = random.NextRoundedDouble(),
                    ZCoordinateDrainageConstruction         = random.NextRoundedDouble(),
                    MinimumLevelPhreaticLineAtDikeTopRiver  = random.NextRoundedDouble(),
                    MinimumLevelPhreaticLineAtDikeTopPolder = random.NextRoundedDouble(),
                    LocationInputExtreme                    =
                    {
                        WaterLevelPolder  = random.NextRoundedDouble(),
                        UseDefaultOffsets = random.NextBoolean(),
                        PhreaticLineOffsetBelowDikeTopAtRiver     = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeTopAtPolder    = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowShoulderBaseInside = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeToeAtPolder    = random.NextRoundedDouble(),
                        PenetrationLength                         = random.NextRoundedDouble()
                    },
                    LocationInputDaily                            =
                    {
                        WaterLevelPolder  = random.NextRoundedDouble(),
                        UseDefaultOffsets = random.NextBoolean(),
                        PhreaticLineOffsetBelowDikeTopAtRiver     = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeTopAtPolder    = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowShoulderBaseInside = random.NextRoundedDouble(),
                        PhreaticLineOffsetBelowDikeToeAtPolder    = random.NextRoundedDouble()
                    },
                    AdjustPhreaticLine3And4ForUplift     = random.NextBoolean(),
                    LeakageLengthOutwardsPhreaticLine3   = random.NextRoundedDouble(),
                    LeakageLengthInwardsPhreaticLine3    = random.NextRoundedDouble(),
                    LeakageLengthOutwardsPhreaticLine4   = random.NextRoundedDouble(),
                    LeakageLengthInwardsPhreaticLine4    = random.NextRoundedDouble(),
                    PiezometricHeadPhreaticLine2Outwards = random.NextRoundedDouble(),
                    PiezometricHeadPhreaticLine2Inwards  = random.NextRoundedDouble(),
                    GridDeterminationType        = random.NextEnumValue <MacroStabilityInwardsGridDeterminationType>(),
                    TangentLineDeterminationType = random.NextEnumValue <MacroStabilityInwardsTangentLineDeterminationType>(),
                    TangentLineZTop    = random.NextRoundedDouble(2.0,                                                    3.0),
                    TangentLineZBottom = random.NextRoundedDouble(0.0,                                                    1.0),
                    TangentLineNumber  = random.Next(1,                                                                    50),
                    LeftGrid           =
                    {
                        XLeft  = random.NextRoundedDouble(0.0,                                                                   1.0),
                        XRight = random.NextRoundedDouble(2.0,                                                                   3.0),
                        NumberOfHorizontalPoints                  = random.Next(1,                                                                                  100),
                        ZTop    = random.NextRoundedDouble(2.0,                                                                   3.0),
                        ZBottom = random.NextRoundedDouble(0.0,                                                                   1.0),
                        NumberOfVerticalPoints                    = random.Next(1,                                     100)
                    },
                    RightGrid                                     =
                    {
                        XLeft  = random.NextRoundedDouble(0.0,                                                                   1.0),
                        XRight = random.NextRoundedDouble(),
                        NumberOfHorizontalPoints                  = random.Next(1,                                                                                  100),
                        ZTop    = random.NextRoundedDouble(2.0,                                                                   3.0),
                        ZBottom = random.NextRoundedDouble(0.0,                                                                   1.0),
                        NumberOfVerticalPoints                    = random.Next(1,                                   100)
                    },
                    CreateZones                                   = random.NextBoolean(),
                    ZoningBoundariesDeterminationType             = random.NextEnumValue <MacroStabilityInwardsZoningBoundariesDeterminationType>(),
                    ZoneBoundaryLeft  = random.NextRoundedDouble(),
                    ZoneBoundaryRight = random.NextRoundedDouble()
                }
            };

            var registry = new PersistenceRegistry();
            int order    = random.Next();

            // Call
            MacroStabilityInwardsCalculationEntity entity = scenario.Create(registry, order);

            // Assert
            Assert.IsNotNull(entity);

            MacroStabilityInwardsCalculationEntityTestHelper.AssertCalculationScenarioPropertyValues(scenario, entity);
            Assert.IsNull(entity.SurfaceLineEntity);
            Assert.IsNull(entity.MacroStabilityInwardsStochasticSoilProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);
            Assert.AreEqual(order, entity.Order);
        }
Esempio n. 10
0
        public void Create_SemiProbabilisticPipingCalculationScenarioWithPropertiesSet_ReturnSemiProbabilisticPipingCalculationEntity(
            bool isRelevant, bool useAssessmentLevelManualInput, double contribution, string name, string comments,
            double exitPoint, double entryPoint, double assessmentLevel, int order, int randomSeed)
        {
            // Setup
            var random = new Random(randomSeed);

            var calculation = new SemiProbabilisticPipingCalculationScenario
            {
                IsRelevant   = isRelevant,
                Contribution = (RoundedDouble)contribution,
                Name         = name,
                Comments     =
                {
                    Body = comments
                },
                InputParameters =
                {
                    ExitPointL        = (RoundedDouble)exitPoint,
                    EntryPointL       = (RoundedDouble)entryPoint,
                    PhreaticLevelExit =
                    {
                        Mean                      = random.NextRoundedDouble(-9999.9999, 9999.9999),
                        StandardDeviation         = random.NextRoundedDouble(1e-6,             9999.9999)
                    },
                    DampingFactorExit             =
                    {
                        Mean                      = random.NextRoundedDouble(1e-6,       9999.9999),
                        StandardDeviation         = random.NextRoundedDouble(1e-6, 9999.9999)
                    },
                    UseAssessmentLevelManualInput = useAssessmentLevelManualInput,
                    AssessmentLevel               = (RoundedDouble)assessmentLevel
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            SemiProbabilisticPipingCalculationEntity entity = calculation.Create(registry, order);

            // Assert
            Assert.AreEqual(Convert.ToByte(isRelevant), entity.RelevantForScenario);
            Assert.AreEqual(calculation.Contribution, entity.ScenarioContribution);
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(comments, entity.Comments);

            Assert.AreEqual(exitPoint.ToNaNAsNull(), entity.ExitPointL);
            Assert.AreEqual(entryPoint.ToNaNAsNull(), entity.EntryPointL);

            SemiProbabilisticPipingInput input = calculation.InputParameters;

            Assert.AreEqual(input.PhreaticLevelExit.Mean.Value, entity.PhreaticLevelExitMean);
            Assert.AreEqual(input.PhreaticLevelExit.StandardDeviation.Value, entity.PhreaticLevelExitStandardDeviation);
            Assert.AreEqual(input.DampingFactorExit.Mean.Value, entity.DampingFactorExitMean);
            Assert.AreEqual(input.DampingFactorExit.StandardDeviation.Value, entity.DampingFactorExitStandardDeviation);

            Assert.AreEqual(Convert.ToByte(input.UseAssessmentLevelManualInput), entity.UseAssessmentLevelManualInput);
            Assert.AreEqual(input.AssessmentLevel.ToNaNAsNull(), entity.AssessmentLevel);

            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(0, entity.SemiProbabilisticPipingCalculationEntityId);
            Assert.IsNull(entity.CalculationGroupEntity);

            Assert.IsNull(entity.SurfaceLineEntity);
            Assert.IsNull(entity.PipingStochasticSoilProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);
            CollectionAssert.IsEmpty(entity.SemiProbabilisticPipingCalculationOutputEntities);
        }
        /// <summary>
        /// Creates a <see cref="ClosingStructureEntity"/> based on the information of the <see cref="ClosingStructure"/>.
        /// </summary>
        /// <param name="structure">The structure 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="structure"/> resides within its parent.</param>
        /// <returns>A new <see cref="ClosingStructureEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static ClosingStructureEntity Create(this ClosingStructure structure, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            if (registry.Contains(structure))
            {
                return(registry.Get(structure));
            }

            var entity = new ClosingStructureEntity
            {
                Name = structure.Name.DeepClone(),
                Id   = structure.Id.DeepClone(),
                X    = structure.Location.X.ToNaNAsNull(),
                Y    = structure.Location.Y.ToNaNAsNull(),
                StructureNormalOrientation = structure.StructureNormalOrientation.ToNaNAsNull(),
                StorageStructureAreaMean   = structure.StorageStructureArea.Mean.ToNaNAsNull(),
                StorageStructureAreaCoefficientOfVariation   = structure.StorageStructureArea.CoefficientOfVariation.ToNaNAsNull(),
                AllowedLevelIncreaseStorageMean              = structure.AllowedLevelIncreaseStorage.Mean.ToNaNAsNull(),
                AllowedLevelIncreaseStorageStandardDeviation = structure.AllowedLevelIncreaseStorage.StandardDeviation.ToNaNAsNull(),
                WidthFlowAperturesMean = structure.WidthFlowApertures.Mean.ToNaNAsNull(),
                WidthFlowAperturesStandardDeviation            = structure.WidthFlowApertures.StandardDeviation.ToNaNAsNull(),
                LevelCrestStructureNotClosingMean              = structure.LevelCrestStructureNotClosing.Mean.ToNaNAsNull(),
                LevelCrestStructureNotClosingStandardDeviation = structure.LevelCrestStructureNotClosing.StandardDeviation.ToNaNAsNull(),
                InsideWaterLevelMean = structure.InsideWaterLevel.Mean.ToNaNAsNull(),
                InsideWaterLevelStandardDeviation        = structure.InsideWaterLevel.StandardDeviation.ToNaNAsNull(),
                ThresholdHeightOpenWeirMean              = structure.ThresholdHeightOpenWeir.Mean.ToNaNAsNull(),
                ThresholdHeightOpenWeirStandardDeviation = structure.ThresholdHeightOpenWeir.StandardDeviation.ToNaNAsNull(),
                AreaFlowAperturesMean = structure.AreaFlowApertures.Mean.ToNaNAsNull(),
                AreaFlowAperturesStandardDeviation = structure.AreaFlowApertures.StandardDeviation.ToNaNAsNull(),
                CriticalOvertoppingDischargeMean   = structure.CriticalOvertoppingDischarge.Mean.ToNaNAsNull(),
                CriticalOvertoppingDischargeCoefficientOfVariation = structure.CriticalOvertoppingDischarge.CoefficientOfVariation.ToNaNAsNull(),
                FlowWidthAtBottomProtectionMean = structure.FlowWidthAtBottomProtection.Mean.ToNaNAsNull(),
                FlowWidthAtBottomProtectionStandardDeviation = structure.FlowWidthAtBottomProtection.StandardDeviation.ToNaNAsNull(),
                ProbabilityOpenStructureBeforeFlooding       = structure.ProbabilityOpenStructureBeforeFlooding.ToNaNAsNull(),
                FailureProbabilityOpenStructure = structure.FailureProbabilityOpenStructure.ToNaNAsNull(),
                IdenticalApertures           = structure.IdenticalApertures,
                FailureProbabilityReparation = structure.FailureProbabilityReparation.ToNaNAsNull(),
                InflowModelType = Convert.ToByte(structure.InflowModelType),
                Order           = order
            };

            registry.Register(entity, structure);

            return(entity);
        }
Esempio n. 12
0
        /// <summary>
        /// Creates a <see cref="DuneLocationCalculationEntity"/> based on the information of the <see cref="DuneLocationCalculation"/>.
        /// </summary>
        /// <param name="calculation">The calculation to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="DuneLocationCalculationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static DuneLocationCalculationEntity Create(this DuneLocationCalculation calculation, PersistenceRegistry registry)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

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

            var duneLocationCalculationEntity = new DuneLocationCalculationEntity
            {
                DuneLocationEntity = registry.Get(calculation.DuneLocation)
            };

            CreateDuneLocationOutput(duneLocationCalculationEntity, calculation.Output);

            return(duneLocationCalculationEntity);
        }
Esempio n. 13
0
        public void Create_ValidCalculation_ReturnEntity(string comment)
        {
            // Setup
            var          random      = new Random(12);
            int          order       = random.Next();
            const string name        = "GrassCoverErosionInwardsCalculation Name";
            var          calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                Name     = name,
                Comments =
                {
                    Body = comment
                },
                IsRelevant      = random.NextBoolean(),
                Contribution    = random.NextRoundedDouble(),
                InputParameters =
                {
                    DikeProfile                                           = null,
                    HydraulicBoundaryLocation                             = null,
                    DikeHeight  = (RoundedDouble)1.1,
                    Orientation = (RoundedDouble)2.2,
                    BreakWater  =
                    {
                        Height = (RoundedDouble)3.3,
                        Type   = BreakWaterType.Dam
                    },
                    CriticalFlowRate                                      =
                    {
                        Mean                                              = (RoundedDouble)4.4,
                        StandardDeviation                                 = (RoundedDouble)5.5
                    },
                    UseBreakWater = true,
                    UseForeshore  = false,
                    ShouldOvertoppingOutputIllustrationPointsBeCalculated = random.NextBoolean(),
                    ShouldDikeHeightBeCalculated = random.NextBoolean(),
                    DikeHeightTargetProbability  = random.NextDouble(1e-15, 0.1),
                    ShouldDikeHeightIllustrationPointsBeCalculated        = random.NextBoolean(),
                    ShouldOvertoppingRateBeCalculated = random.NextBoolean(),
                    OvertoppingRateTargetProbability  = random.NextDouble(1e-15, 0.1),
                    ShouldOvertoppingRateIllustrationPointsBeCalculated   = random.NextBoolean()
                },
                Output = null
            };

            var registry = new PersistenceRegistry();

            // Call
            GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, order);

            // Assert
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(comment, entity.Comments);
            Assert.AreEqual(Convert.ToByte(calculation.IsRelevant), entity.RelevantForScenario);
            Assert.AreEqual(calculation.Contribution, entity.ScenarioContribution);

            Assert.AreEqual(order, entity.Order);

            Assert.IsNull(entity.DikeProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);

            GrassCoverErosionInwardsInput input = calculation.InputParameters;

            Assert.AreEqual(input.BreakWater.Height.Value, entity.BreakWaterHeight);
            Assert.AreEqual((short)input.BreakWater.Type, entity.BreakWaterType);
            Assert.AreEqual(Convert.ToByte(input.UseBreakWater), entity.UseBreakWater);
            Assert.AreEqual(input.CriticalFlowRate.Mean.Value, entity.CriticalFlowRateMean);
            Assert.AreEqual(input.CriticalFlowRate.StandardDeviation.Value, entity.CriticalFlowRateStandardDeviation);
            Assert.AreEqual(input.Orientation.Value, entity.Orientation);
            Assert.AreEqual(input.DikeHeight.Value, entity.DikeHeight);
            Assert.AreEqual(Convert.ToByte(input.UseForeshore), entity.UseForeshore);

            Assert.AreEqual(Convert.ToByte(input.ShouldOvertoppingOutputIllustrationPointsBeCalculated),
                            entity.ShouldOvertoppingOutputIllustrationPointsBeCalculated);

            Assert.AreEqual(Convert.ToByte(input.ShouldDikeHeightBeCalculated), entity.ShouldDikeHeightBeCalculated);
            Assert.AreEqual(input.DikeHeightTargetProbability, entity.DikeHeightTargetProbability);
            Assert.AreEqual(Convert.ToByte(input.ShouldDikeHeightIllustrationPointsBeCalculated),
                            entity.ShouldDikeHeightIllustrationPointsBeCalculated);

            Assert.AreEqual(Convert.ToByte(input.ShouldOvertoppingRateBeCalculated), entity.ShouldOvertoppingRateBeCalculated);
            Assert.AreEqual(input.OvertoppingRateTargetProbability, entity.OvertoppingRateTargetProbability);
            Assert.AreEqual(Convert.ToByte(input.ShouldOvertoppingRateIllustrationPointsBeCalculated),
                            entity.ShouldOvertoppingRateIllustrationPointsBeCalculated);

            Assert.IsFalse(entity.GrassCoverErosionInwardsOutputEntities.Any());
        }
        public void Create_SurfaceLineWithCharacteristicPointsOnSameGeometryPoint_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
        {
            // Setup
            var random   = new Random(31);
            var registry = new PersistenceRegistry();

            Point3D[] geometry =
            {
                GetRandomPoint3D(random)
            };
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = new Point2D(random.NextDouble(), random.NextDouble())
            };

            surfaceLine.SetGeometry(geometry);
            surfaceLine.SetSurfaceLevelOutsideAt(geometry[0]);
            surfaceLine.SetDikeTopAtPolderAt(geometry[0]);
            surfaceLine.SetDikeTopAtRiverAt(geometry[0]);
            surfaceLine.SetShoulderBaseInsideAt(geometry[0]);
            surfaceLine.SetShoulderTopInsideAt(geometry[0]);
            surfaceLine.SetBottomDitchDikeSideAt(geometry[0]);
            surfaceLine.SetBottomDitchPolderSideAt(geometry[0]);
            surfaceLine.SetDikeToeAtPolderAt(geometry[0]);
            surfaceLine.SetDikeToeAtRiverAt(geometry[0]);
            surfaceLine.SetDitchDikeSideAt(geometry[0]);
            surfaceLine.SetDitchPolderSideAt(geometry[0]);
            surfaceLine.SetSurfaceLevelInsideAt(geometry[0]);

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, 0);

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

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.AreEqual(12, entity.MacroStabilityInwardsCharacteristicPointEntities.Count);
            CollectionAssert.AreEquivalent(new[]
            {
                (byte)MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside,
                (byte)MacroStabilityInwardsCharacteristicPointType.DikeTopAtPolder,
                (byte)MacroStabilityInwardsCharacteristicPointType.DikeTopAtRiver,
                (byte)MacroStabilityInwardsCharacteristicPointType.ShoulderBaseInside,
                (byte)MacroStabilityInwardsCharacteristicPointType.ShoulderTopInside,
                (byte)MacroStabilityInwardsCharacteristicPointType.BottomDitchDikeSide,
                (byte)MacroStabilityInwardsCharacteristicPointType.BottomDitchPolderSide,
                (byte)MacroStabilityInwardsCharacteristicPointType.DikeToeAtPolder,
                (byte)MacroStabilityInwardsCharacteristicPointType.DikeToeAtRiver,
                (byte)MacroStabilityInwardsCharacteristicPointType.DitchDikeSide,
                (byte)MacroStabilityInwardsCharacteristicPointType.DitchPolderSide,
                (byte)MacroStabilityInwardsCharacteristicPointType.SurfaceLevelInside
            }, entity.MacroStabilityInwardsCharacteristicPointEntities
                                           .Select(cpe => cpe.Type));

            foreach (MacroStabilityInwardsCharacteristicPointEntity characteristicPointEntity in entity.MacroStabilityInwardsCharacteristicPointEntities)
            {
                Assert.AreEqual(geometry[0].X, characteristicPointEntity.X);
                Assert.AreEqual(geometry[0].Y, characteristicPointEntity.Y);
                Assert.AreEqual(geometry[0].Z, characteristicPointEntity.Z);
            }
        }
        public void Create_SurfaceLineWithGeometryAndCharacteristicPoints_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
        {
            // Setup
            var random = new Random(31);

            Point3D[] geometry =
            {
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random),
                GetRandomPoint3D(random)
            };
            var surfaceLine = new MacroStabilityInwardsSurfaceLine("Test")
            {
                ReferenceLineIntersectionWorldPoint = GetRandomPoint2D(random)
            };

            surfaceLine.SetGeometry(geometry);

            const int surfaceLevelOutsideIndex = 1;

            surfaceLine.SetSurfaceLevelOutsideAt(geometry[surfaceLevelOutsideIndex]);
            const int dikeTopAtPolderIndex = 2;

            surfaceLine.SetDikeTopAtPolderAt(geometry[dikeTopAtPolderIndex]);
            const int dikeTopAtRiverIndex = 3;

            surfaceLine.SetDikeTopAtRiverAt(geometry[dikeTopAtRiverIndex]);
            const int shoulderBaseInsideIndex = 4;

            surfaceLine.SetShoulderBaseInsideAt(geometry[shoulderBaseInsideIndex]);
            const int shoulderTopInsideIndex = 5;

            surfaceLine.SetShoulderTopInsideAt(geometry[shoulderTopInsideIndex]);
            const int bottomDitchDikeSideIndex = 6;

            surfaceLine.SetBottomDitchDikeSideAt(geometry[bottomDitchDikeSideIndex]);
            const int bottomDitchPolderSideIndex = 7;

            surfaceLine.SetBottomDitchPolderSideAt(geometry[bottomDitchPolderSideIndex]);
            const int dikeToeAtPolderIndex = 8;

            surfaceLine.SetDikeToeAtPolderAt(geometry[dikeToeAtPolderIndex]);
            const int dikeToeAtRiverIndex = 9;

            surfaceLine.SetDikeToeAtRiverAt(geometry[dikeToeAtRiverIndex]);
            const int ditchDikeSideIndex = 10;

            surfaceLine.SetDitchDikeSideAt(geometry[ditchDikeSideIndex]);
            const int ditchPolderSideIndex = 11;

            surfaceLine.SetDitchPolderSideAt(geometry[ditchPolderSideIndex]);
            const int surfaceLevelInsideIndex = 12;

            surfaceLine.SetSurfaceLevelInsideAt(geometry[surfaceLevelInsideIndex]);

            var registry = new PersistenceRegistry();

            // Call
            SurfaceLineEntity entity = surfaceLine.Create(registry, 0);

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

            string expectedXml = new Point3DCollectionXmlSerializer().ToXml(geometry);

            Assert.AreEqual(expectedXml, entity.PointsXml);

            Assert.AreEqual(12, entity.MacroStabilityInwardsCharacteristicPointEntities.Count);
            foreach (MacroStabilityInwardsCharacteristicPointEntity characteristicPointEntity in entity.MacroStabilityInwardsCharacteristicPointEntities)
            {
                switch (characteristicPointEntity.Type)
                {
                case (byte)MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside:
                    Assert.AreEqual(geometry[surfaceLevelOutsideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[surfaceLevelOutsideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[surfaceLevelOutsideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.DikeTopAtPolder:
                    Assert.AreEqual(geometry[dikeTopAtPolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[dikeTopAtPolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[dikeTopAtPolderIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.DikeTopAtRiver:
                    Assert.AreEqual(geometry[dikeTopAtRiverIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[dikeTopAtRiverIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[dikeTopAtRiverIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.ShoulderBaseInside:
                    Assert.AreEqual(geometry[shoulderBaseInsideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[shoulderBaseInsideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[shoulderBaseInsideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.ShoulderTopInside:
                    Assert.AreEqual(geometry[shoulderTopInsideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[shoulderTopInsideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[shoulderTopInsideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.BottomDitchDikeSide:
                    Assert.AreEqual(geometry[bottomDitchDikeSideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[bottomDitchDikeSideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[bottomDitchDikeSideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.BottomDitchPolderSide:
                    Assert.AreEqual(geometry[bottomDitchPolderSideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[bottomDitchPolderSideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[bottomDitchPolderSideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.DikeToeAtPolder:
                    Assert.AreEqual(geometry[dikeToeAtPolderIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[dikeToeAtPolderIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[dikeToeAtPolderIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.DikeToeAtRiver:
                    Assert.AreEqual(geometry[dikeToeAtRiverIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[dikeToeAtRiverIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[dikeToeAtRiverIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.DitchDikeSide:
                    Assert.AreEqual(geometry[ditchDikeSideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[ditchDikeSideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[ditchDikeSideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.DitchPolderSide:
                    Assert.AreEqual(geometry[ditchPolderSideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[ditchPolderSideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[ditchPolderSideIndex].Z, characteristicPointEntity.Z);
                    break;

                case (byte)MacroStabilityInwardsCharacteristicPointType.SurfaceLevelInside:
                    Assert.AreEqual(geometry[surfaceLevelInsideIndex].X, characteristicPointEntity.X);
                    Assert.AreEqual(geometry[surfaceLevelInsideIndex].Y, characteristicPointEntity.Y);
                    Assert.AreEqual(geometry[surfaceLevelInsideIndex].Z, characteristicPointEntity.Z);
                    break;

                default:
                    Assert.Fail("Invalid characteristic point type found: {0}", characteristicPointEntity.Type);
                    break;
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Creates a <see cref="FailureMechanismEntity"/> based on the information of the <see cref="ClosingStructuresFailureMechanism"/>.
        /// </summary>
        /// <param name="mechanism">The failure mechanism to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="FailureMechanismEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static FailureMechanismEntity Create(this ClosingStructuresFailureMechanism mechanism, PersistenceRegistry registry)
        {
            FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.ReliabilityClosingOfStructure, registry);

            AddEntitiesForForeshoreProfiles(mechanism.ForeshoreProfiles, entity, registry);
            AddEntitiesForClosingStructures(mechanism.ClosingStructures, entity, registry);
            AddEntitiesForFailureMechanismMeta(mechanism, entity);
            entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0);
            AddEntitiesForSectionResults(mechanism.SectionResults, registry);

            return(entity);
        }