Ejemplo n.º 1
0
        public void Create_WithClosingStructures_ClosingStructureEntitiesCreated()
        {
            // Setup
            ClosingStructure structure = new TestClosingStructure();

            var          failureMechanism = new ClosingStructuresFailureMechanism();
            const string filePath         = "some path";

            failureMechanism.ClosingStructures.AddRange(new[]
            {
                structure
            }, filePath);

            var persistenceRegistry = new PersistenceRegistry();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry);

            // Assert
            Assert.AreEqual(1, entity.ClosingStructureEntities.Count);
            Assert.IsTrue(persistenceRegistry.Contains(structure));

            ClosingStructuresFailureMechanismMetaEntity metaEntity =
                entity.ClosingStructuresFailureMechanismMetaEntities.Single();
            string entitySourcePath = metaEntity.ClosingStructureCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(filePath, entitySourcePath);
        }
Ejemplo n.º 2
0
        public void Create_WithStabilityPointStructures_StabilityPointStructureEntitiesCreated()
        {
            // Setup
            StabilityPointStructure structure = new TestStabilityPointStructure();

            const string filePath         = "path/to/structures";
            var          failureMechanism = new StabilityPointStructuresFailureMechanism();

            failureMechanism.StabilityPointStructures.AddRange(new[]
            {
                structure
            }, filePath);

            var persistenceRegistry = new PersistenceRegistry();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry);

            // Assert
            Assert.AreEqual(1, entity.StabilityPointStructureEntities.Count);
            Assert.IsTrue(persistenceRegistry.Contains(structure));

            StabilityPointStructuresFailureMechanismMetaEntity metaEntity =
                entity.StabilityPointStructuresFailureMechanismMetaEntities.Single();

            TestHelper.AssertAreEqualButNotSame(filePath, metaEntity.StabilityPointStructureCollectionSourcePath);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a <see cref="StochasticSoilModelEntity"/> based on the information of the <see cref="PipingStochasticSoilModel"/>.
        /// </summary>
        /// <param name="model">The model to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="StochasticSoilModelEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static StochasticSoilModelEntity Create(this PipingStochasticSoilModel model,
                                                         PersistenceRegistry registry,
                                                         int order)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }

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

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

            var entity = new StochasticSoilModelEntity
            {
                Name = model.Name.DeepClone(),
                StochasticSoilModelSegmentPointXml = new Point2DCollectionXmlSerializer().ToXml(model.Geometry),
                Order = order
            };

            AddEntitiesForStochasticSoilProfiles(model, registry, entity);

            registry.Register(entity, model);
            return(entity);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a <see cref="DikeProfileEntity"/> based on the information of the <see cref="DikeProfile"/>.
        /// </summary>
        /// <param name="dikeProfile">The dike profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="DikeProfileEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static DikeProfileEntity Create(this DikeProfile dikeProfile, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var sectionResultEntity = new DikeProfileEntity
            {
                X  = dikeProfile.WorldReferencePoint.X,
                Y  = dikeProfile.WorldReferencePoint.Y,
                X0 = dikeProfile.X0,
                DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry),
                ForeshoreXml    = new Point2DCollectionXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry),
                Orientation     = dikeProfile.Orientation,
                DikeHeight      = dikeProfile.DikeHeight,
                Id    = dikeProfile.Id.DeepClone(),
                Name  = dikeProfile.Name.DeepClone(),
                Order = order
            };

            if (dikeProfile.HasBreakWater)
            {
                sectionResultEntity.BreakWaterHeight = dikeProfile.BreakWater.Height;
                sectionResultEntity.BreakWaterType   = Convert.ToByte(dikeProfile.BreakWater.Type);
            }

            registry.Register(sectionResultEntity, dikeProfile);
            return(sectionResultEntity);
        }
