Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Exporters/GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter.cs
===================================================================
diff -u -r3771373489e1203a02e905ab185c3edfa64443d6 -ra04b22a8d3bc9bf09d5572a99d40e36d70ae9928
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Exporters/GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter.cs) (revision 3771373489e1203a02e905ab185c3edfa64443d6)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Exporters/GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter.cs) (revision a04b22a8d3bc9bf09d5572a99d40e36d70ae9928)
@@ -21,6 +21,7 @@
using System;
using Core.Common.Base.IO;
+using Core.Common.Util;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.GrassCoverErosionOutwards.Data;
@@ -31,15 +32,20 @@
///
public class GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter : IFileExporter
{
+ private readonly string filePath;
+
///
/// Creates a new instance of .
///
/// The failure mechanism to get calculations from.
/// The assessment section to get locations and calculation from.
+ /// The path of the file to export to.
/// Thrown when or
/// is null.
+ /// Thrown when is invalid.
public GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(GrassCoverErosionOutwardsFailureMechanism failureMechanism,
- IAssessmentSection assessmentSection)
+ IAssessmentSection assessmentSection,
+ string filePath)
{
if (failureMechanism == null)
{
@@ -50,6 +56,10 @@
{
throw new ArgumentNullException(nameof(assessmentSection));
}
+
+ IOUtils.ValidateFilePath(filePath);
+
+ this.filePath = filePath;
}
public bool Export()
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj
===================================================================
diff -u -r3771373489e1203a02e905ab185c3edfa64443d6 -ra04b22a8d3bc9bf09d5572a99d40e36d70ae9928
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.csproj) (revision 3771373489e1203a02e905ab185c3edfa64443d6)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.IO/Ringtoets.GrassCoverErosionOutwards.IO.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.csproj) (revision a04b22a8d3bc9bf09d5572a99d40e36d70ae9928)
@@ -32,6 +32,10 @@
Core.Common.IO
False
+
+ {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98}
+ Core.Common.Util
+
{d4200f43-3f72-4f42-af0a-8ced416a38ec}
Ringtoets.Common.Data
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Exporters/GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporterTest.cs
===================================================================
diff -u -r3771373489e1203a02e905ab185c3edfa64443d6 -ra04b22a8d3bc9bf09d5572a99d40e36d70ae9928
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Exporters/GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporterTest.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporterTest.cs) (revision 3771373489e1203a02e905ab185c3edfa64443d6)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Exporters/GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporterTest.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporterTest.cs) (revision a04b22a8d3bc9bf09d5572a99d40e36d70ae9928)
@@ -20,7 +20,9 @@
// All rights reserved.
using System;
+using System.IO;
using Core.Common.Base.IO;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
@@ -40,8 +42,11 @@
var assessmentSection = mocks.Stub();
mocks.ReplayAll();
+ string filePath = TestHelper.GetScratchPadPath(Path.Combine("export", "test.shp"));
+
// Call
- TestDelegate call = () => new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(null, assessmentSection);
+ TestDelegate call = () => new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(
+ null, assessmentSection, filePath);
// Assert
var exception = Assert.Throws(call);
@@ -52,27 +57,51 @@
[Test]
public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
{
+ // Setup
+ string filePath = TestHelper.GetScratchPadPath(Path.Combine("export", "test.shp"));
+
// Call
- TestDelegate call = () => new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(new GrassCoverErosionOutwardsFailureMechanism(), null);
+ TestDelegate call = () => new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(
+ new GrassCoverErosionOutwardsFailureMechanism(), null, filePath);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("assessmentSection", exception.ParamName);
}
[Test]
+ public void Constructor_FilePathNull_ThrowArgumentException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(
+ new GrassCoverErosionOutwardsFailureMechanism(), assessmentSection, null);
+
+ // Assert
+ Assert.Throws(call);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Constructor_ExpectedValues()
{
// Setup
var mocks = new MockRepository();
var assessmentSection = mocks.Stub();
mocks.ReplayAll();
+ string filePath = TestHelper.GetScratchPadPath(Path.Combine("export", "test.shp"));
+
// Call
- var exporter = new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(new GrassCoverErosionOutwardsFailureMechanism(), assessmentSection);
+ var exporter = new GrassCoverErosionOutwardsHydraulicBoundaryLocationsExporter(new GrassCoverErosionOutwardsFailureMechanism(), assessmentSection, filePath);
// Assert
Assert.IsInstanceOf(exporter);
+ mocks.VerifyAll();
}
}
}
\ No newline at end of file