Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Exporters/GrassCoverErosionOutwardsWaveConditionsExporterTest.cs =================================================================== diff -u -r96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b -r0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Exporters/GrassCoverErosionOutwardsWaveConditionsExporterTest.cs (.../GrassCoverErosionOutwardsWaveConditionsExporterTest.cs) (revision 96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Exporters/GrassCoverErosionOutwardsWaveConditionsExporterTest.cs (.../GrassCoverErosionOutwardsWaveConditionsExporterTest.cs) (revision 0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d) @@ -20,11 +20,18 @@ // 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.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.IO.Exporters; +using Ringtoets.Revetment.Data; using Ringtoets.Revetment.IO.Exporters; +using Ringtoets.Revetment.TestUtil; namespace Ringtoets.GrassCoverErosionOutwards.IO.Test.Exporters { @@ -64,5 +71,112 @@ var exception = Assert.Throws(call); Assert.AreEqual("filePath", exception.ParamName); } + + [Test] + public void Export_CalculationsWithoutOutput_FileWithOnlyHeader() + { + // Setup + string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_CalculationsWithoutOutput_FileWithOnlyHeader)); + using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_CalculationsWithoutOutput_FileWithOnlyHeader))) + { + string filePath = Path.Combine(directoryPath, "test.csv"); + + var calculationsWithoutOutput = new[] + { + new GrassCoverErosionOutwardsWaveConditionsCalculation() + }; + + var exporter = new GrassCoverErosionOutwardsWaveConditionsExporter(calculationsWithoutOutput, filePath); + + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n", fileContent); + } + } + + [Test] + public void Export_CalculationsWithoutHydraulicBoundaryLocation_FileWithOnlyHeader() + { + // Setup + string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_CalculationsWithoutHydraulicBoundaryLocation_FileWithOnlyHeader)); + using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_CalculationsWithoutHydraulicBoundaryLocation_FileWithOnlyHeader))) + { + string filePath = Path.Combine(directoryPath, "test.csv"); + + var calculations = new[] + { + new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty()) + } + }; + + var exporter = new GrassCoverErosionOutwardsWaveConditionsExporter(calculations, filePath); + + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n", fileContent); + } + } + + [Test] + public void Export_ValidData_ValidFile() + { + // Setup + string subFolder = $"{nameof(GrassCoverErosionOutwardsWaveConditionsExporterTest)}.{nameof(Export_ValidData_ValidFile)}"; + string directoryPath = TestHelper.GetScratchPadPath(subFolder); + using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), subFolder)) + { + string filePath = Path.Combine(directoryPath, "test.csv"); + + var calculations = new[] + { + new GrassCoverErosionOutwardsWaveConditionsCalculation + { + Name = "aCalculation", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(8, "aLocation", 44, 123.456) + { + DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(28.36844) + }, + ForeshoreProfile = new TestForeshoreProfile("foreshoreA"), + LowerBoundaryRevetment = (RoundedDouble) 1.384, + UpperBoundaryRevetment = (RoundedDouble) 11.54898963, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryWaterLevels = (RoundedDouble) 1.98699, + UpperBoundaryWaterLevels = (RoundedDouble) 84.26548 + }, + Output = new GrassCoverErosionOutwardsWaveConditionsOutput(new[] + { + new TestWaveConditionsOutput() + }) + } + }; + + var exporter = new GrassCoverErosionOutwardsWaveConditionsExporter(calculations, filePath); + + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n" + + "aCalculation, aLocation, 44.000, 123.456, foreshoreA, nee, nee, Gras, 1.10, 2.20, 3.30, 4.40, 5.50\r\n", + fileContent); + } + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj =================================================================== diff -u -r96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b -r0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj) (revision 96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.IO.Test/Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.IO.Test.csproj) (revision 0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d) @@ -90,6 +90,10 @@ {E3347B16-BB18-41C1-8D34-FBCBF20DB695} Ringtoets.Revetment.IO + + {3706200E-48C6-4B86-B48C-4E45C69ABE95} + Ringtoets.Revetment.Data.TestUtil + {E7225477-577F-4A17-B7EC-6721158E1543} Ringtoets.GrassCoverErosionOutwards.Data Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/Exporters/StabilityStoneCoverWaveConditionsExporterTest.cs =================================================================== diff -u -r96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b -r0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/Exporters/StabilityStoneCoverWaveConditionsExporterTest.cs (.../StabilityStoneCoverWaveConditionsExporterTest.cs) (revision 96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.IO.Test/Exporters/StabilityStoneCoverWaveConditionsExporterTest.cs (.../StabilityStoneCoverWaveConditionsExporterTest.cs) (revision 0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d) @@ -143,6 +143,7 @@ { DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(28.36844) }, + ForeshoreProfile = new TestForeshoreProfile("foreshoreA"), LowerBoundaryRevetment = (RoundedDouble) 1.384, UpperBoundaryRevetment = (RoundedDouble) 11.54898963, StepSize = WaveConditionsInputStepSize.Half, @@ -169,8 +170,8 @@ Assert.IsTrue(File.Exists(filePath)); string fileContent = File.ReadAllText(filePath); Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n" + - "aCalculation, aLocation, 44.000, 123.456, , nee, nee, Steen (zuilen), 1.10, 2.20, 3.30, 4.40, 5.50\r\n" + - "aCalculation, aLocation, 44.000, 123.456, , nee, nee, Steen (blokken), 1.10, 2.20, 3.30, 4.40, 5.50\r\n", + "aCalculation, aLocation, 44.000, 123.456, foreshoreA, nee, nee, Steen (zuilen), 1.10, 2.20, 3.30, 4.40, 5.50\r\n" + + "aCalculation, aLocation, 44.000, 123.456, foreshoreA, nee, nee, Steen (blokken), 1.10, 2.20, 3.30, 4.40, 5.50\r\n", fileContent); } } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Exporters/WaveImpactAsphaltCoverWaveConditionsExporterTest.cs =================================================================== diff -u -r96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b -r0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Exporters/WaveImpactAsphaltCoverWaveConditionsExporterTest.cs (.../WaveImpactAsphaltCoverWaveConditionsExporterTest.cs) (revision 96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Exporters/WaveImpactAsphaltCoverWaveConditionsExporterTest.cs (.../WaveImpactAsphaltCoverWaveConditionsExporterTest.cs) (revision 0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d) @@ -20,9 +20,16 @@ // 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.Data.Hydraulics; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Revetment.Data; using Ringtoets.Revetment.IO.Exporters; +using Ringtoets.Revetment.TestUtil; using Ringtoets.WaveImpactAsphaltCover.Data; using Ringtoets.WaveImpactAsphaltCover.IO.Exporters; @@ -68,5 +75,112 @@ var exception = Assert.Throws(call); Assert.AreEqual("filePath", exception.ParamName); } + + [Test] + public void Export_CalculationsWithoutOutput_FileWithOnlyHeader() + { + // Setup + string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_CalculationsWithoutOutput_FileWithOnlyHeader)); + using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_CalculationsWithoutOutput_FileWithOnlyHeader))) + { + string filePath = Path.Combine(directoryPath, "test.csv"); + + var calculationsWithoutOutput = new[] + { + new WaveImpactAsphaltCoverWaveConditionsCalculation() + }; + + var exporter = new WaveImpactAsphaltCoverWaveConditionsExporter(calculationsWithoutOutput, filePath); + + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n", fileContent); + } + } + + [Test] + public void Export_CalculationsWithoutHydraulicBoundaryLocation_FileWithOnlyHeader() + { + // Setup + string directoryPath = TestHelper.GetScratchPadPath(nameof(Export_CalculationsWithoutHydraulicBoundaryLocation_FileWithOnlyHeader)); + using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), nameof(Export_CalculationsWithoutHydraulicBoundaryLocation_FileWithOnlyHeader))) + { + string filePath = Path.Combine(directoryPath, "test.csv"); + + var calculations = new[] + { + new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty()) + } + }; + + var exporter = new WaveImpactAsphaltCoverWaveConditionsExporter(calculations, filePath); + + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n", fileContent); + } + } + + [Test] + public void Export_ValidData_ValidFile() + { + // Setup + string subFolder = $"{nameof(WaveImpactAsphaltCoverWaveConditionsExporterTest)}.{nameof(Export_ValidData_ValidFile)}"; + string directoryPath = TestHelper.GetScratchPadPath(subFolder); + using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), subFolder)) + { + string filePath = Path.Combine(directoryPath, "test.csv"); + + var calculations = new[] + { + new WaveImpactAsphaltCoverWaveConditionsCalculation + { + Name = "aCalculation", + InputParameters = + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(8, "aLocation", 44, 123.456) + { + DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(28.36844) + }, + ForeshoreProfile = new TestForeshoreProfile("foreshoreA"), + LowerBoundaryRevetment = (RoundedDouble) 1.384, + UpperBoundaryRevetment = (RoundedDouble) 11.54898963, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryWaterLevels = (RoundedDouble) 1.98699, + UpperBoundaryWaterLevels = (RoundedDouble) 84.26548 + }, + Output = new WaveImpactAsphaltCoverWaveConditionsOutput(new[] + { + new TestWaveConditionsOutput() + }) + } + }; + + var exporter = new WaveImpactAsphaltCoverWaveConditionsExporter(calculations, filePath); + + // Call + bool isExported = exporter.Export(); + + // Assert + Assert.IsTrue(isExported); + Assert.IsTrue(File.Exists(filePath)); + string fileContent = File.ReadAllText(filePath); + Assert.AreEqual("Naam berekening, Naam HR locatie, X HR locatie (RD) [m], Y HR locatie (RD) [m], Naam voorlandprofiel, Dam gebruikt, Voorlandgeometrie gebruikt, Type bekleding, Waterstand [m+NAP], Golfhoogte (Hs) [m], Golfperiode (Tp) [s], Golfrichting t.o.v. dijknormaal [°], Golfrichting t.o.v. Noord [°]\r\n" + + "aCalculation, aLocation, 44.000, 123.456, foreshoreA, nee, nee, Asfalt, 1.10, 2.20, 3.30, 4.40, 5.50\r\n", + fileContent); + } + } } } \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj =================================================================== diff -u -r96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b -r0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj) (revision 96cd93f1a08294e5af3fec5f5ae0b59cbe914c4b) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.IO.Test/Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.IO.Test.csproj) (revision 0d0b747c9b4d6769f09e0dad0a0b7690b7b5755d) @@ -89,6 +89,10 @@ {E3347B16-BB18-41C1-8D34-FBCBF20DB695} Ringtoets.Revetment.IO + + {3706200E-48C6-4B86-B48C-4E45C69ABE95} + Ringtoets.Revetment.Data.TestUtil + {567e0b69-5280-41ce-add6-443725a61c86} Ringtoets.WaveImpactAsphaltCover.Data