Ejemplo n.º 5
0
        public void Create_StochasticSoilProfileSet_EntityHasStochasticSoilProfileEntity()
        {
            // Setup
            PipingSoilProfile soilProfile = PipingSoilProfileTestFactory.CreatePipingSoilProfile();
            var stochasticSoilProfile     = new PipingStochasticSoilProfile(0.6, soilProfile);

            PipingStochasticSoilModel soilModel = PipingStochasticSoilModelTestFactory.CreatePipingStochasticSoilModel("A", new[]
            {
                stochasticSoilProfile
            });

            var registry = new PersistenceRegistry();
            StochasticSoilModelEntity soilModelEntity = soilModel.Create(registry, 0);

            var calculation = new ProbabilisticPipingCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilModel   = soilModel,
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            // Call
            ProbabilisticPipingCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            PipingStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = soilModelEntity.PipingStochasticSoilProfileEntities.First();

            Assert.AreSame(expectedStochasticSoilProfileEntity, entity.PipingStochasticSoilProfileEntity);
            Assert.IsTrue(registry.Contains(soilModel));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates a <see cref="SurfaceLineEntity"/> based on the information of the <see cref="MacroStabilityInwardsSurfaceLine"/>.
        /// </summary>
        /// <param name="surfaceLine">The surface line to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="SurfaceLineEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        internal static SurfaceLineEntity Create(this MacroStabilityInwardsSurfaceLine surfaceLine,
                                                 PersistenceRegistry registry,
                                                 int order)
        {
            if (surfaceLine == null)
            {
                throw new ArgumentNullException(nameof(surfaceLine));
            }

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

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

            var entity = new SurfaceLineEntity
            {
                Name = surfaceLine.Name.DeepClone(),
                ReferenceLineIntersectionX = surfaceLine.ReferenceLineIntersectionWorldPoint?.X.ToNaNAsNull(),
                ReferenceLineIntersectionY = surfaceLine.ReferenceLineIntersectionWorldPoint?.Y.ToNaNAsNull(),
                PointsXml = new Point3DCollectionXmlSerializer().ToXml(surfaceLine.Points),
                Order     = order
            };

            CreateCharacteristicPointEntities(surfaceLine, entity);

            registry.Register(entity, surfaceLine);

            return(entity);
        }
        public void Create_WithForeshoreProfiles_ForeshoreProfileEntitiesCreated()
        {
            // Setup
            var profile = new TestForeshoreProfile();

            var          failureMechanism = new HeightStructuresFailureMechanism();
            const string filePath         = "some/path/to/foreshoreProfiles";

            failureMechanism.ForeshoreProfiles.AddRange(new[]
            {
                profile
            }, filePath);

            var persistenceRegistry = new PersistenceRegistry();

            // Call
            FailureMechanismEntity entity = failureMechanism.Create(persistenceRegistry);

            // Assert
            Assert.AreEqual(1, entity.ForeshoreProfileEntities.Count);
            Assert.IsTrue(persistenceRegistry.Contains(profile));

            HeightStructuresFailureMechanismMetaEntity metaEntity =
                entity.HeightStructuresFailureMechanismMetaEntities.Single();
            string metaEntityForeshoreProfileCollectionSourcePath = metaEntity.ForeshoreProfileCollectionSourcePath;

            TestHelper.AssertAreEqualButNotSame(filePath, metaEntityForeshoreProfileCollectionSourcePath);
        }
        /// <summary>
        /// Creates a <see cref="PipingSoilProfileEntity"/> based on the information of the <see cref="PipingSoilProfile"/>.
        /// </summary>
        /// <param name="profile">The profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="PipingSoilProfileEntity"/> or one from the <paramref name="registry"/>
        /// if it was created for the <see cref="profile"/> earlier.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static PipingSoilProfileEntity Create(this PipingSoilProfile profile,
                                                       PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new PipingSoilProfileEntity
            {
                Name       = profile.Name.DeepClone(),
                Bottom     = profile.Bottom.ToNaNAsNull(),
                SourceType = Convert.ToByte(profile.SoilProfileSourceType)
            };

            AddEntitiesForPipingSoilLayers(profile, entity);

            registry.Register(entity, profile);
            return(entity);
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsStochasticSoilProfileEntity"/> based on
        /// the information of the <see cref="MacroStabilityInwardsStochasticSoilProfile"/>.
        /// </summary>
        /// <param name="stochasticSoilProfile">The stochastic soil profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsStochasticSoilProfileEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <see cref="MacroStabilityInwardsStochasticSoilProfile.SoilProfile"/> is
        /// not of type <see cref="MacroStabilityInwardsSoilProfile1D"/> or <see cref="MacroStabilityInwardsSoilProfile2D"/>.</exception>
        public static MacroStabilityInwardsStochasticSoilProfileEntity Create(this MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile,
                                                                              PersistenceRegistry registry,
                                                                              int order)
        {
            if (stochasticSoilProfile == null)
            {
                throw new ArgumentNullException(nameof(stochasticSoilProfile));
            }

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

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

            var entity = new MacroStabilityInwardsStochasticSoilProfileEntity
            {
                Probability = stochasticSoilProfile.Probability,
                Order       = order
            };

            AddEntityForProfile(stochasticSoilProfile.SoilProfile, entity, registry);

            registry.Register(entity, stochasticSoilProfile);
            return(entity);
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsSoilProfile2D"/>.
        /// </summary>
        /// <param name="soilProfile">The soil profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfileTwoDEntity"/> or one from the
        /// <paramref name="registry"/> if it was created for the <see cref="soilProfile"/> earlier.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilProfileTwoDEntity Create(this MacroStabilityInwardsSoilProfile2D soilProfile,
                                                                        PersistenceRegistry registry)
        {
            if (soilProfile == null)
            {
                throw new ArgumentNullException(nameof(soilProfile));
            }

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

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

            var entity = new MacroStabilityInwardsSoilProfileTwoDEntity
            {
                Name = soilProfile.Name.DeepClone()
            };

            AddEntitiesForSoilLayers(soilProfile.Layers, entity);
            AddEntitiesForPreconsolidationStresses(soilProfile.PreconsolidationStresses, entity);

            registry.Register(entity, soilProfile);
            return(entity);
        }
        /// <summary>
        /// Creates a <see cref="DuneLocationEntity"/> based on the information of the <see cref="DuneLocation"/>.
        /// </summary>
        /// <param name="location">The location to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="DuneLocationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static DuneLocationEntity Create(this DuneLocation location, PersistenceRegistry registry, int order)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

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

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

            var entity = new DuneLocationEntity
            {
                LocationId    = location.Id,
                Name          = location.Name.DeepClone(),
                LocationX     = location.Location.X.ToNaNAsNull(),
                LocationY     = location.Location.Y.ToNaNAsNull(),
                CoastalAreaId = location.CoastalAreaId,
                Offset        = location.Offset.ToNaNAsNull(),
                Orientation   = location.Orientation.ToNaNAsNull(),
                D50           = location.D50.ToNaNAsNull(),
                Order         = order
            };

            registry.Register(entity, location);
            return(entity);
        }
        /// <summary>
        /// Creates a <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> based on the information
        /// of the <see cref="MacroStabilityInwardsSoilProfile1D"/>.
        /// </summary>
        /// <param name="soilProfile">The soil profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="MacroStabilityInwardsSoilProfileOneDEntity"/> or one from the
        /// <paramref name="registry"/> if it was created for the <see cref="soilProfile"/> earlier.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any input parameter is <c>null</c>.</exception>
        public static MacroStabilityInwardsSoilProfileOneDEntity Create(this MacroStabilityInwardsSoilProfile1D soilProfile,
                                                                        PersistenceRegistry registry)
        {
            if (soilProfile == null)
            {
                throw new ArgumentNullException(nameof(soilProfile));
            }

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

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

            var entity = new MacroStabilityInwardsSoilProfileOneDEntity
            {
                Name   = soilProfile.Name.DeepClone(),
                Bottom = soilProfile.Bottom.ToNaNAsNull()
            };

            AddEntitiesForSoilLayers(soilProfile.Layers, entity);

            registry.Register(entity, soilProfile);
            return(entity);
        }
        /// <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);
        }
