Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.IO/DuneLocationsExporter.cs
===================================================================
diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -rb06f209aeee8d486386e6d6007a51d561cf9593f
--- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.IO/DuneLocationsExporter.cs (.../DuneLocationsExporter.cs) (revision ac96d7c315129af851634ed5a4a6800b59ede718)
+++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.IO/DuneLocationsExporter.cs (.../DuneLocationsExporter.cs) (revision b06f209aeee8d486386e6d6007a51d561cf9593f)
@@ -31,40 +31,40 @@
namespace Ringtoets.DuneErosion.IO
{
///
- /// Exports dune locations and stores them as a bnd file.
+ /// Exports dune location calculations and stores them as a bnd file.
///
public class DuneLocationsExporter : IFileExporter
{
private static readonly ILog log = LogManager.GetLogger(typeof(DuneLocationsExporter));
- private readonly IEnumerable duneLocations;
+ private readonly IEnumerable duneLocationCalculations;
private readonly string filePath;
///
/// Creates a new instance of .
///
- /// The dune locations to export.
+ /// The dune location calculations to export.
/// The path of the file to export to.
- /// Thrown when is null.
+ /// Thrown when is null.
/// Thrown when is invalid.
- public DuneLocationsExporter(IEnumerable duneLocations, string filePath)
+ public DuneLocationsExporter(IEnumerable duneLocationCalculations, string filePath)
{
- if (duneLocations == null)
+ if (duneLocationCalculations == null)
{
- throw new ArgumentNullException(nameof(duneLocations));
+ throw new ArgumentNullException(nameof(duneLocationCalculations));
}
IOUtils.ValidateFilePath(filePath);
- this.duneLocations = duneLocations;
+ this.duneLocationCalculations = duneLocationCalculations;
this.filePath = filePath;
}
public bool Export()
{
try
{
- DuneLocationsWriter.WriteDuneLocations(duneLocations, filePath);
+ DuneLocationsWriter.WriteDuneLocations(duneLocationCalculations, filePath);
}
catch (CriticalFileWriteException e)
{
Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.IO/DuneLocationsWriter.cs
===================================================================
diff -u -r397eafbec8987f6aa2e31318745c4e07ed575981 -rb06f209aeee8d486386e6d6007a51d561cf9593f
--- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.IO/DuneLocationsWriter.cs (.../DuneLocationsWriter.cs) (revision 397eafbec8987f6aa2e31318745c4e07ed575981)
+++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.IO/DuneLocationsWriter.cs (.../DuneLocationsWriter.cs) (revision b06f209aeee8d486386e6d6007a51d561cf9593f)
@@ -43,16 +43,16 @@
///
/// Writes dune locations to a bnd file.
///
- /// The dune locations to be written to the file.
+ /// The dune location calculations to be written to the file.
/// The path to the file.
/// Thrown when any parameter is null.
/// Thrown when unable to write to .
- public static void WriteDuneLocations(IEnumerable duneLocations,
+ public static void WriteDuneLocations(IEnumerable duneLocationCalculations,
string filePath)
{
- if (duneLocations == null)
+ if (duneLocationCalculations == null)
{
- throw new ArgumentNullException(nameof(duneLocations));
+ throw new ArgumentNullException(nameof(duneLocationCalculations));
}
if (filePath == null)
{
@@ -64,9 +64,9 @@
try
{
- foreach (DuneLocation location in duneLocations)
+ foreach (DuneLocationCalculation calculation in duneLocationCalculations)
{
- stringBuilder.AppendLine(CreateCsvLine(location));
+ stringBuilder.AppendLine(CreateCsvLine(calculation));
}
File.WriteAllText(filePath, stringBuilder.ToString());
@@ -77,17 +77,18 @@
}
}
- private static string CreateCsvLine(DuneLocation location)
+ private static string CreateCsvLine(DuneLocationCalculation calculation)
{
+ var duneLocation = calculation.DuneLocation;
var stringComponents = new List
{
- location.CoastalAreaId.ToString(null, CultureInfo.InvariantCulture),
- location.Offset.ToString(DuneErosionDataResources.DuneLocation_Offset_format, CultureInfo.InvariantCulture),
+ duneLocation.CoastalAreaId.ToString(null, CultureInfo.InvariantCulture),
+ duneLocation.Offset.ToString(DuneErosionDataResources.DuneLocation_Offset_format, CultureInfo.InvariantCulture),
Resources.DuneLocationsWriter_CreateCsvLine_Parameter_without_value,
- location.D50.ToString(null, CultureInfo.InvariantCulture)
+ duneLocation.D50.ToString(null, CultureInfo.InvariantCulture)
};
- stringComponents.InsertRange(2, GetOutputValues(location.Calculation.Output));
+ stringComponents.InsertRange(2, GetOutputValues(calculation.Output));
return string.Join(separator, stringComponents);
}
Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.IO.Test/DuneLocationsExporterTest.cs
===================================================================
diff -u -rb0e228408016f88b94ac63d6896e5bc7668a75c1 -rb06f209aeee8d486386e6d6007a51d561cf9593f
--- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.IO.Test/DuneLocationsExporterTest.cs (.../DuneLocationsExporterTest.cs) (revision b0e228408016f88b94ac63d6896e5bc7668a75c1)
+++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.IO.Test/DuneLocationsExporterTest.cs (.../DuneLocationsExporterTest.cs) (revision b06f209aeee8d486386e6d6007a51d561cf9593f)
@@ -43,21 +43,21 @@
string filePath = TestHelper.GetScratchPadPath(Path.Combine(nameof(DuneLocationsExporterTest), "test.bnd"));
// Call
- var exporter = new DuneLocationsExporter(Enumerable.Empty(), filePath);
+ var exporter = new DuneLocationsExporter(Enumerable.Empty(), filePath);
// Assert
Assert.IsInstanceOf(exporter);
}
[Test]
- public void Constructor_LocationsNull_ThrowArgumentNullException()
+ public void Constructor_DuneLocationCalculationsNull_ThrowArgumentNullException()
{
// Call
TestDelegate test = () => new DuneLocationsExporter(null, "IAmValid.bnd");
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("duneLocations", exception.ParamName);
+ Assert.AreEqual("duneLocationCalculations", exception.ParamName);
}
[Test]
@@ -67,7 +67,7 @@
public void Constructor_FilePathInvalid_ThrowArgumentException(string filePath)
{
// Call
- TestDelegate test = () => new DuneLocationsExporter(Enumerable.Empty(), filePath);
+ TestDelegate test = () => new DuneLocationsExporter(Enumerable.Empty(), filePath);
// Assert
Assert.Throws(test);
@@ -77,27 +77,31 @@
public void Export_ValidData_ReturnTrueAndWritesFile()
{
// Setup
- DuneLocation locationNoOutput = CreateDuneLocationForExport(9, 9740, 1.9583e-4);
+ var calculationWithoutOutput = new DuneLocationCalculation(CreateDuneLocationForExport(9, 9740, 1.9583e-4));
- DuneLocation locationUncalculatedOutput = CreateDuneLocationForExport(10, 9770.1, 1.9583e-4);
- locationUncalculatedOutput.Calculation.Output = CreateDuneLocationOutputForExport(double.NaN, double.NaN, double.NaN);
+ var calculationWithUncalculatedOutput = new DuneLocationCalculation(CreateDuneLocationForExport(10, 9770.1, 1.9583e-4))
+ {
+ Output = CreateDuneLocationOutputForExport(double.NaN, double.NaN, double.NaN)
+ };
- DuneLocation locationCalculatedOutput = CreateDuneLocationForExport(11, 9771.34, 1.337e-4);
- locationCalculatedOutput.Calculation.Output = CreateDuneLocationOutputForExport(5.89, 14.11, 8.53);
+ var calculationWithOutput = new DuneLocationCalculation(CreateDuneLocationForExport(11, 9771.34, 1.337e-4))
+ {
+ Output = CreateDuneLocationOutputForExport(5.89, 14.11, 8.53)
+ };
- DuneLocation[] duneLocations =
+ DuneLocationCalculation[] duneLocationCalculations =
{
- locationNoOutput,
- locationUncalculatedOutput,
- locationCalculatedOutput
+ calculationWithoutOutput,
+ calculationWithUncalculatedOutput,
+ calculationWithOutput
};
string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_ValidData_ReturnTrueAndWritesFile));
using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_ValidData_ReturnTrueAndWritesFile)))
{
string filePath = Path.Combine(directoryPath, "test.bnd");
- var exporter = new DuneLocationsExporter(duneLocations, filePath);
+ var exporter = new DuneLocationsExporter(duneLocationCalculations, filePath);
// Call
bool isExported = exporter.Export();
@@ -119,23 +123,11 @@
public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse()
{
// Setup
- DuneLocation[] duneLocations =
- {
- new TestDuneLocation(),
- new TestDuneLocation
- {
- Calculation =
- {
- Output = new TestDuneLocationOutput()
- }
- }
- };
-
string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse));
using (var disposeHelper = new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_InvalidDirectoryRights_LogErrorAndReturnFalse)))
{
string filePath = Path.Combine(directoryPath, "test.bnd");
- var exporter = new DuneLocationsExporter(duneLocations, filePath);
+ var exporter = new DuneLocationsExporter(Enumerable.Empty(), filePath);
disposeHelper.LockDirectory(FileSystemRights.Write);
var isExported = true;
Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.IO.Test/DuneLocationsWriterTest.cs
===================================================================
diff -u -rb0e228408016f88b94ac63d6896e5bc7668a75c1 -rb06f209aeee8d486386e6d6007a51d561cf9593f
--- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.IO.Test/DuneLocationsWriterTest.cs (.../DuneLocationsWriterTest.cs) (revision b0e228408016f88b94ac63d6896e5bc7668a75c1)
+++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.IO.Test/DuneLocationsWriterTest.cs (.../DuneLocationsWriterTest.cs) (revision b06f209aeee8d486386e6d6007a51d561cf9593f)
@@ -36,21 +36,21 @@
public class DuneLocationsWriterTest
{
[Test]
- public void WriteDuneLocations_DuneLocationsNull_ThrowArgumentNullException()
+ public void WriteDuneLocations_DuneLocationCalculationsNull_ThrowArgumentNullException()
{
// Call
TestDelegate test = () => DuneLocationsWriter.WriteDuneLocations(null, string.Empty);
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("duneLocations", exception.ParamName);
+ Assert.AreEqual("duneLocationCalculations", exception.ParamName);
}
[Test]
public void WriteDuneLocations_FilePathNull_ThrowArgumentNullException()
{
// Call
- TestDelegate test = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), null);
+ TestDelegate test = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), null);
// Assert
var exception = Assert.Throws(test);
@@ -64,7 +64,7 @@
public void WriteDuneLocations_FilePathInvalid_ThrowCriticalFileWriteException(string filePath)
{
// Call
- TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), filePath);
+ TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), filePath);
// Assert
var exception = Assert.Throws(call);
@@ -79,7 +79,7 @@
var filePath = new string('a', 249);
// Call
- TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), filePath);
+ TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), filePath);
// Assert
var exception = Assert.Throws(call);
@@ -97,7 +97,7 @@
string filePath = Path.Combine(directoryPath, "test.bnd");
// Call
- TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), filePath);
+ TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), filePath);
disposeHelper.LockDirectory(FileSystemRights.Write);
// Assert
@@ -118,7 +118,7 @@
fileDisposeHelper.LockFiles();
// Call
- TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), path);
+ TestDelegate call = () => DuneLocationsWriter.WriteDuneLocations(Enumerable.Empty(), path);
// Assert
var exception = Assert.Throws(call);
@@ -131,19 +131,23 @@
public void WriteDuneLocations_ValidData_ValidFile()
{
// Setup
- DuneLocation locationNoOutput = CreateDuneLocationForExport(9, 9740, 1.9583e-4);
+ var calculationWithoutOutput = new DuneLocationCalculation(CreateDuneLocationForExport(9, 9740, 1.9583e-4));
- DuneLocation locationUncalculatedOutput = CreateDuneLocationForExport(10, 9770.1, 1.9583e-4);
- locationUncalculatedOutput.Calculation.Output = CreateDuneLocationOutputForExport(double.NaN, double.NaN, double.NaN);
+ var calculationWithUncalculatedOutput = new DuneLocationCalculation(CreateDuneLocationForExport(10, 9770.1, 1.9583e-4))
+ {
+ Output = CreateDuneLocationOutputForExport(double.NaN, double.NaN, double.NaN)
+ };
- DuneLocation locationCalculatedOutput = CreateDuneLocationForExport(11, 9771.34, 1.337e-4);
- locationCalculatedOutput.Calculation.Output = CreateDuneLocationOutputForExport(5.89, 14.11, 8.53);
+ var calculationWithOutput = new DuneLocationCalculation(CreateDuneLocationForExport(11, 9771.34, 1.337e-4))
+ {
+ Output = CreateDuneLocationOutputForExport(5.89, 14.11, 8.53)
+ };
- DuneLocation[] duneLocations =
+ DuneLocationCalculation[] duneLocationCalculations =
{
- locationNoOutput,
- locationUncalculatedOutput,
- locationCalculatedOutput
+ calculationWithoutOutput,
+ calculationWithUncalculatedOutput,
+ calculationWithOutput
};
string directoryPath = TestHelper.GetScratchPadPath("WriteDuneLocations_ValidData_ValidFile");
@@ -153,7 +157,7 @@
try
{
// Call
- DuneLocationsWriter.WriteDuneLocations(duneLocations, filePath);
+ DuneLocationsWriter.WriteDuneLocations(duneLocationCalculations, filePath);
// Assert
Assert.IsTrue(File.Exists(filePath));