/// <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="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);
        }
Esempio n. 3
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_CalculationWithoutOutput_ReturnsHydraulicLocationCalculationEntity()
        {
            // Setup
            var  random = new Random(33);
            bool shouldIllustrationPointsBeCalculated = random.NextBoolean();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated
                },
                Output = null
            };

            var registry = new PersistenceRegistry();
            var hydraulicLocationEntity = new HydraulicLocationEntity();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(Convert.ToByte(shouldIllustrationPointsBeCalculated), entity.ShouldIllustrationPointsBeCalculated);
            Assert.IsEmpty(entity.HydraulicLocationOutputEntities);
        }
        /// <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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public void Create_WithValidCollection_ReturnsEntityWithExpectedResults()
        {
            // Setup
            var random = new Random(21);
            int order  = random.Next();

            var duneLocation = new TestDuneLocation();
            var calculation  = new DuneLocationCalculation(duneLocation);

            var calculations = new DuneLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1))
            {
                DuneLocationCalculations =
                {
                    calculation
                }
            };

            var duneLocationEntity = new DuneLocationEntity();
            var registry           = new PersistenceRegistry();

            registry.Register(duneLocationEntity, duneLocation);

            // Call
            DuneLocationCalculationForTargetProbabilityCollectionEntity entity = calculations.Create(order, registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(calculations.TargetProbability, entity.TargetProbability);

            DuneLocationCalculationEntity duneLocationCalculationEntity = entity.DuneLocationCalculationEntities.Single();

            Assert.AreSame(duneLocationEntity, duneLocationCalculationEntity.DuneLocationEntity);
            CollectionAssert.IsEmpty(duneLocationCalculationEntity.DuneLocationCalculationOutputEntities);
        }
        public void Create_CalculationWithAlreadyRegisteredStochasticSoilProfile_ReturnsEntityWithStochasticSoilModelEntity()
        {
            // Setup
            var random = new Random(21);
            var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(random.NextDouble(),
                                                                                       MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D());
            var scenario = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    StochasticSoilProfile = stochasticSoilProfile
                }
            };

            var registry = new PersistenceRegistry();
            var stochasticSoilProfileEntity = new MacroStabilityInwardsStochasticSoilProfileEntity();

            registry.Register(stochasticSoilProfileEntity, stochasticSoilProfile);

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

            // Assert
            Assert.IsNotNull(entity);
            MacroStabilityInwardsStochasticSoilProfileEntity expectedStochasticSoilProfileEntity = registry.Get(stochasticSoilProfile);

            Assert.AreSame(expectedStochasticSoilProfileEntity, entity.MacroStabilityInwardsStochasticSoilProfileEntity);
        }
        /// <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);
        }
Esempio n. 12
0
        public void Create_WithDuneLocations_ReturnsEntityWithDuneLocations()
        {
            // Setup
            var duneLocation     = new TestDuneLocation();
            var failureMechanism = new DuneErosionFailureMechanism
            {
                DuneLocationCalculationsForUserDefinedTargetProbabilities =
                {
                    new DuneLocationCalculationsForTargetProbability(0.1),
                    new DuneLocationCalculationsForTargetProbability(0.01)
                }
            };

            failureMechanism.SetDuneLocations(new[]
            {
                duneLocation
            });

            var duneLocationEntity = new DuneLocationEntity();
            var registry           = new PersistenceRegistry();

            registry.Register(duneLocationEntity, duneLocation);

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

            // Assert
            DuneLocationEntity actualDuneLocationEntity = entity.DuneLocationEntities.Single();

            Assert.AreSame(duneLocationEntity, actualDuneLocationEntity);

            DuneErosionFailureMechanismMetaEntity metaEntity = entity.DuneErosionFailureMechanismMetaEntities.Single();

            AssertDuneLocationCalculationCollectionEntities(failureMechanism, metaEntity);
        }