Ejemplo n.º 14
0
        public void Create_DikeProfileAlreadyRegistered_ReturnRegisteredEntity()
        {
            // Setup
            DikeProfile       dikeProfile = DikeProfileTestFactory.CreateDikeProfile();
            var               registry    = new PersistenceRegistry();
            DikeProfileEntity entity1     = dikeProfile.Create(registry, 0);

            // Precondition:
            Assert.IsTrue(registry.Contains(dikeProfile));

            // Call
            DikeProfileEntity entity2 = dikeProfile.Create(registry, 0);

            // Assert
            Assert.AreSame(entity1, entity2);
        }
Ejemplo n.º 15
0
        public void Create_ValidStructure_ReturnEntity()
        {
            // Setup
            ClosingStructure structure = new TestClosingStructure();
            var registry = new PersistenceRegistry();

            const int order = 4;

            // Call
            ClosingStructureEntity entity = structure.Create(registry, order);

            // Assert
            Assert.AreEqual(structure.Name, entity.Name);
            Assert.AreNotSame(structure.Name, entity.Name);
            Assert.AreEqual(structure.Id, entity.Id);
            Assert.AreNotSame(structure.Id, entity.Id);
            Assert.AreEqual(structure.Location.X, entity.X);
            Assert.AreEqual(structure.Location.Y, entity.Y);
            Assert.AreEqual(structure.StructureNormalOrientation.Value, entity.StructureNormalOrientation);

            Assert.AreEqual(structure.StorageStructureArea.Mean.Value, entity.StorageStructureAreaMean);
            Assert.AreEqual(structure.StorageStructureArea.CoefficientOfVariation.Value, entity.StorageStructureAreaCoefficientOfVariation);
            Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Mean.Value, entity.AllowedLevelIncreaseStorageMean);
            Assert.AreEqual(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value, entity.AllowedLevelIncreaseStorageStandardDeviation);
            Assert.AreEqual(structure.WidthFlowApertures.Mean.Value, entity.WidthFlowAperturesMean);
            Assert.AreEqual(structure.WidthFlowApertures.StandardDeviation.Value, entity.WidthFlowAperturesStandardDeviation);
            Assert.AreEqual(structure.LevelCrestStructureNotClosing.Mean.Value, entity.LevelCrestStructureNotClosingMean);
            Assert.AreEqual(structure.LevelCrestStructureNotClosing.StandardDeviation.Value, entity.LevelCrestStructureNotClosingStandardDeviation);
            Assert.AreEqual(structure.InsideWaterLevel.Mean.Value, entity.InsideWaterLevelMean);
            Assert.AreEqual(structure.InsideWaterLevel.StandardDeviation.Value, entity.InsideWaterLevelStandardDeviation);
            Assert.AreEqual(structure.ThresholdHeightOpenWeir.Mean.Value, entity.ThresholdHeightOpenWeirMean);
            Assert.AreEqual(structure.ThresholdHeightOpenWeir.StandardDeviation.Value, entity.ThresholdHeightOpenWeirStandardDeviation);
            Assert.AreEqual(structure.AreaFlowApertures.Mean.Value, entity.AreaFlowAperturesMean);
            Assert.AreEqual(structure.AreaFlowApertures.StandardDeviation.Value, entity.AreaFlowAperturesStandardDeviation);
            Assert.AreEqual(structure.CriticalOvertoppingDischarge.Mean.Value, entity.CriticalOvertoppingDischargeMean);
            Assert.AreEqual(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value, entity.CriticalOvertoppingDischargeCoefficientOfVariation);
            Assert.AreEqual(structure.FlowWidthAtBottomProtection.Mean.Value, entity.FlowWidthAtBottomProtectionMean);
            Assert.AreEqual(structure.FlowWidthAtBottomProtection.StandardDeviation.Value, entity.FlowWidthAtBottomProtectionStandardDeviation);
            Assert.AreEqual(structure.ProbabilityOpenStructureBeforeFlooding, entity.ProbabilityOpenStructureBeforeFlooding);
            Assert.AreEqual(structure.FailureProbabilityOpenStructure, entity.FailureProbabilityOpenStructure);
            Assert.AreEqual(structure.IdenticalApertures, entity.IdenticalApertures);
            Assert.AreEqual(structure.FailureProbabilityReparation, entity.FailureProbabilityReparation);
            Assert.AreEqual(Convert.ToByte(structure.InflowModelType), entity.InflowModelType);
            Assert.AreEqual(order, entity.Order);

            Assert.IsTrue(registry.Contains(structure));
        }
        public void Create_ForeshoreProfileAlreadyRegistered_ReturnRegisteredEntity()
        {
            // Setup
            var foreshoreProfile = new TestForeshoreProfile();
            var registry         = new PersistenceRegistry();

            ForeshoreProfileEntity entity1 = foreshoreProfile.Create(registry, 0);

            // Precondition:
            Assert.IsTrue(registry.Contains(foreshoreProfile));

            // Call
            ForeshoreProfileEntity entity2 = foreshoreProfile.Create(registry, 0);

            // Assert
            Assert.AreSame(entity1, entity2);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Creates a <see cref="PipingStochasticSoilProfileEntity"/> based on the information of the
        /// <see cref="PipingStochasticSoilProfile"/>.
        /// </summary>
        /// <param name="profile">The profile to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">Index at which this instance resides inside its parent container.</param>
        /// <returns>A new <see cref="PipingStochasticSoilProfileEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static PipingStochasticSoilProfileEntity Create(this PipingStochasticSoilProfile profile,
                                                                 PersistenceRegistry registry,
                                                                 int order)
        {
            var entity = new PipingStochasticSoilProfileEntity
            {
                Probability             = profile.Probability,
                PipingSoilProfileEntity = profile.SoilProfile.Create(registry),
                Order = order
            };

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

            registry.Register(entity, profile);
            return(entity);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates a <see cref="HeightStructureEntity"/> based on the information of the <see cref="HeightStructure"/>.
        /// </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="HeightStructureEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static HeightStructureEntity Create(this HeightStructure structure, PersistenceRegistry registry, int order)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

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

            var entity = new HeightStructureEntity
            {
                Name = structure.Name.DeepClone(),
                Id   = structure.Id.DeepClone(),
                X    = structure.Location.X.ToNaNAsNull(),
                Y    = structure.Location.Y.ToNaNAsNull(),
                StructureNormalOrientation      = structure.StructureNormalOrientation.ToNaNAsNull(),
                AllowedLevelIncreaseStorageMean = structure.AllowedLevelIncreaseStorage.Mean.ToNaNAsNull(),
                AllowedLevelIncreaseStorageStandardDeviation       = structure.AllowedLevelIncreaseStorage.StandardDeviation.ToNaNAsNull(),
                CriticalOvertoppingDischargeMean                   = structure.CriticalOvertoppingDischarge.Mean.ToNaNAsNull(),
                CriticalOvertoppingDischargeCoefficientOfVariation = structure.CriticalOvertoppingDischarge.CoefficientOfVariation.ToNaNAsNull(),
                FailureProbabilityStructureWithErosion             = structure.FailureProbabilityStructureWithErosion.ToNaNAsNull(),
                FlowWidthAtBottomProtectionMean = structure.FlowWidthAtBottomProtection.Mean.ToNaNAsNull(),
                FlowWidthAtBottomProtectionStandardDeviation = structure.FlowWidthAtBottomProtection.StandardDeviation.ToNaNAsNull(),
                LevelCrestStructureMean = structure.LevelCrestStructure.Mean.ToNaNAsNull(),
                LevelCrestStructureStandardDeviation       = structure.LevelCrestStructure.StandardDeviation.ToNaNAsNull(),
                StorageStructureAreaMean                   = structure.StorageStructureArea.Mean.ToNaNAsNull(),
                StorageStructureAreaCoefficientOfVariation = structure.StorageStructureArea.CoefficientOfVariation.ToNaNAsNull(),
                WidthFlowAperturesMean = structure.WidthFlowApertures.Mean.ToNaNAsNull(),
                WidthFlowAperturesStandardDeviation = structure.WidthFlowApertures.StandardDeviation.ToNaNAsNull(),
                Order = order
            };

            registry.Register(entity, structure);

            return(entity);
        }
        public void Create_ValidStructure_ReturnEntity()
        {
            // Setup
            HeightStructure structure = new TestHeightStructure();
            var             registry  = new PersistenceRegistry();

            const int order = 4;

            // Call
            HeightStructureEntity entity = structure.Create(registry, order);

            // Assert
            Assert.AreEqual(structure.Name, entity.Name);
            Assert.AreNotSame(structure.Name, entity.Name);
            Assert.AreEqual(structure.Id, entity.Id);
            Assert.AreNotSame(structure.Id, entity.Id);
            Assert.AreEqual(structure.Location.X, entity.X);
            Assert.AreEqual(structure.Location.Y, entity.Y);
            Assert.AreEqual(structure.StructureNormalOrientation.Value, entity.StructureNormalOrientation);
            Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Mean.Value, entity.AllowedLevelIncreaseStorageMean);
            Assert.AreEqual(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value, entity.AllowedLevelIncreaseStorageStandardDeviation);
            Assert.AreEqual(structure.CriticalOvertoppingDischarge.Mean.Value, entity.CriticalOvertoppingDischargeMean);
            Assert.AreEqual(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value, entity.CriticalOvertoppingDischargeCoefficientOfVariation);
            Assert.AreEqual(structure.FailureProbabilityStructureWithErosion, entity.FailureProbabilityStructureWithErosion);
            Assert.AreEqual(structure.FlowWidthAtBottomProtection.Mean.Value, entity.FlowWidthAtBottomProtectionMean);
            Assert.AreEqual(structure.FlowWidthAtBottomProtection.StandardDeviation.Value, entity.FlowWidthAtBottomProtectionStandardDeviation);
            Assert.AreEqual(structure.LevelCrestStructure.Mean.Value, entity.LevelCrestStructureMean);
            Assert.AreEqual(structure.LevelCrestStructure.StandardDeviation.Value, entity.LevelCrestStructureStandardDeviation);
            Assert.AreEqual(structure.StorageStructureArea.Mean.Value, entity.StorageStructureAreaMean);
            Assert.AreEqual(structure.StorageStructureArea.CoefficientOfVariation.Value, entity.StorageStructureAreaCoefficientOfVariation);
            Assert.AreEqual(structure.WidthFlowApertures.Mean.Value, entity.WidthFlowAperturesMean);
            Assert.AreEqual(structure.WidthFlowApertures.StandardDeviation.Value, entity.WidthFlowAperturesStandardDeviation);
            Assert.AreEqual(order, entity.Order);

            Assert.IsTrue(registry.Contains(structure));
        }
Ejemplo n.º 20
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);
        }
        public void Create_ValidStructure_ReturnEntity()
        {
            // Setup
            StabilityPointStructure structure = new TestStabilityPointStructure();
            var registry = new PersistenceRegistry();

            const int order = 4;

            // Call
            StabilityPointStructureEntity entity = structure.Create(registry, order);

            // Assert
            Assert.AreEqual(structure.Name, entity.Name);
            Assert.AreNotSame(structure.Name, entity.Name);
            Assert.AreEqual(structure.Id, entity.Id);
            Assert.AreNotSame(structure.Id, entity.Id);
            Assert.AreEqual(structure.Location.X, entity.X);
            Assert.AreEqual(structure.Location.Y, entity.Y);
            Assert.AreEqual(structure.StructureNormalOrientation.Value, entity.StructureNormalOrientation);

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

            Assert.IsTrue(registry.Contains(structure));
        }