Ejemplo n.º 1
0
        public void CreateHydraulicBoundaryLocationFeatures_WithLocations_ReturnsLocationFeaturesCollection(bool setOutput)
        {
            // Setup
            var assessmentSection = new AssessmentSectionStub();

            assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
            {
                new HydraulicBoundaryLocation(1, "location1", 1, 1),
                new HydraulicBoundaryLocation(2, "location2", 2, 2)
            }, setOutput);

            Dictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string> waterLevels =
                assessmentSection.WaterLevelCalculationsForUserDefinedTargetProbabilities.ToDictionary(
                    tp => (IObservableEnumerable <HydraulicBoundaryLocationCalculation>)tp.HydraulicBoundaryLocationCalculations,
                    tp => $"h - {ProbabilityFormattingHelper.Format(tp.TargetProbability)}");

            waterLevels.Add(assessmentSection.WaterLevelCalculationsForMaximumAllowableFloodingProbability, "h - 1/30.000");
            waterLevels.Add(assessmentSection.WaterLevelCalculationsForSignalFloodingProbability, "h - 1/30.000 (1)");

            IEnumerable <AggregatedHydraulicBoundaryLocation> locations = AggregatedHydraulicBoundaryLocationFactory.CreateAggregatedHydraulicBoundaryLocations(
                assessmentSection.HydraulicBoundaryDatabase.Locations,
                waterLevels,
                assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities.ToDictionary(
                    tp => (IObservableEnumerable <HydraulicBoundaryLocationCalculation>)tp.HydraulicBoundaryLocationCalculations,
                    tp => $"Hs - {ProbabilityFormattingHelper.Format(tp.TargetProbability)}"));

            // Call
            IEnumerable <MapFeature> features = RiskeerMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(locations);

            // Assert
            MapFeaturesTestHelper.AssertHydraulicBoundaryFeaturesData(assessmentSection, features);
        }
Ejemplo n.º 2
0
        public void CreateAggregatedHydraulicBoundaryLocations_WaterLevelCalculationsNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => AggregatedHydraulicBoundaryLocationFactory.CreateAggregatedHydraulicBoundaryLocations(
                Enumerable.Empty <HydraulicBoundaryLocation>(), null,
                new Dictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string>());

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("waterLevelCalculations", exception.ParamName);
        }
        private void SetFeatures()
        {
            IReadOnlyDictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string> waterLevelCalculations  = GetWaterLevelCalculations();
            IReadOnlyDictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string> waveHeightsCalculations = GetWaveHeightCalculations();

            IEnumerable <AggregatedHydraulicBoundaryLocation> newLocations = AggregatedHydraulicBoundaryLocationFactory.CreateAggregatedHydraulicBoundaryLocations(
                assessmentSection.HydraulicBoundaryDatabase.Locations, waterLevelCalculations, waveHeightsCalculations);

            MapData.Features = RiskeerMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeatures(newLocations);

            if (MapData.Features.Any())
            {
                UpdateMetaData(waterLevelCalculations, waveHeightsCalculations);
            }
        }
Ejemplo n.º 4
0
        public void CreateAggregatedHydraulicBoundaryLocations_WithAllData_ReturnAggregatedHydraulicBoundaryLocations()
        {
            // Setup
            var random    = new Random(21);
            var locations = new[]
            {
                new HydraulicBoundaryLocation(1, "location1", 1, 1),
                new HydraulicBoundaryLocation(2, "location2", 2, 2)
            };

            var waterLevelCalculations = new Dictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string>
            {
                {
                    new ObservableList <HydraulicBoundaryLocationCalculation>
                    {
                        new HydraulicBoundaryLocationCalculation(locations[0])
                        {
                            Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
                        },
                        new HydraulicBoundaryLocationCalculation(locations[1])
                        {
                            Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
                        }
                    },
                    "1/10"
                },
                {
                    new ObservableList <HydraulicBoundaryLocationCalculation>
                    {
                        new HydraulicBoundaryLocationCalculation(locations[0])
                        {
                            Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
                        },
                        new HydraulicBoundaryLocationCalculation(locations[1])
                    },
                    "1/100"
                }
            };
            var waveHeightCalculations = new Dictionary <IObservableEnumerable <HydraulicBoundaryLocationCalculation>, string>
            {
                {
                    new ObservableList <HydraulicBoundaryLocationCalculation>
                    {
                        new HydraulicBoundaryLocationCalculation(locations[0]),
                        new HydraulicBoundaryLocationCalculation(locations[1])
                        {
                            Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble())
                        }
                    },
                    "1/200"
                }
            };

            // Call
            IEnumerable <AggregatedHydraulicBoundaryLocation> aggregatedLocations = AggregatedHydraulicBoundaryLocationFactory.CreateAggregatedHydraulicBoundaryLocations(
                locations, waterLevelCalculations, waveHeightCalculations);

            // Assert
            Assert.AreEqual(locations.Length, aggregatedLocations.Count());

            for (var i = 0; i < locations.Length; i++)
            {
                AggregatedHydraulicBoundaryLocation aggregatedLocation = aggregatedLocations.ElementAt(i);

                Assert.AreEqual(locations[i].Id, aggregatedLocation.Id);
                Assert.AreEqual(locations[i].Name, aggregatedLocation.Name);
                Assert.AreEqual(locations[i].Location, aggregatedLocation.Location);

                Assert.AreEqual(waterLevelCalculations.Count, aggregatedLocation.WaterLevelCalculationsForTargetProbabilities.Count());
                Assert.AreEqual(waveHeightCalculations.Count, aggregatedLocation.WaveHeightCalculationsForTargetProbabilities.Count());

                for (var j = 0; j < waterLevelCalculations.Count; j++)
                {
                    Assert.AreEqual(waterLevelCalculations.ElementAt(j).Value, aggregatedLocation.WaterLevelCalculationsForTargetProbabilities.ElementAt(j).Item1);
                    Assert.AreEqual(GetExpectedResult(waterLevelCalculations.ElementAt(j).Key, locations[i]),
                                    aggregatedLocation.WaterLevelCalculationsForTargetProbabilities.ElementAt(j).Item2);
                }

                for (var j = 0; j < waveHeightCalculations.Count; j++)
                {
                    Assert.AreEqual(waveHeightCalculations.ElementAt(j).Value, aggregatedLocation.WaveHeightCalculationsForTargetProbabilities.ElementAt(j).Item1);
                    Assert.AreEqual(GetExpectedResult(waveHeightCalculations.ElementAt(j).Key, locations[i]),
                                    aggregatedLocation.WaveHeightCalculationsForTargetProbabilities.ElementAt(j).Item2);
                }
            }
        }