Esempio n. 13
0
        public void Create_HasHydraulicLocationCalculationsForTargetProbability_EntityHasHydraulicLocationCalculationForTargetProbabilityCollectionEntity()
        {
            // Setup
            var random = new Random(21);
            var hydraulicCalculations       = new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1));
            var hydraulicCalculationsEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity();

            var registry = new PersistenceRegistry();

            registry.Register(hydraulicCalculationsEntity, hydraulicCalculations);

            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                InputParameters =
                {
                    CalculationsTargetProbability = hydraulicCalculations
                }
            };

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

            // Assert
            Assert.AreSame(hydraulicCalculationsEntity, entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity);
        }
        /// <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. 15
0
        public void Create_StructureAlreadyRegistered_ReturnRegisteredEntity()
        {
            // Setup
            ClosingStructure structure = new TestClosingStructure();

            var registeredEntity = new ClosingStructureEntity();
            var registry         = new PersistenceRegistry();

            registry.Register(registeredEntity, structure);

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

            // Assert
            Assert.AreSame(registeredEntity, entity);
        }
Esempio n. 16
0
        public void Create_WithValidCollection_ReturnsEntityWithExpectedResults()
        {
            // Setup
            var random          = new Random(21);
            int order           = random.Next();
            var calculationType = random.NextEnumValue <HydraulicBoundaryLocationCalculationType>();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = random.NextBoolean()
                }
            };

            var calculations = new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1))
            {
                HydraulicBoundaryLocationCalculations =
                {
                    calculation
                }
            };

            var hydraulicLocationEntity = new HydraulicLocationEntity();
            var registry = new PersistenceRegistry();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationForTargetProbabilityCollectionEntity entity = calculations.Create(calculationType, order, registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(calculations.TargetProbability, entity.TargetProbability);
            Assert.AreEqual(Convert.ToByte(calculationType), entity.HydraulicBoundaryLocationCalculationType);

            HydraulicLocationCalculationEntity hydraulicLocationCalculationEntity = entity.HydraulicLocationCalculationEntities.Single();

            Assert.AreSame(hydraulicLocationEntity, hydraulicLocationCalculationEntity.HydraulicLocationEntity);
            Assert.AreEqual(Convert.ToByte(calculation.InputParameters.ShouldIllustrationPointsBeCalculated),
                            hydraulicLocationCalculationEntity.ShouldIllustrationPointsBeCalculated);
            CollectionAssert.IsEmpty(hydraulicLocationCalculationEntity.HydraulicLocationOutputEntities);
        }
        public void Create_CalculationWithAlreadyRegisteredDuneLocation_ReturnsEntityWithDuneLocationEntity()
        {
            // Setup
            var duneLocation = new TestDuneLocation();
            var calculation  = new DuneLocationCalculation(duneLocation);

            var registry           = new PersistenceRegistry();
            var duneLocationEntity = new DuneLocationEntity();

            registry.Register(duneLocationEntity, duneLocation);

            // Call
            DuneLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreSame(duneLocationEntity, entity.DuneLocationEntity);
        }
        public void Create_CalculationWithoutOutput_ReturnsDuneLocationCalculationEntity()
        {
            // Setup
            var duneLocation = new TestDuneLocation();
            var calculation  = new DuneLocationCalculation(duneLocation);

            var registry           = new PersistenceRegistry();
            var duneLocationEntity = new DuneLocationEntity();

            registry.Register(duneLocationEntity, duneLocation);

            // Call
            DuneLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            CollectionAssert.IsEmpty(entity.DuneLocationCalculationOutputEntities);
        }
        public void Create_CalculationWithAlreadyCreatedHydraulicBoundaryLocation_ReturnsEntityWithHydraulicBoundaryLocationEntity()
        {
            // Setup
            var hydraulicLocation = new TestHydraulicBoundaryLocation();

            var registry = new PersistenceRegistry();
            var hydraulicLocationEntity = new HydraulicLocationEntity();

            registry.Register(hydraulicLocationEntity, hydraulicLocation);

            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicLocation);

            // Call
            HydraulicLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }
        public void Create_CalculationWithOutput_ReturnsDuneLocationCalculationEntityWithOutput()
        {
            // Setup
            var random = new Random(21);
            var output = new DuneLocationCalculationOutput(random.NextEnumValue <CalculationConvergence>(), new DuneLocationCalculationOutput.ConstructionProperties
            {
                WaterLevel            = random.NextDouble(),
                WaveHeight            = random.NextDouble(),
                WavePeriod            = random.NextDouble(),
                CalculatedProbability = random.NextDouble(),
                CalculatedReliability = random.NextDouble(),
                TargetProbability     = random.NextDouble(),
                TargetReliability     = random.NextDouble()
            });

            var duneLocation = new TestDuneLocation();
            var calculation  = new DuneLocationCalculation(duneLocation)
            {
                Output = output
            };

            var registry           = new PersistenceRegistry();
            var duneLocationEntity = new DuneLocationEntity();

            registry.Register(duneLocationEntity, duneLocation);

            // Call
            DuneLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);

            DuneLocationCalculationOutputEntity outputEntity = entity.DuneLocationCalculationOutputEntities.Single();

            Assert.AreEqual(output.WaterLevel, outputEntity.WaterLevel, output.WaterLevel.GetAccuracy());
            Assert.AreEqual(output.WaveHeight, outputEntity.WaveHeight, output.WaveHeight.GetAccuracy());
            Assert.AreEqual(output.WavePeriod, outputEntity.WavePeriod, output.WavePeriod.GetAccuracy());
            Assert.AreEqual(output.TargetProbability, outputEntity.TargetProbability);
            Assert.AreEqual(output.TargetReliability, outputEntity.TargetReliability, output.TargetReliability.GetAccuracy());
            Assert.AreEqual(output.CalculatedProbability, outputEntity.CalculatedProbability);
            Assert.AreEqual(output.CalculatedReliability, outputEntity.CalculatedReliability, output.CalculatedReliability.GetAccuracy());
            Assert.AreEqual(Convert.ToByte(output.CalculationConvergence), outputEntity.CalculationConvergence);
        }
