Index: Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsExporter.cs =================================================================== diff -u -r8fa6146e0eb76dc692cc15b9452a022da2b542ff -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsExporter.cs (.../HydraulicBoundaryLocationCalculationsExporter.cs) (revision 8fa6146e0eb76dc692cc15b9452a022da2b542ff) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsExporter.cs (.../HydraulicBoundaryLocationCalculationsExporter.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -39,43 +39,37 @@ private readonly IEnumerable calculations; private readonly string filePath; - private readonly string outputMetaDataHeader; + private readonly HydraulicBoundaryLocationCalculationsType calculationsType; /// /// Creates a new instance of . /// /// The calculations to export. /// The path of the file to export to. - /// - /// Thrown when - /// or is null. + /// The type of calculations. + /// Thrown when is null. /// Thrown when is invalid. public HydraulicBoundaryLocationCalculationsExporter(IEnumerable calculations, - string filePath, string outputMetaDataHeader) + string filePath, HydraulicBoundaryLocationCalculationsType calculationsType) { if (calculations == null) { throw new ArgumentNullException(nameof(calculations)); } - if (outputMetaDataHeader == null) - { - throw new ArgumentNullException(nameof(outputMetaDataHeader)); - } - IOUtils.ValidateFilePath(filePath); this.calculations = calculations; this.filePath = filePath; - this.outputMetaDataHeader = outputMetaDataHeader; + this.calculationsType = calculationsType; } public bool Export() { try { HydraulicBoundaryLocationCalculationsWriter.WriteHydraulicBoundaryLocationCalculations( - calculations, filePath, outputMetaDataHeader); + calculations, filePath, calculationsType); } catch (CriticalFileWriteException e) { Index: Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsWriter.cs =================================================================== diff -u -r69e925ddf2b2feb9e52502ca3dc957b518f0d33d -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsWriter.cs (.../HydraulicBoundaryLocationCalculationsWriter.cs) (revision 69e925ddf2b2feb9e52502ca3dc957b518f0d33d) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Exporters/HydraulicBoundaryLocationCalculationsWriter.cs (.../HydraulicBoundaryLocationCalculationsWriter.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -27,6 +27,7 @@ using Core.Components.Gis.IO.Writers; using Riskeer.Common.Data.Hydraulics; using Riskeer.Common.Util; +using Riskeer.Integration.IO.Properties; namespace Riskeer.Integration.IO.Exporters { @@ -41,13 +42,13 @@ /// /// The hydraulic boundary locations calculations to be written to file. /// The path to the shapefile. - /// The header to use for the meta data. + /// The type of calculations. /// Thrown when or /// is null. /// Thrown when is invalid. /// Thrown when the shapefile cannot be written. public static void WriteHydraulicBoundaryLocationCalculations(IEnumerable calculations, - string filePath, string metaDataHeader) + string filePath, HydraulicBoundaryLocationCalculationsType calculationsType) { if (calculations == null) { @@ -59,23 +60,23 @@ throw new ArgumentNullException(nameof(filePath)); } - if (metaDataHeader == null) - { - throw new ArgumentNullException(nameof(metaDataHeader)); - } - var pointShapeFileWriter = new PointShapeFileWriter(); - foreach (MapPointData mapDataLocation in calculations.Select(c => CreateCalculationData(c, metaDataHeader))) + foreach (MapPointData mapDataLocation in calculations.Select(c => CreateCalculationData(c, calculationsType))) { pointShapeFileWriter.CopyToFeature(mapDataLocation); } pointShapeFileWriter.SaveAs(filePath); } - private static MapPointData CreateCalculationData(HydraulicBoundaryLocationCalculation calculation, string metaDataHeader) + 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[] Index: Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rc36b47c2e1e8cf948767cca33f80ad735f370ad0 -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c36b47c2e1e8cf948767cca33f80ad735f370ad0) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -196,6 +196,26 @@ } /// + /// Looks up a localized string similar to h. + /// + internal static string HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaterLevel_DisplayName { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaterLevel_" + + "DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hs. + /// + internal static string HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaveHeight_DisplayName { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationCalculationsWriter_WaterLevelCalculationType_WaveHeight_" + + "DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to {0} ///Er is geen HLCD geïmporteerd.. /// Index: Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx =================================================================== diff -u -r9a63a368f95026b1b89f4c46d44c651d8e938a37 -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision 9a63a368f95026b1b89f4c46d44c651d8e938a37) +++ Riskeer/Integration/src/Riskeer.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -197,4 +197,10 @@ Het bijbehorende preprocessor closure bestand is niet gevonden in dezelfde map als het HLCD bestand. + + h + + + Hs + \ No newline at end of file Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r8b6d97341faa438655fd58d8bab819d9c7adb9de -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8b6d97341faa438655fd58d8bab819d9c7adb9de) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -427,24 +427,6 @@ } /// - /// Looks up a localized string similar to h. - /// - public static string MetaData_WaterLevelCalculation { - get { - return ResourceManager.GetString("MetaData_WaterLevelCalculation", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Hs. - /// - public static string MetaData_WaveHeight { - get { - return ResourceManager.GetString("MetaData_WaveHeight", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Na het importeren van een aangepaste ligging van de referentielijn zullen alle geïmporteerde en berekende gegevens van alle toetssporen worden gewist. /// ///Wilt u doorgaan?. Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.resx =================================================================== diff -u -r8b6d97341faa438655fd58d8bab819d9c7adb9de -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 8b6d97341faa438655fd58d8bab819d9c7adb9de) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -292,10 +292,4 @@ Weet u zeker dat u wilt doorgaan? - - h - - - Hs - \ No newline at end of file Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r852180bf875d11a6c2ca28380c5b9132d39d8207 -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 852180bf875d11a6c2ca28380c5b9132d39d8207) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -748,9 +748,9 @@ }; yield return CreateHydraulicBoundaryLocationCalculationsForTargetProbabilityExportInfo< - WaterLevelCalculationsForUserDefinedTargetProbabilityContext>(Resources.MetaData_WaterLevelCalculation); + WaterLevelCalculationsForUserDefinedTargetProbabilityContext>(HydraulicBoundaryLocationCalculationsType.WaterLevel); yield return CreateHydraulicBoundaryLocationCalculationsForTargetProbabilityExportInfo< - WaveHeightCalculationsForUserDefinedTargetProbabilityContext>(Resources.MetaData_WaveHeight); + WaveHeightCalculationsForUserDefinedTargetProbabilityContext>(HydraulicBoundaryLocationCalculationsType.WaveHeight); } public override IEnumerable GetUpdateInfos() @@ -1165,15 +1165,15 @@ }; } - private ExportInfo CreateHydraulicBoundaryLocationCalculationsForTargetProbabilityExportInfo(string metaDataHeader) + private ExportInfo CreateHydraulicBoundaryLocationCalculationsForTargetProbabilityExportInfo(HydraulicBoundaryLocationCalculationsType calculationsType) where T : HydraulicBoundaryLocationCalculationsForUserDefinedTargetProbabilityContext { return new ExportInfo { Name = RiskeerCommonDataResources.HydraulicBoundaryConditions_DisplayName, Extension = RiskeerCommonIOResources.Shape_file_filter_Extension, CreateFileExporter = (context, filePath) => new HydraulicBoundaryLocationCalculationsExporter( - context.WrappedData.HydraulicBoundaryLocationCalculations, filePath, metaDataHeader), + context.WrappedData.HydraulicBoundaryLocationCalculations, filePath, calculationsType), IsEnabled = context => true, GetExportPath = () => ExportHelper.GetFilePath(GetInquiryHelper(), new FileFilterGenerator(RiskeerCommonIOResources.Shape_file_filter_Extension, RiskeerCommonIOResources.Shape_file_filter_Description)) Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsExporterTest.cs =================================================================== diff -u -r8fa6146e0eb76dc692cc15b9452a022da2b542ff -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsExporterTest.cs (.../HydraulicBoundaryLocationCalculationsExporterTest.cs) (revision 8fa6146e0eb76dc692cc15b9452a022da2b542ff) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsExporterTest.cs (.../HydraulicBoundaryLocationCalculationsExporterTest.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -39,31 +39,19 @@ public void Constructor_CalculationsNull_ThrowsArgumentNullException() { // Call - void Call() => new HydraulicBoundaryLocationCalculationsExporter(null, string.Empty, string.Empty); + void Call() => new HydraulicBoundaryLocationCalculationsExporter(null, string.Empty, HydraulicBoundaryLocationCalculationsType.WaterLevel); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("calculations", exception.ParamName); } [Test] - public void Constructor_OutputMetaDataHeaderNull_ThrowsArgumentNullException() - { - // Call - void Call() => new HydraulicBoundaryLocationCalculationsExporter( - Enumerable.Empty(), string.Empty, null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("outputMetaDataHeader", exception.ParamName); - } - - [Test] public void Constructor_FilePathNull_ThrowsArgumentException() { // Call void Call() => new HydraulicBoundaryLocationCalculationsExporter( - Enumerable.Empty(), null, string.Empty); + Enumerable.Empty(), null, HydraulicBoundaryLocationCalculationsType.WaterLevel); // Assert Assert.Throws(Call); @@ -77,14 +65,17 @@ // Call var exporter = new HydraulicBoundaryLocationCalculationsExporter( - Enumerable.Empty(), filePath, string.Empty); + Enumerable.Empty(), filePath, HydraulicBoundaryLocationCalculationsType.WaterLevel); // Assert Assert.IsInstanceOf(exporter); } [Test] - public void Export_ValidData_ReturnsTrueAndWritesCorrectData() + [TestCase(HydraulicBoundaryLocationCalculationsType.WaterLevel, "ExpectedWaterLevelExport")] + [TestCase(HydraulicBoundaryLocationCalculationsType.WaveHeight, "ExpectedWaveHeightExport")] + public void Export_ValidData_ReturnsTrueAndWritesCorrectData(HydraulicBoundaryLocationCalculationsType calculationsType, + string expectedExportFileName) { // Setup const string fileName = "test"; @@ -96,7 +87,7 @@ var exporter = new HydraulicBoundaryLocationCalculationsExporter(new[] { new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2)) - }, filePath, "Waterlevel"); + }, filePath, calculationsType); // Precondition FileTestHelper.AssertEssentialShapefilesExist(directoryPath, fileName, false); @@ -112,7 +103,7 @@ directoryPath, fileName, Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.IO), nameof(HydraulicBoundaryLocationCalculationsExporter)), - "ExpectedExport", 28, 8, 628); + expectedExportFileName, 28, 8, 628); Assert.IsTrue(isExported); } finally @@ -134,7 +125,7 @@ var exporter = new HydraulicBoundaryLocationCalculationsExporter(new[] { new HydraulicBoundaryLocationCalculation(new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2)) - }, filePath, "Waterlevel"); + }, filePath, HydraulicBoundaryLocationCalculationsType.WaterLevel); try { Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsWriterTest.cs =================================================================== diff -u -r69e925ddf2b2feb9e52502ca3dc957b518f0d33d -r129bee0491f9f29f4cd10662d812d1b541502129 --- Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsWriterTest.cs (.../HydraulicBoundaryLocationCalculationsWriterTest.cs) (revision 69e925ddf2b2feb9e52502ca3dc957b518f0d33d) +++ Riskeer/Integration/test/Riskeer.Integration.IO.Test/Exporters/HydraulicBoundaryLocationCalculationsWriterTest.cs (.../HydraulicBoundaryLocationCalculationsWriterTest.cs) (revision 129bee0491f9f29f4cd10662d812d1b541502129) @@ -39,7 +39,7 @@ { // Call void Call() => HydraulicBoundaryLocationCalculationsWriter.WriteHydraulicBoundaryLocationCalculations( - null, string.Empty, string.Empty); + null, string.Empty, HydraulicBoundaryLocationCalculationsType.WaterLevel); // Assert var exception = Assert.Throws(Call); @@ -51,32 +51,21 @@ { // Call void Call() => HydraulicBoundaryLocationCalculationsWriter.WriteHydraulicBoundaryLocationCalculations( - Enumerable.Empty(), null, string.Empty); + Enumerable.Empty(), null, HydraulicBoundaryLocationCalculationsType.WaterLevel); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("filePath", exception.ParamName); } [Test] - public void WriteHydraulicBoundaryLocationCalculations_MetaDataHeaderNull_ThrowsArgumentNullException() + [TestCase(HydraulicBoundaryLocationCalculationsType.WaterLevel, "ExpectedWaterLevelExport")] + [TestCase(HydraulicBoundaryLocationCalculationsType.WaveHeight, "ExpectedWaveHeightExport")] + public void WriteHydraulicBoundaryLocationCalculations_ValidData_WritesShapeFile(HydraulicBoundaryLocationCalculationsType calculationsType, + string expectedExportFileName) { - // Call - void Call() => HydraulicBoundaryLocationCalculationsWriter.WriteHydraulicBoundaryLocationCalculations( - Enumerable.Empty(), string.Empty, null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("metaDataHeader", exception.ParamName); - } - - [Test] - [SetCulture("nl-NL")] - public void WriteHydraulicBoundaryLocationCalculations_ValidData_WritesShapeFile() - { // Setup const string fileName = "test"; - const string metaDataHeader = "header"; string directoryPath = TestHelper.GetScratchPadPath(nameof(WriteHydraulicBoundaryLocationCalculations_ValidData_WritesShapeFile)); string filePath = Path.Combine(directoryPath, $"{fileName}.shp"); @@ -94,15 +83,15 @@ HydraulicBoundaryLocationCalculationsWriter.WriteHydraulicBoundaryLocationCalculations(new[] { calculation - }, filePath, metaDataHeader); + }, filePath, calculationsType); // Assert FileTestHelper.AssertEssentialShapefilesExist(directoryPath, fileName, true); FileTestHelper.AssertEssentialShapefileMd5Hashes( directoryPath, fileName, Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.IO), nameof(HydraulicBoundaryLocationCalculationsWriter)), - "ExpectedExport", 28, 8, 628); + expectedExportFileName, 28, 8, 628); } finally { Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedExport.dbf =================================================================== diff -u -r8fa6146e0eb76dc692cc15b9452a022da2b542ff -r129bee0491f9f29f4cd10662d812d1b541502129 Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedExport.shp =================================================================== diff -u -r8fa6146e0eb76dc692cc15b9452a022da2b542ff -r129bee0491f9f29f4cd10662d812d1b541502129 Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedExport.shx =================================================================== diff -u -r8fa6146e0eb76dc692cc15b9452a022da2b542ff -r129bee0491f9f29f4cd10662d812d1b541502129 Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedWaterLevelExport.dbf =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedWaterLevelExport.shp =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedWaterLevelExport.shx =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedWaveHeightExport.dbf =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedWaveHeightExport.shp =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsExporter/ExpectedWaveHeightExport.shx =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedExport.dbf =================================================================== diff -u -r69e925ddf2b2feb9e52502ca3dc957b518f0d33d -r129bee0491f9f29f4cd10662d812d1b541502129 Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedExport.shp =================================================================== diff -u -r69e925ddf2b2feb9e52502ca3dc957b518f0d33d -r129bee0491f9f29f4cd10662d812d1b541502129 Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedExport.shx =================================================================== diff -u -r69e925ddf2b2feb9e52502ca3dc957b518f0d33d -r129bee0491f9f29f4cd10662d812d1b541502129 Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedWaterLevelExport.dbf =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedWaterLevelExport.shp =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedWaterLevelExport.shx =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedWaveHeightExport.dbf =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedWaveHeightExport.shp =================================================================== diff -u Binary files differ Index: Riskeer/Integration/test/Riskeer.Integration.IO.Test/test-data/HydraulicBoundaryLocationCalculationsWriter/ExpectedWaveHeightExport.shx =================================================================== diff -u Binary files differ