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");
        }
        public void CreateHydraulicBoundaryLocationFeature_LocationNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationFeature(null);

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

            Assert.AreEqual("location", exception.ParamName);
        }
        public void CreateHydraulicBoundaryLocationCalculationFeature_MetaDataHeaderNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature(
                new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation()), null);

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

            Assert.AreEqual("metaDataHeader", exception.ParamName);
        }
        public void AddTargetProbabilityMetaData_TargetProbabilitiesNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(
                new MapFeature(Enumerable.Empty <MapGeometry>()), null, string.Empty);

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

            Assert.AreEqual("targetProbabilities", exception.ParamName);
        }
        public void AddTargetProbabilityMetaData_FeatureNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(
                null, Enumerable.Empty <Tuple <double, RoundedDouble> >(), string.Empty);

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

            Assert.AreEqual("feature", exception.ParamName);
        }
        public void AddTargetProbabilityMetaData_DisplayNameFormatNull_ThrowsArgumentNullException()
        {
            // Call
            void Call() => HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(
                new MapFeature(Enumerable.Empty <MapGeometry>()), Enumerable.Empty <Tuple <double, RoundedDouble> >(), null);

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

            Assert.AreEqual("displayNameFormat", exception.ParamName);
        }
Beispiel #7
0
        private static MapPointData CreateCalculationData(HydraulicBoundaryLocationCalculation calculation,
                                                          HydraulicBoundaryLocationCalculationsType calculationsType)
        {
            string metaDataHeader = calculationsType == HydraulicBoundaryLocationCalculationsType.WaterLevel
                                        ? Resources.HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaterLevel_DisplayName
                                        : Resources.HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaveHeight_DisplayName;

            return(new MapPointData(calculation.HydraulicBoundaryLocation.Name)
            {
                Features = new[]
                {
                    HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature(
                        calculation, metaDataHeader)
                }
            });
        }
Beispiel #8
0
        private static MapFeature CreateDuneLocationFeature(AggregatedDuneLocation location)
        {
            MapFeature feature = RiskeerMapDataFeaturesFactoryHelper.CreateSinglePointMapFeature(location.Location);

            feature.MetaData[RiskeerCommonUtilResources.MetaData_ID]   = location.Id;
            feature.MetaData[RiskeerCommonUtilResources.MetaData_Name] = location.Name;
            feature.MetaData[Resources.MetaData_CoastalAreaId]         = location.CoastalAreaId;
            feature.MetaData[Resources.MetaData_Offset] = location.Offset.ToString(RiskeerDuneErosionDataResources.DuneLocation_Offset_format,
                                                                                   CultureInfo.CurrentCulture);
            feature.MetaData[Resources.MetaData_D50] = location.D50.ToString();

            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, location.WaterLevelCalculationsForTargetProbabilities,
                                                                                         Resources.MetaData_WaterLevel_TargetProbability_0);
            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, location.WaveHeightCalculationsForTargetProbabilities,
                                                                                         Resources.MetaData_WaveHeight_TargetProbability_0);
            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, location.WavePeriodCalculationsForTargetProbabilities,
                                                                                         Resources.MetaData_WavePeriod_TargetProbability_0);

            return(feature);
        }
        public void CreateHydraulicBoundaryLocationCalculationFeature_WithData_ReturnFeature(bool calculationHasOutput)
        {
            // Setup
            const string metaDataHeader = "header";
            var          calculation    = new HydraulicBoundaryLocationCalculation(new TestHydraulicBoundaryLocation("location 1"));

            if (calculationHasOutput)
            {
                calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput();
            }

            // Call
            MapFeature feature = HydraulicBoundaryLocationMapDataFeaturesFactory.CreateHydraulicBoundaryLocationCalculationFeature(
                calculation, metaDataHeader);

            // Assert
            RoundedDouble expectedMetaDataValue = calculationHasOutput
                                                      ? calculation.Output.Result
                                                      : RoundedDouble.NaN;

            MapFeaturesMetaDataTestHelper.AssertMetaData(expectedMetaDataValue.ToString(),
                                                         feature, metaDataHeader);
        }
        public void AddTargetProbabilityMetaData_WithAllData_AddsMetaDataItems()
        {
            // Setup
            const string displayNameFormat = "Test - {0}";

            var random              = new Random(21);
            var feature             = new MapFeature(Enumerable.Empty <MapGeometry>());
            var targetProbabilities = new[]
            {
                new Tuple <double, RoundedDouble>(0.01, random.NextRoundedDouble()),
                new Tuple <double, RoundedDouble>(0.01, RoundedDouble.NaN),
                new Tuple <double, RoundedDouble>(0.0001, random.NextRoundedDouble())
            };

            // Call
            HydraulicBoundaryLocationMapDataFeaturesFactory.AddTargetProbabilityMetaData(feature, targetProbabilities, displayNameFormat);

            // Assert
            Assert.AreEqual(3, feature.MetaData.Count);
            MapFeaturesMetaDataTestHelper.AssertMetaData(targetProbabilities[0].Item2.ToString(), feature, string.Format(displayNameFormat, "1/100"));
            MapFeaturesMetaDataTestHelper.AssertMetaData(targetProbabilities[1].Item2.ToString(), feature, string.Format(displayNameFormat, "1/100 (1)"));
            MapFeaturesMetaDataTestHelper.AssertMetaData(targetProbabilities[2].Item2.ToString(), feature, string.Format(displayNameFormat, "1/10.000"));
        }