Esempio n. 21
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);
        }
        public void Create_CalculationWithOutput_ReturnsHydraulicLocationCalculationEntityWithOutput()
        {
            // Setup
            var  random = new Random(33);
            bool shouldIllustrationPointsBeCalculated = random.NextBoolean();

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated
                },
                Output = new HydraulicBoundaryLocationCalculationOutput(
                    random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(),
                    random.NextDouble(), random.NextEnumValue <CalculationConvergence>(),
                    null)
            };

            var registry = new PersistenceRegistry();
            var hydraulicLocationEntity = new HydraulicLocationEntity();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationEntity entity = calculation.Create(registry);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual(Convert.ToByte(shouldIllustrationPointsBeCalculated), entity.ShouldIllustrationPointsBeCalculated);

            HydraulicLocationOutputEntity outputEntity = entity.HydraulicLocationOutputEntities.Single();

            HydraulicBoundaryLocationCalculationOutput expectedOutput = calculation.Output;

            Assert.AreEqual(expectedOutput.CalculatedProbability, outputEntity.CalculatedProbability);
            Assert.AreEqual(expectedOutput.CalculatedReliability, outputEntity.CalculatedReliability);
            Assert.AreEqual(expectedOutput.TargetReliability, outputEntity.TargetReliability);
            Assert.AreEqual(expectedOutput.TargetProbability, outputEntity.TargetProbability);
            Assert.IsNull(outputEntity.GeneralResultSubMechanismIllustrationPointEntity);
            Assert.AreEqual(Convert.ToByte(expectedOutput.CalculationConvergence), outputEntity.CalculationConvergence);
        }
Esempio n. 23
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);
        }
