Fisheye: Tag 16619bc4d9f84a35b603217d2eaddfe9092783a7 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/HydraulicBoundaryLocationsExporter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.IO/Hydraulics/HydraulicBoundaryLocationsExporter.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Hydraulics/HydraulicBoundaryLocationsExporter.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Hydraulics/HydraulicBoundaryLocationsExporter.cs (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -0,0 +1,98 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base.IO; +using Core.Common.IO.Exceptions; +using Core.Common.Utils; +using log4net; +using Ringtoets.Common.IO.Properties; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.Common.IO.Hydraulics +{ + /// + /// Exports hydraulic boundary locations and stores them as a shapefile. + /// + public class HydraulicBoundaryLocationsExporter : IFileExporter + { + private static readonly ILog log = LogManager.GetLogger(typeof(HydraulicBoundaryLocationsExporter)); + + private readonly IEnumerable hydraulicBoundaryLocations; + private readonly string filePath; + private readonly string designWaterLevelName; + private readonly string waveHeightName; + + /// + /// Creates a new instance of . + /// + /// The hydraulic boundary locations to export. + /// The path of the file to export to. + /// The Dutch name of the content of the + /// property. + /// The Dutch name of the content of the + /// property. + /// Thrown when , + /// or is null. + /// Thrown when is invalid. + public HydraulicBoundaryLocationsExporter(IEnumerable hydraulicBoundaryLocations, + string filePath, string designWaterLevelName, string waveHeightName) + { + if (hydraulicBoundaryLocations == null) + { + throw new ArgumentNullException("hydraulicBoundaryLocations"); + } + if (designWaterLevelName == null) + { + throw new ArgumentNullException("designWaterLevelName"); + } + if (waveHeightName == null) + { + throw new ArgumentNullException("waveHeightName"); + } + + FileUtils.ValidateFilePath(filePath); + + this.hydraulicBoundaryLocations = hydraulicBoundaryLocations; + this.filePath = filePath; + this.designWaterLevelName = designWaterLevelName; + this.waveHeightName = waveHeightName; + } + + public bool Export() + { + var hydraulicBoundaryLocationsWriter = new HydraulicBoundaryLocationsWriter(designWaterLevelName, waveHeightName); + + try + { + hydraulicBoundaryLocationsWriter.WriteHydraulicBoundaryLocations(hydraulicBoundaryLocations, filePath); + } + catch (CriticalFileWriteException e) + { + log.ErrorFormat(Resources.HydraulicBoundaryLocationsExporter_Error_Exception_0_no_HydraulicBoundaryLocations_exported, e.Message); + return false; + } + + return true; + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Hydraulics/HydraulicBoundaryLocationsWriter.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/Hydraulics/HydraulicBoundaryLocationsWriter.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Hydraulics/HydraulicBoundaryLocationsWriter.cs (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -0,0 +1,134 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.IO.Exceptions; +using Core.Components.Gis.Data; +using Core.Components.Gis.Features; +using Core.Components.Gis.Geometries; +using Core.Components.Gis.IO.Writers; +using Ringtoets.Common.IO.Properties; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.Common.IO.Hydraulics +{ + /// + /// Shapefile writer that writes the locations of a collection of as point features. + /// + public class HydraulicBoundaryLocationsWriter + { + private readonly string designWaterLevelName; + private readonly string waveHeightName; + + /// + /// Creates a new instance of . + /// + /// The Dutch name of the content of the + /// property. + /// The Dutch name of the content of the + /// property. + /// Thrown when or + /// is null. + public HydraulicBoundaryLocationsWriter(string designWaterLevelName, string waveHeightName) + { + if (designWaterLevelName == null) + { + throw new ArgumentNullException("designWaterLevelName"); + } + if (waveHeightName == null) + { + throw new ArgumentNullException("waveHeightName"); + } + + this.designWaterLevelName = designWaterLevelName; + this.waveHeightName = waveHeightName; + } + + /// + /// Writes the collection of as point features in a shapefile. + /// + /// The hydraulic boundary locations to be written to file. + /// The path to the shapefile. + /// Thrown when or + /// is null. + /// Thrown when is invalid. + /// Thrown when the shapefile cannot be written. + public void WriteHydraulicBoundaryLocations(IEnumerable hydraulicBoundaryLocations, + string filePath) + { + if (hydraulicBoundaryLocations == null) + { + throw new ArgumentNullException("hydraulicBoundaryLocations"); + } + if (filePath == null) + { + throw new ArgumentNullException("filePath"); + } + + var pointShapeFileWriter = new PointShapeFileWriter(); + + foreach (MapPointData mapPointData in hydraulicBoundaryLocations.Select(CreateMapPointData)) + { + pointShapeFileWriter.CopyToFeature(mapPointData); + } + + pointShapeFileWriter.SaveAs(filePath); + } + + private MapPointData CreateMapPointData(HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + if (hydraulicBoundaryLocation == null) + { + throw new ArgumentNullException("hydraulicBoundaryLocation"); + } + + MapGeometry hydraulicBoundaryLocationGeometry = new MapGeometry( + new List> + { + new[] + { + hydraulicBoundaryLocation.Location + } + }); + + MapFeature mapFeature = new MapFeature(new[] + { + hydraulicBoundaryLocationGeometry + }); + + mapFeature.MetaData.Add(Resources.HydraulicBoundaryLocation_Name, hydraulicBoundaryLocation.Name); + mapFeature.MetaData.Add(Resources.HydraulicBoundaryLocation_Id, hydraulicBoundaryLocation.Id); + mapFeature.MetaData.Add(designWaterLevelName, hydraulicBoundaryLocation.DesignWaterLevel.Value); + mapFeature.MetaData.Add(waveHeightName, hydraulicBoundaryLocation.WaveHeight.Value); + + return new MapPointData(hydraulicBoundaryLocation.Name) + { + Features = new[] + { + mapFeature + } + }; + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rdee01f6d6c15af0cc124816bfe99c7658af8995d -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision dee01f6d6c15af0cc124816bfe99c7658af8995d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -584,6 +584,24 @@ } /// + /// Looks up a localized string similar to ID. + /// + public static string HydraulicBoundaryLocation_Id { + get { + return ResourceManager.GetString("HydraulicBoundaryLocation_Id", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Naam. + /// + public static string HydraulicBoundaryLocation_Name { + get { + return ResourceManager.GetString("HydraulicBoundaryLocation_Name", resourceCulture); + } + } + + /// /// Looks up a localized string similar to {0} Er zijn geen hydraulische randvoorwaarden locaties geëxporteerd.. /// public static string HydraulicBoundaryLocationsExporter_Error_Exception_0_no_HydraulicBoundaryLocations_exported { Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r853f384d81f2125022a669589fc993a7fd1dfe42 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 853f384d81f2125022a669589fc993a7fd1dfe42) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -489,4 +489,10 @@ Voor één of meerdere vakken is geen naam opgegeven. + + Naam + + + ID + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -rffe405e6b0f8b4d10e6be78cf7735c554eb42a93 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision ffe405e6b0f8b4d10e6be78cf7735c554eb42a93) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -72,7 +72,8 @@ - + + Fisheye: Tag 16619bc4d9f84a35b603217d2eaddfe9092783a7 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraulicBoundaryLocationsExporterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Hydraulics/HydraulicBoundaryLocationsExporterTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Hydraulics/HydraulicBoundaryLocationsExporterTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Hydraulics/HydraulicBoundaryLocationsExporterTest.cs (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -0,0 +1,276 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using System.Linq; +using System.Security.AccessControl; +using Core.Common.Base.Data; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO.Hydraulics; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.Common.IO.Test.Hydraulics +{ + public class HydraulicBoundaryLocationsExporterTest + { + [Test] + public void Constructor_ValidParameters_ExpectedValues() + { + // Setup + + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); + + // Call + var hydraulicBoundaryLocationsExporter = new HydraulicBoundaryLocationsExporter(Enumerable.Empty(), filePath, "Toetspeil", "Golfhoogte"); + + // Assert + Assert.IsInstanceOf(hydraulicBoundaryLocationsExporter); + } + + [Test] + public void Constructor_HydraulicBoundaryLocationsNull_ThrowsArgumentNullException() + { + // Setup + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); + + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsExporter(null, filePath, "Toetspeil", "Golfhoogte"); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName); + } + + [Test] + public void Constructor_FilePathNull_ThrowArgumentException() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsExporter(new[] + { + hydraulicBoundaryLocation + }, null, "Toetspeil", "Golfhoogte"); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Constructor_DesignWaterLevelNameNull_ThrowArgumentNullException() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); + + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsExporter(new[] + { + hydraulicBoundaryLocation + }, filePath, null, "Golfhoogte"); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("designWaterLevelName", exception.ParamName); + } + + [Test] + public void Constructor_WaveHeightNameNull_ThrowArgumentNullException() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); + + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsExporter(new[] + { + hydraulicBoundaryLocation + }, filePath, "Toetspeil", null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("waveHeightName", exception.ParamName); + } + + [Test] + public void Export_ValidData_ReturnTrueAndWritesFile() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + string directoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + "Export_ValidData_ReturnTrue"); + Directory.CreateDirectory(directoryPath); + string filePath = Path.Combine(directoryPath, "test.shp"); + var baseName = "test"; + + var exporter = new HydraulicBoundaryLocationsExporter(new[] + { + hydraulicBoundaryLocation + }, filePath, "Toetspeil", "Golfhoogte"); + + bool isExported; + try + { + // Call + isExported = exporter.Export(); + + // Assert + AssertEssentialShapefileExists(directoryPath, baseName, true); + } + finally + { + Directory.Delete(directoryPath, true); + } + + Assert.IsTrue(isExported); + } + + [Test] + public void Export_ValidData_WritesCorrectData() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + string directoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + "Export_ValidData_ReturnTrue"); + Directory.CreateDirectory(directoryPath); + string filePath = Path.Combine(directoryPath, "test.shp"); + var baseName = "test"; + + var exporter = new HydraulicBoundaryLocationsExporter(new[] + { + hydraulicBoundaryLocation + }, filePath, "Toetspeil", "Golfhoogte"); + + // Precondition + AssertEssentialShapefileExists(directoryPath, baseName, false); + + try + { + // Call + exporter.Export(); + + // Assert + AssertEssentialShapefileExists(directoryPath, baseName, true); + AssertEssentialShapefileMd5Hashes(directoryPath, baseName); + } + finally + { + Directory.Delete(directoryPath, true); + } + } + + [Test] + public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + string directoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + "Export_InvalidDirectoryRights_LogErrorAndReturnFalse"); + Directory.CreateDirectory(directoryPath); + string filePath = Path.Combine(directoryPath, "test.shp"); + + var exporter = new HydraulicBoundaryLocationsExporter(new[] + { + hydraulicBoundaryLocation + }, filePath, "Toetspeil", "Golfhoogte"); + + try + { + using (new DirectoryPermissionsRevoker(directoryPath, FileSystemRights.Write)) + { + // Call + bool isExported = true; + Action call = () => isExported = exporter.Export(); + + // Assert + string expectedMessage = string.Format("Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{0}'. " + + "Er zijn geen hydraulische randvoorwaarden locaties ge�xporteerd.", filePath); + TestHelper.AssertLogMessageIsGenerated(call, expectedMessage); + Assert.IsFalse(isExported); + } + } + finally + { + Directory.Delete(directoryPath, true); + } + } + + private static void AssertEssentialShapefileExists(string directoryPath, string baseName, bool shouldExist) + { + string pathName = Path.Combine(directoryPath, baseName); + Assert.AreEqual(shouldExist, File.Exists(pathName + ".shp")); + Assert.AreEqual(shouldExist, File.Exists(pathName + ".shx")); + Assert.AreEqual(shouldExist, File.Exists(pathName + ".dbf")); + } + + private void AssertEssentialShapefileMd5Hashes(string directoryPath, string baseName) + { + string refPathName = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO), "PointShapefileMd5"); + string pathName = Path.Combine(directoryPath, baseName); + + AssertBinaryFileContent(refPathName, pathName, ".shp", 100, 28); + AssertBinaryFileContent(refPathName, pathName, ".shx", 100, 8); + AssertBinaryFileContent(refPathName, pathName, ".dbf", 32, 441); + } + + private static void AssertBinaryFileContent(string refPathName, string pathName, string extension, int headerLength, int bodyLength) + { + var refContent = File.ReadAllBytes(refPathName + extension); + var content = File.ReadAllBytes(pathName + extension); + Assert.AreEqual(headerLength + bodyLength, content.Length); + Assert.AreEqual(refContent.Skip(headerLength).Take(bodyLength), + content.Skip(headerLength).Take(bodyLength)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Hydraulics/HydraulicBoundaryLocationsWriterTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Hydraulics/HydraulicBoundaryLocationsWriterTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Hydraulics/HydraulicBoundaryLocationsWriterTest.cs (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -0,0 +1,154 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.IO; +using System.Linq; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO.Hydraulics; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.Common.IO.Test.Hydraulics +{ + [TestFixture] + public class HydraulicBoundaryLocationsWriterTest + { + [Test] + public void ParameteredConstructor_DesignWaterLevelNameNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsWriter(null, "bName"); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("designWaterLevelName", exception.ParamName); + } + + [Test] + public void ParameteredConstructor_WaveHeightNameNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsWriter("aName", null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("waveHeightName", exception.ParamName); + } + + [Test] + public void WriteHydraulicBoundaryLocations_HydraulicBoundaryLocationsNull_ThrowArgumentNullException() + { + // Setup + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + Path.Combine("WriteHydraulicBoundaryLocations_NullhydraulicBoundaryLocations_ThrowArgumentNullException", + "test.shp")); + + var writer = new HydraulicBoundaryLocationsWriter("aName", "bName"); + + // Call + TestDelegate call = () => writer.WriteHydraulicBoundaryLocations(null, filePath); + + // Assert + Assert.Throws(call); + } + + [Test] + public void WriteHydraulicBoundaryLocations_FilePathNull_ThrowArgumentNullException() + { + // Setup + var writer = new HydraulicBoundaryLocationsWriter("aName", "bName"); + + // Call + TestDelegate call = () => writer.WriteHydraulicBoundaryLocations(Enumerable.Empty(), null); + + // Assert + Assert.Throws(call); + } + + [Test] + public void WriteHydraulicBoundaryLocations_ValidData_WritesShapeFile() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = (RoundedDouble) 111.111, + WaveHeight = (RoundedDouble) 222.222 + }; + + string directoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + "WriteHydraulicBoundaryLocations_ValidData_WritesShapeFile"); + Directory.CreateDirectory(directoryPath); + string filePath = Path.Combine(directoryPath, "test.shp"); + var baseName = "test"; + + var writer = new HydraulicBoundaryLocationsWriter("Toetspeil", "Golfhoogte"); + + // Precondition + AssertEssentialShapefileExists(directoryPath, baseName, false); + + try + { + // Call + writer.WriteHydraulicBoundaryLocations(new[] + { + hydraulicBoundaryLocation + }, filePath); + + // Assert + AssertEssentialShapefileExists(directoryPath, baseName, true); + AssertEssentialShapefileMd5Hashes(directoryPath, baseName); + } + finally + { + Directory.Delete(directoryPath, true); + } + } + + private static void AssertEssentialShapefileExists(string directoryPath, string baseName, bool shouldExist) + { + string pathName = Path.Combine(directoryPath, baseName); + Assert.AreEqual(shouldExist, File.Exists(pathName + ".shp")); + Assert.AreEqual(shouldExist, File.Exists(pathName + ".shx")); + Assert.AreEqual(shouldExist, File.Exists(pathName + ".dbf")); + } + + private void AssertEssentialShapefileMd5Hashes(string directoryPath, string baseName) + { + string refPathName = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO), "PointShapefileMd5"); + string pathName = Path.Combine(directoryPath, baseName); + + AssertBinaryFileContent(refPathName, pathName, ".shp", 100, 28); + AssertBinaryFileContent(refPathName, pathName, ".shx", 100, 8); + AssertBinaryFileContent(refPathName, pathName, ".dbf", 32, 441); + } + + private static void AssertBinaryFileContent(string refPathName, string pathName, string extension, int headerLength, int bodyLength) + { + var refContent = File.ReadAllBytes(refPathName + extension); + var content = File.ReadAllBytes(pathName + extension); + Assert.AreEqual(headerLength + bodyLength, content.Length); + Assert.AreEqual(refContent.Skip(headerLength).Take(bodyLength), + content.Skip(headerLength).Take(bodyLength)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -rffe405e6b0f8b4d10e6be78cf7735c554eb42a93 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision ffe405e6b0f8b4d10e6be78cf7735c554eb42a93) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -68,7 +68,8 @@ - + + Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r4af9b44a7b9bea4035396ef522fe83c4cdd6f398 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 4af9b44a7b9bea4035396ef522fe83c4cdd6f398) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -39,7 +39,7 @@ using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; -using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Hydraulics; using Ringtoets.Common.Service; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms; Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs =================================================================== diff -u -r4af9b44a7b9bea4035396ef522fe83c4cdd6f398 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs (.../HydraulicBoundariesGroupContextExportInfoTest.cs) (revision 4af9b44a7b9bea4035396ef522fe83c4cdd6f398) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/ExportInfos/HydraulicBoundariesGroupContextExportInfoTest.cs (.../HydraulicBoundariesGroupContextExportInfoTest.cs) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -27,7 +27,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Hydraulics; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionOutwards.IO; Fisheye: Tag 16619bc4d9f84a35b603217d2eaddfe9092783a7 refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryLocationsWriter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r7d6e4c28a40fb056c182d0691dda2b2e88aeebfd -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7d6e4c28a40fb056c182d0691dda2b2e88aeebfd) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -100,24 +100,6 @@ } /// - /// Looks up a localized string similar to ID. - /// - public static string HydraulicBoundaryLocation_Id { - get { - return ResourceManager.GetString("HydraulicBoundaryLocation_Id", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Naam. - /// - public static string HydraulicBoundaryLocation_Name { - get { - return ResourceManager.GetString("HydraulicBoundaryLocation_Name", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Het opgegeven bestandspad ({0}) is niet geldig.. /// public static string HydraulicDatabaseHelper_ValidatePathForCalculation_Invalid_path_0_ { Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.resx =================================================================== diff -u -r7d6e4c28a40fb056c182d0691dda2b2e88aeebfd -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.resx (.../Resources.resx) (revision 7d6e4c28a40fb056c182d0691dda2b2e88aeebfd) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.resx (.../Resources.resx) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -129,12 +129,6 @@ Het bevragen van de database is mislukt. - - Naam - - - ID - Het opgegeven bestandspad ({0}) is niet geldig. Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj =================================================================== diff -u -r02d0e67121f748ae6d69ab9f68643d2f5e62f800 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj (.../Ringtoets.HydraRing.IO.csproj) (revision 02d0e67121f748ae6d69ab9f68643d2f5e62f800) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj (.../Ringtoets.HydraRing.IO.csproj) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -59,7 +59,6 @@ - @@ -92,16 +91,6 @@ Core.Common.Utils False - - {FD264FAD-E6F9-47CC-97CD-770199A8E629} - Core.Components.Gis.IO - False - - - {318BA582-88C9-4816-A54A-A7E431461DE3} - Core.Components.Gis - False - {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} Ringtoets.HydraRing.Data Fisheye: Tag 16619bc4d9f84a35b603217d2eaddfe9092783a7 refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicBoundaryLocationsWriterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/Ringtoets.HydraRing.IO.Test.csproj =================================================================== diff -u -r382a89069b631e11752a6fabf9b80b9274c8503e -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/Ringtoets.HydraRing.IO.Test.csproj (.../Ringtoets.HydraRing.IO.Test.csproj) (revision 382a89069b631e11752a6fabf9b80b9274c8503e) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/Ringtoets.HydraRing.IO.Test.csproj (.../Ringtoets.HydraRing.IO.Test.csproj) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -59,7 +59,6 @@ - @@ -71,10 +70,6 @@ - - {3bbfd65b-b277-4e50-ae6d-bd24c3434609} - Core.Common.Base - {E344867E-9AC9-44C8-88A5-8185681679A9} Core.Common.IO @@ -87,10 +82,6 @@ {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil - - {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} - Ringtoets.HydraRing.Data - {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} Ringtoets.HydraRing.IO Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r4af9b44a7b9bea4035396ef522fe83c4cdd6f398 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 4af9b44a7b9bea4035396ef522fe83c4cdd6f398) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -52,9 +52,9 @@ using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TreeNodeInfos; using Ringtoets.Common.Forms.Views; -using Ringtoets.Common.IO; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.HydraRing; +using Ringtoets.Common.IO.Hydraulics; using Ringtoets.Common.IO.ReferenceLines; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs =================================================================== diff -u -r4af9b44a7b9bea4035396ef522fe83c4cdd6f398 -r16619bc4d9f84a35b603217d2eaddfe9092783a7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs (.../HydraulicBoundaryDatabaseContextExportInfoTest.cs) (revision 4af9b44a7b9bea4035396ef522fe83c4cdd6f398) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/ExportInfos/HydraulicBoundaryDatabaseContextExportInfoTest.cs (.../HydraulicBoundaryDatabaseContextExportInfoTest.cs) (revision 16619bc4d9f84a35b603217d2eaddfe9092783a7) @@ -25,7 +25,7 @@ using NUnit.Framework; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Hydraulics; -using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Hydraulics; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; using Ringtoets.Integration.Forms.PresentationObjects;