Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditions/ExportableWaveConditionsFactory.cs =================================================================== diff -u -r29e5f1ed0694c7bad1d044b4e1dfd8b1c8415cb8 -rfaee3de18c59589d2380809cccd379c5c8aa76ce --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditions/ExportableWaveConditionsFactory.cs (.../ExportableWaveConditionsFactory.cs) (revision 29e5f1ed0694c7bad1d044b4e1dfd8b1c8415cb8) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/WaveConditions/ExportableWaveConditionsFactory.cs (.../ExportableWaveConditionsFactory.cs) (revision faee3de18c59589d2380809cccd379c5c8aa76ce) @@ -125,5 +125,47 @@ return output.Select(waveConditionsOutput => new ExportableWaveConditions(name, waveConditionsInput, waveConditionsOutput, coverType)).ToArray(); } + + /// + /// Create a collection of . + /// + /// The name of the calculation to which the objects belong. + /// The used in the calculations. + /// The objects resulting from the calculations. + /// The type of cover. + /// A container of objects. + /// Thrown when: + /// + /// any parameter is null + /// any item in is null + /// + /// Thrown when + /// is null for . + public static IEnumerable CreateExportableWaveConditionsCollection( + string name, FailureMechanismCategoryWaveConditionsInput waveConditionsInput, + IEnumerable output, CoverType coverType) + { + if (name == null) + { + throw new ArgumentNullException(nameof(name)); + } + + if (waveConditionsInput == null) + { + throw new ArgumentNullException(nameof(waveConditionsInput)); + } + + if (output == null) + { + throw new ArgumentNullException(nameof(output)); + } + + if (coverType == null) + { + throw new ArgumentNullException(nameof(coverType)); + } + + return output.Select(waveConditionsOutput => new ExportableWaveConditions(name, waveConditionsInput, waveConditionsOutput, coverType)).ToArray(); + } } } \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditions/ExportableWaveConditionsFactoryTest.cs =================================================================== diff -u -r29e5f1ed0694c7bad1d044b4e1dfd8b1c8415cb8 -rfaee3de18c59589d2380809cccd379c5c8aa76ce --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditions/ExportableWaveConditionsFactoryTest.cs (.../ExportableWaveConditionsFactoryTest.cs) (revision 29e5f1ed0694c7bad1d044b4e1dfd8b1c8415cb8) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/WaveConditions/ExportableWaveConditionsFactoryTest.cs (.../ExportableWaveConditionsFactoryTest.cs) (revision faee3de18c59589d2380809cccd379c5c8aa76ce) @@ -249,5 +249,101 @@ Assert.AreEqual(waveConditionsOutput.WaveAngle, exportableWaveConditions.WaveAngle); Assert.AreEqual(waveConditionsOutput.WaveDirection, exportableWaveConditions.WaveDirection); } + + [Test] + public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_NameNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(null, + new FailureMechanismCategoryWaveConditionsInput(), + waveConditionsOutputCollection, + CoverType.Asphalt); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("name", exception.ParamName); + } + + [Test] + public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_WaveConditionsInputNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName", + null, + waveConditionsOutputCollection, + CoverType.Asphalt); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("waveConditionsInput", exception.ParamName); + } + + [Test] + public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_OutputNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName", + new FailureMechanismCategoryWaveConditionsInput(), + null, + CoverType.Asphalt); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("output", exception.ParamName); + } + + [Test] + public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_CoverTypeNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName", + new FailureMechanismCategoryWaveConditionsInput(), + Enumerable.Empty(), + (CoverType) null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("coverType", exception.ParamName); + } + + [Test] + public void CreateExportableWaveConditionsCollectionWithFailureMechanismCategoryWaveConditionsInput_ValidDataWithCoverType_ReturnsValidCollection() + { + // Setup + var waveConditionsInput = new FailureMechanismCategoryWaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "hblName", 1.0, 8.0), + ForeshoreProfile = new TestForeshoreProfile(), + UseForeshore = true + }; + + // Call + ExportableWaveConditions[] exportableWaveConditionsCollection = + ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("ewcName", + waveConditionsInput, + waveConditionsOutputCollection, + CoverType.Grass).ToArray(); + + // Assert + Assert.AreEqual(1, exportableWaveConditionsCollection.Length); + ExportableWaveConditions exportableWaveConditions = exportableWaveConditionsCollection[0]; + Assert.AreEqual("ewcName", exportableWaveConditions.CalculationName); + Assert.AreEqual("hblName", exportableWaveConditions.LocationName); + Assert.AreEqual(1.0, exportableWaveConditions.LocationXCoordinate); + Assert.AreEqual(8.0, exportableWaveConditions.LocationYCoordinate); + Assert.AreEqual("id", exportableWaveConditions.ForeshoreId); + Assert.AreEqual(false, exportableWaveConditions.UseBreakWater); + Assert.AreEqual(true, exportableWaveConditions.UseForeshore); + Assert.AreEqual(CoverType.Grass, exportableWaveConditions.CoverType); + Assert.AreEqual(2, exportableWaveConditions.WaterLevel.NumberOfDecimalPlaces); + Assert.AreEqual(2, exportableWaveConditions.WaveHeight.NumberOfDecimalPlaces); + Assert.AreEqual(2, exportableWaveConditions.WavePeriod.NumberOfDecimalPlaces); + Assert.AreEqual(2, exportableWaveConditions.WaveAngle.NumberOfDecimalPlaces); + Assert.AreEqual(waveConditionsOutput.WaterLevel, exportableWaveConditions.WaterLevel); + Assert.AreEqual(waveConditionsOutput.WaveHeight, exportableWaveConditions.WaveHeight); + Assert.AreEqual(waveConditionsOutput.WavePeakPeriod, exportableWaveConditions.WavePeriod); + Assert.AreEqual(waveConditionsOutput.WaveAngle, exportableWaveConditions.WaveAngle); + Assert.AreEqual(waveConditionsOutput.WaveDirection, exportableWaveConditions.WaveDirection); + } } } \ No newline at end of file