Esempio n. 24
0
        public void Create_CalculationWithAlreadySavedDikeProfile_ReturnEntityWithDikeProfileEntity()
        {
            // Setup
            DikeProfile dikeProfile = DikeProfileTestFactory.CreateDikeProfile();
            var         calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    DikeProfile = dikeProfile
                }
            };

            var dikeProfileEntity = new DikeProfileEntity();
            var registry          = new PersistenceRegistry();

            registry.Register(dikeProfileEntity, dikeProfile);

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

            // Assert
            Assert.AreSame(dikeProfileEntity, entity.DikeProfileEntity);
        }
Esempio n. 25
0
        public void Create_CalculationWithAlreadySavedHydraulicBoundaryLocation_ReturnEntityWithHydraulicLocationEntity()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 1, 1);
            var calculation = new GrassCoverErosionInwardsCalculationScenario
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = hydraulicBoundaryLocation
                }
            };

            var hydraulicLocationEntity = new HydraulicLocationEntity();
            var registry = new PersistenceRegistry();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

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

            // Assert
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }
Esempio n. 26
0
        public void Create_WithValidCollection_ReturnsEntityWithExpectedResults()
        {
            // Setup
            var random = new Random(21);

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
            var calculation = new HydraulicBoundaryLocationCalculation(hydraulicBoundaryLocation)
            {
                InputParameters =
                {
                    ShouldIllustrationPointsBeCalculated = random.NextBoolean()
                }
            };

            var calculationCollection = new ObservableList <HydraulicBoundaryLocationCalculation>
            {
                calculation
            };

            var hydraulicLocationEntity = new HydraulicLocationEntity();
            var registry = new PersistenceRegistry();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            HydraulicLocationCalculationCollectionEntity entity = calculationCollection.Create(registry);

            // Assert
            Assert.IsNotNull(entity);

            HydraulicLocationCalculationEntity hydraulicLocationCalculationEntity = entity.HydraulicLocationCalculationEntities.Single();

            Assert.AreSame(hydraulicLocationEntity, hydraulicLocationCalculationEntity.HydraulicLocationEntity);
            Assert.AreEqual(Convert.ToByte(calculation.InputParameters.ShouldIllustrationPointsBeCalculated),
                            hydraulicLocationCalculationEntity.ShouldIllustrationPointsBeCalculated);
            CollectionAssert.IsEmpty(hydraulicLocationCalculationEntity.HydraulicLocationOutputEntities);
        }
        public void Create_CalculationWithAlreadyRegisteredHydraulicBoundaryLocation_ReturnsEntityWithHydraulicBoundaryLocationEntity()
        {
            // Setup
            var hydraulicLocation = new TestHydraulicBoundaryLocation();
            var scenario          = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = hydraulicLocation
                }
            };

            var registry = new PersistenceRegistry();
            var hydraulicLocationEntity = new HydraulicLocationEntity();

            registry.Register(hydraulicLocationEntity, hydraulicLocation);

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

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }
        public void Create_CalculationWithAlreadyRegisteredSurfaceLine_ReturnsEntityWithSurfaceLineEntity()
        {
            // Setup
            var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty);
            var scenario    = new MacroStabilityInwardsCalculationScenario
            {
                InputParameters =
                {
                    SurfaceLine = surfaceLine
                }
            };

            var registry          = new PersistenceRegistry();
            var surfaceLineEntity = new SurfaceLineEntity();

            registry.Register(surfaceLineEntity, surfaceLine);

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

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreSame(surfaceLineEntity, entity.SurfaceLineEntity);
        }
Esempio n. 29
0
        public void Create_HasHydraulicLocationEntity_EntityHasHydraulicLocationEntity()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 2.3, 4.5);

            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = hydraulicBoundaryLocation
                }
            };

            HydraulicLocationEntity hydraulicLocationEntity = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity();
            var registry = new PersistenceRegistry();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

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

            // Assert
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }
Esempio n. 30
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);
        }