public void CreateHydraulicBoundaryLocationFeature_WithLocation_ReturnFeature()
        {
            // Setup
            var random = new Random(39);
            IEnumerable <Tuple <string, RoundedDouble> > waterLevelCalculationForTargetProbabilities = new[]
            {
                new Tuple <string, RoundedDouble>("h - 1/10", random.NextRoundedDouble()),
                new Tuple <string, RoundedDouble>("h - 1/10 (1)", random.NextRoundedDouble())
            };
            IEnumerable <Tuple <string, RoundedDouble> > waveHeightCalculationForTargetProbabilities = new[]
            {
                new Tuple <string, RoundedDouble>("Hs - 1/1.000", random.NextRoundedDouble())
            };
            var location = new AggregatedHydraulicBoundaryLocation(1, "test", new Point2D(0, 0),
                                                                   waterLevelCalculationForTargetProbabilities,
                                                                   waveHeightCalculationForTargetProbabilities);

            // Call
            MapFeature feature = HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeature(location);

            // Assert
            MapFeaturesMetaDataTestHelper.AssertMetaData(location.Id, feature, "ID");
            MapFeaturesMetaDataTestHelper.AssertMetaData(location.Name, feature, "Naam");

            MapFeaturesMetaDataTestHelper.AssertMetaData(location.WaterLevelCalculationsForTargetProbabilities.First().Item2.ToString(), feature, "h - 1/10");
            MapFeaturesMetaDataTestHelper.AssertMetaData(location.WaterLevelCalculationsForTargetProbabilities.Last().Item2.ToString(), feature, "h - 1/10 (1)");
            MapFeaturesMetaDataTestHelper.AssertMetaData(location.WaveHeightCalculationsForTargetProbabilities.First().Item2.ToString(), feature, "Hs - 1/1.000");
        }
        /// <summary>
        /// Creates a hydraulic boundary location feature based on the given <paramref name="location"/>.
        /// </summary>
        /// <param name="location">The location to create the feature for.</param>
        /// <returns>A feature based on the given <paramref name="location"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="location"/> is <c>null</c>.</exception>
        public static MapFeature CreateHydraulicBoundaryLocationFeature(AggregatedHydraulicBoundaryLocation location)
        {
            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            MapFeature feature = RiskeerMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(location.Location);

            feature.MetaData[RiskeerCommonUtilResources.MetaData_ID]   = location.Id;
            feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = location.Name;

            AddTargetProbabilityMetaData(feature, location.WaterLevelCalculationsForTargetProbabilities);

            AddTargetProbabilityMetaData(feature, location.WaveHeightCalculationsForTargetProbabilities);

            return(feature);
        }
        public void Constructor_WithAllData_ExpectedValues()
        {
            // Setup
            const string name = "location";

            var  random   = new Random(39);
            long id       = random.Next();
            var  location = new Point2D(random.NextDouble(), random.NextDouble());
            var  waterLevelCalculationsForTargetProbabilities = new List <Tuple <string, RoundedDouble> >();
            var  waveHeightCalculationsForTargetProbabilities = new List <Tuple <string, RoundedDouble> >();

            // Call
            var aggregatedLocation = new AggregatedHydraulicBoundaryLocation(
                id, name, location, waterLevelCalculationsForTargetProbabilities, waveHeightCalculationsForTargetProbabilities);

            // Assert
            Assert.AreEqual(id, aggregatedLocation.Id);
            Assert.AreEqual(name, aggregatedLocation.Name);
            Assert.AreSame(location, aggregatedLocation.Location);
            Assert.AreSame(waterLevelCalculationsForTargetProbabilities, aggregatedLocation.WaterLevelCalculationsForTargetProbabilities);
            Assert.AreSame(waveHeightCalculationsForTargetProbabilities, aggregatedLocation.WaveHeightCalculationsForTargetProbabilities);
        }
Example #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);
                }
            }
        }