Fisheye: Tag ef9736bc348f44143fccc4c399825cf7f947599d refers to a dead (removed) revision in file `Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryLocationsExporter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj =================================================================== diff -u -r718ec8557636bd25dc37b11a836af2e6b3829be6 -ref9736bc348f44143fccc4c399825cf7f947599d --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj (.../Ringtoets.HydraRing.IO.csproj) (revision 718ec8557636bd25dc37b11a836af2e6b3829be6) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj (.../Ringtoets.HydraRing.IO.csproj) (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -58,7 +58,6 @@ - Fisheye: Tag ef9736bc348f44143fccc4c399825cf7f947599d refers to a dead (removed) revision in file `Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/HydraulicBoundaryLocationsExporterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/Ringtoets.HydraRing.IO.Test.csproj =================================================================== diff -u -r718ec8557636bd25dc37b11a836af2e6b3829be6 -ref9736bc348f44143fccc4c399825cf7f947599d --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/Ringtoets.HydraRing.IO.Test.csproj (.../Ringtoets.HydraRing.IO.Test.csproj) (revision 718ec8557636bd25dc37b11a836af2e6b3829be6) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/Ringtoets.HydraRing.IO.Test.csproj (.../Ringtoets.HydraRing.IO.Test.csproj) (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -56,7 +56,6 @@ - Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileExporters/HydraulicBoundaryLocationsExporter.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileExporters/HydraulicBoundaryLocationsExporter.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileExporters/HydraulicBoundaryLocationsExporter.cs (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -0,0 +1,75 @@ +// 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.HydraRing.Data; +using Ringtoets.HydraRing.IO; +using Ringtoets.HydraRing.IO.Properties; + +namespace Ringtoets.Integration.Plugin.FileExporters +{ + /// + /// Exports the locations of a and stores them as a shapefile. + /// + public class HydraulicBoundaryLocationsExporter : IFileExporter + { + private static readonly ILog log = LogManager.GetLogger(typeof(HydraulicBoundaryLocationsExporter)); + + private readonly ICollection hydraulicBoundaryLocations; + private readonly string filePath; + + /// + /// Creates a new instance of . + /// + /// The hydraulic boundary locations to export. + /// The path of the file to export to. + /// Thrown when is invalid. + public HydraulicBoundaryLocationsExporter(ICollection hydraulicBoundaryLocations, string filePath) + { + FileUtils.ValidateFilePath(filePath); + + this.hydraulicBoundaryLocations = hydraulicBoundaryLocations; + this.filePath = filePath; + } + + public bool Export() + { + var hydraulicBoundaryLocationsWriter = new HydraulicBoundaryLocationsWriter(); + + try + { + hydraulicBoundaryLocationsWriter.WriteHydraulicBoundaryLocations(hydraulicBoundaryLocations, filePath); + } + catch (CriticalFileWriteException e) + { + log.Error(string.Format(Resources.HydraulicBoundaryLocationsExporter_Error_0_no_HydraulicBoundaryLocations_exported, e.Message)); + return false; + } + + return true; + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj =================================================================== diff -u -rf67a4a5faeca53255e37c31e7eb849e5dd8d54f9 -ref9736bc348f44143fccc4c399825cf7f947599d --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision f67a4a5faeca53255e37c31e7eb849e5dd8d54f9) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -54,6 +54,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs =================================================================== diff -u -r718ec8557636bd25dc37b11a836af2e6b3829be6 -ref9736bc348f44143fccc4c399825cf7f947599d --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 718ec8557636bd25dc37b11a836af2e6b3829be6) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -62,6 +62,7 @@ using Ringtoets.Integration.Forms.PropertyClasses; using Ringtoets.Integration.Forms.Views; using Ringtoets.Integration.Forms.Views.SectionResultViews; +using Ringtoets.Integration.Plugin.FileExporters; using Ringtoets.Integration.Plugin.FileImporters; using Ringtoets.Integration.Plugin.Properties; using Ringtoets.Integration.Service; Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileExporters/HydraulicBoundaryLocationsExporterTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileExporters/HydraulicBoundaryLocationsExporterTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileExporters/HydraulicBoundaryLocationsExporterTest.cs (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -0,0 +1,140 @@ +// 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.Security.AccessControl; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.HydraRing.Data; +using Ringtoets.Integration.Plugin.FileExporters; + +namespace Ringtoets.Integration.Plugin.Test.FileExporters +{ + public class HydraulicBoundaryLocationsExporterTest + { + [Test] + public void ParameteredConstructor_ValidParameters_ExpectedValues() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = 111.111, + WaveHeight = 222.222 + }; + + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); + + // Call + var hydraulicBoundaryLocationsExporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); + + // Assert + Assert.IsInstanceOf(hydraulicBoundaryLocationsExporter); + } + + [Test] + public void ParameteredConstructor_NullFilePath_ThrowArgumentException() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = 111.111, + WaveHeight = 222.222 + }; + + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); + + // Call + TestDelegate call = () => new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, null); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Export_ValidData_ReturnTrue() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = 111.111, + WaveHeight = 222.222 + }; + + string directoryPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, + "Export_ValidData_ReturnTrue"); + Directory.CreateDirectory(directoryPath); + string filePath = Path.Combine(directoryPath, "test.shp"); + + var exporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); + + bool isExported; + try + { + // Call + isExported = exporter.Export(); + } + finally + { + Directory.Delete(directoryPath, true); + } + + // Assert + Assert.IsTrue(isExported); + } + + [Test] + public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + { + DesignWaterLevel = 111.111, + WaveHeight = 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); + + bool isExported = true; + try + { + using (new DirectoryPermissionsRevoker(directoryPath, FileSystemRights.Write)) + { + // Call + isExported = exporter.Export(); + } + } + finally + { + Directory.Delete(directoryPath, true); + } + + // Assert + Assert.IsFalse(isExported); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -r27014b59b58198c1ff843949292fcbe4f60f6916 -ref9736bc348f44143fccc4c399825cf7f947599d --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 27014b59b58198c1ff843949292fcbe4f60f6916) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision ef9736bc348f44143fccc4c399825cf7f947599d) @@ -65,6 +65,7 @@ +