public void Create_HydraulicBoundaryDatabaseNotLinked_SetsExpectedPropertiesToEntity() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); assessmentSection.SetHydraulicBoundaryLocationCalculations(assessmentSection.HydraulicBoundaryDatabase.Locations); var registry = new PersistenceRegistry(); // Call AssessmentSectionEntity entity = assessmentSection.Create(registry); // Assert CollectionAssert.IsEmpty(entity.HydraulicBoundaryDatabaseEntities); CollectionAssert.IsEmpty(entity.HydraulicLocationEntities); AssertHydraulicLocationCalculationCollectionEntities(assessmentSection, entity); }
public void Create_WithReferenceLine_AddsReferenceLinePointEntities() { // Setup var points = new[] { new Point2D(1, 0), new Point2D(2, 3), new Point2D(5, 3) }; var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); assessmentSection.ReferenceLine.SetGeometry(points); var registry = new PersistenceRegistry(); // Call AssessmentSectionEntity entity = assessmentSection.Create(registry); // Assert string expectedXml = new Point2DCollectionXmlSerializer().ToXml(points); Assert.AreEqual(expectedXml, entity.ReferenceLinePointXml); }
public void Create_WithCollector_ReturnsAssessmentSectionEntityWithCompositionAndFailureMechanisms(AssessmentSectionComposition assessmentSectionComposition) { // Setup const string testId = "testId"; const string testName = "testName"; const string comments = "Some text"; const double maximumAllowableFloodingProbability = 0.05; const double signalFloodingProbability = 0.02; var random = new Random(65); const string mapDataName = "map data name"; const double transparency = 0.3; const bool isVisible = true; const BackgroundDataType backgroundType = BackgroundDataType.Wmts; var normativeProbabilityType = random.NextEnumValue <NormativeProbabilityType>(); IEnumerable <SpecificFailureMechanism> specificFailureMechanisms = Enumerable.Repeat(new SpecificFailureMechanism(), random.Next(1, 10)) .ToArray(); var assessmentSection = new AssessmentSection(assessmentSectionComposition) { Id = testId, Name = testName, Comments = { Body = comments }, FailureMechanismContribution = { MaximumAllowableFloodingProbability = maximumAllowableFloodingProbability, SignalFloodingProbability = signalFloodingProbability, NormativeProbabilityType = normativeProbabilityType }, BackgroundData = { Name = mapDataName, Transparency = (RoundedDouble)transparency, IsVisible = isVisible, Configuration = new WmtsBackgroundDataConfiguration(false,null, null, null) } }; assessmentSection.SpecificFailureMechanisms.AddRange(specificFailureMechanisms); var registry = new PersistenceRegistry(); // Call AssessmentSectionEntity entity = assessmentSection.Create(registry); // Assert Assert.IsNotNull(entity); Assert.AreEqual(Convert.ToByte(assessmentSectionComposition), entity.Composition); Assert.AreEqual(testId, entity.Id); Assert.AreEqual(testName, entity.Name); Assert.AreEqual(comments, entity.Comments); Assert.AreEqual(maximumAllowableFloodingProbability, entity.MaximumAllowableFloodingProbability); Assert.AreEqual(signalFloodingProbability, entity.SignalFloodingProbability); Assert.AreEqual(Convert.ToByte(normativeProbabilityType), entity.NormativeProbabilityType); Assert.AreEqual(15, entity.FailureMechanismEntities.Count); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.Piping)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.GrassRevetmentTopErosionAndInwards)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.MacroStabilityInwards)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.Microstability)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.StabilityStoneRevetment)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.WaveImpactOnAsphaltRevetment)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.WaterOverpressureAsphaltRevetment)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.GrassRevetmentErosionOutwards)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.GrassRevetmentSlidingOutwards)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.GrassRevetmentSlidingInwards)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.StructureHeight)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.ReliabilityClosingOfStructure)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.PipingAtStructure)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.StabilityPointStructures)); Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.DuneErosion)); Assert.AreEqual(assessmentSection.SpecificFailureMechanisms.Count, entity.SpecificFailureMechanismEntities.Count); Assert.IsNull(entity.ReferenceLinePointXml); Assert.AreEqual(1, entity.BackgroundDataEntities.Count); BackgroundDataEntity backgroundDataEntity = entity.BackgroundDataEntities.Single(); Assert.IsNotNull(backgroundDataEntity); Assert.AreEqual(mapDataName, backgroundDataEntity.Name); Assert.AreEqual(transparency, backgroundDataEntity.Transparency); Assert.AreEqual(Convert.ToByte(isVisible), backgroundDataEntity.IsVisible); Assert.AreEqual(Convert.ToByte(backgroundType), backgroundDataEntity.BackgroundDataType); Assert.AreEqual(1, backgroundDataEntity.BackgroundDataMetaEntities.Count); BackgroundDataMetaEntity isConfiguredMetaEntity = backgroundDataEntity.BackgroundDataMetaEntities.Single(); Assert.AreEqual("IsConfigured", isConfiguredMetaEntity.Key); Assert.AreEqual("0", isConfiguredMetaEntity.Value); }
public void Create_HydraulicBoundaryDatabaseLinked_SetsExpectedPropertiesToEntity() { // Setup var random = new Random(21); const string testFilePath = "path"; const string testVersion = "1"; var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { HydraulicBoundaryDatabase = { FilePath = testFilePath, Version = testVersion, Locations = { new HydraulicBoundaryLocation(-1, "name", 1, 2) } }, WaveHeightCalculationsForUserDefinedTargetProbabilities = { new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)), new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)), new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)) }, WaterLevelCalculationsForUserDefinedTargetProbabilities = { new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)), new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1)) } }; assessmentSection.SetHydraulicBoundaryLocationCalculations(assessmentSection.HydraulicBoundaryDatabase.Locations); SetHydraulicBoundaryLocationCalculationInputsOfAssessmentSection(assessmentSection); var registry = new PersistenceRegistry(); // Call AssessmentSectionEntity entity = assessmentSection.Create(registry); // Assert HydraulicBoundaryDatabaseEntity hydraulicBoundaryDatabaseEntity = entity.HydraulicBoundaryDatabaseEntities.Single(); HydraulicBoundaryDatabase hydraulicBoundaryDatabase = assessmentSection.HydraulicBoundaryDatabase; Assert.AreEqual(hydraulicBoundaryDatabase.FilePath, hydraulicBoundaryDatabaseEntity.FilePath); Assert.AreEqual(hydraulicBoundaryDatabase.Version, hydraulicBoundaryDatabaseEntity.Version); HydraulicLocationConfigurationSettings settings = hydraulicBoundaryDatabase.HydraulicLocationConfigurationSettings; Assert.AreEqual(settings.FilePath, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsFilePath); Assert.AreEqual(settings.ScenarioName, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsScenarioName); Assert.AreEqual(settings.Year, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsYear); Assert.AreEqual(settings.Scope, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsScope); Assert.AreEqual(settings.SeaLevel, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsSeaLevel); Assert.AreEqual(settings.RiverDischarge, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsRiverDischarge); Assert.AreEqual(settings.LakeLevel, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsLakeLevel); Assert.AreEqual(settings.WindDirection, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsWindDirection); Assert.AreEqual(settings.WindSpeed, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsWindSpeed); Assert.AreEqual(settings.Comment, hydraulicBoundaryDatabaseEntity.HydraulicLocationConfigurationSettingsComment); int expectedNrOfHydraulicBoundaryLocations = hydraulicBoundaryDatabase.Locations.Count; Assert.AreEqual(expectedNrOfHydraulicBoundaryLocations, entity.HydraulicLocationEntities.Count); AssertHydraulicLocationCalculationCollectionEntities(assessmentSection, entity); }