Index: Riskeer/DuneErosion/src/Riskeer.DuneErosion.Service/DuneErosionDataSynchronizationService.cs
===================================================================
diff -u -r2f9d8396ab89c4826d9fcd1bf1f8daa0a8c13be3 -r02829c4e0d62e67ebeae2b7ba5cb9e4cf2c3711b
--- Riskeer/DuneErosion/src/Riskeer.DuneErosion.Service/DuneErosionDataSynchronizationService.cs (.../DuneErosionDataSynchronizationService.cs) (revision 2f9d8396ab89c4826d9fcd1bf1f8daa0a8c13be3)
+++ Riskeer/DuneErosion/src/Riskeer.DuneErosion.Service/DuneErosionDataSynchronizationService.cs (.../DuneErosionDataSynchronizationService.cs) (revision 02829c4e0d62e67ebeae2b7ba5cb9e4cf2c3711b)
@@ -41,11 +41,11 @@
///
/// The to update.
/// The hydraulic boundary locations to use.
- /// The dune locations to use.
+ /// The read dune locations to use.
/// Thrown when any parameter is null.
public static void SetDuneLocations(DuneErosionFailureMechanism failureMechanism,
IEnumerable hydraulicBoundaryLocations,
- IEnumerable duneLocations)
+ IEnumerable readDuneLocations)
{
if (failureMechanism == null)
{
@@ -57,35 +57,17 @@
throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
}
- if (duneLocations == null)
+ if (readDuneLocations == null)
{
- throw new ArgumentNullException(nameof(duneLocations));
+ throw new ArgumentNullException(nameof(readDuneLocations));
}
- if (!hydraulicBoundaryLocations.Any() || !duneLocations.Any())
+ if (!hydraulicBoundaryLocations.Any() || !readDuneLocations.Any())
{
return;
}
- var duneLocationsToSet = new List();
-
- Dictionary readDuneLocationsLookup = duneLocations.ToDictionary(rdl => rdl.Name, rdl => rdl);
-
- foreach (HydraulicBoundaryLocation hydraulicBoundaryLocation in hydraulicBoundaryLocations)
- {
- if (readDuneLocationsLookup.TryGetValue(hydraulicBoundaryLocation.Name, out ReadDuneLocation correspondingReadDuneLocation))
- {
- duneLocationsToSet.Add(new DuneLocation(hydraulicBoundaryLocation.Name,
- hydraulicBoundaryLocation,
- new DuneLocation.ConstructionProperties
- {
- CoastalAreaId = correspondingReadDuneLocation.CoastalAreaId,
- Offset = correspondingReadDuneLocation.Offset
- }));
- }
- }
-
- failureMechanism.SetDuneLocations(duneLocationsToSet);
+ failureMechanism.SetDuneLocations(GetDuneLocationsToSet(hydraulicBoundaryLocations, readDuneLocations));
}
///
@@ -130,5 +112,24 @@
return affectedCalculations;
}
+
+ private static IEnumerable GetDuneLocationsToSet(IEnumerable hydraulicBoundaryLocations, IEnumerable readDuneLocations)
+ {
+ Dictionary readDuneLocationsLookup = readDuneLocations.ToDictionary(rdl => rdl.Name, rdl => rdl);
+
+ foreach (HydraulicBoundaryLocation hydraulicBoundaryLocation in hydraulicBoundaryLocations)
+ {
+ if (readDuneLocationsLookup.TryGetValue(hydraulicBoundaryLocation.Name, out ReadDuneLocation correspondingReadDuneLocation))
+ {
+ yield return new DuneLocation(hydraulicBoundaryLocation.Name,
+ hydraulicBoundaryLocation,
+ new DuneLocation.ConstructionProperties
+ {
+ CoastalAreaId = correspondingReadDuneLocation.CoastalAreaId,
+ Offset = correspondingReadDuneLocation.Offset
+ });
+ }
+ }
+ }
}
}
\ No newline at end of file
Index: Riskeer/DuneErosion/test/Riskeer.DuneErosion.Service.Test/DuneErosionDataSynchronizationServiceTest.cs
===================================================================
diff -u -rf043860613450243336703dff6dcb8d81f4acd8b -r02829c4e0d62e67ebeae2b7ba5cb9e4cf2c3711b
--- Riskeer/DuneErosion/test/Riskeer.DuneErosion.Service.Test/DuneErosionDataSynchronizationServiceTest.cs (.../DuneErosionDataSynchronizationServiceTest.cs) (revision f043860613450243336703dff6dcb8d81f4acd8b)
+++ Riskeer/DuneErosion/test/Riskeer.DuneErosion.Service.Test/DuneErosionDataSynchronizationServiceTest.cs (.../DuneErosionDataSynchronizationServiceTest.cs) (revision 02829c4e0d62e67ebeae2b7ba5cb9e4cf2c3711b)
@@ -65,7 +65,7 @@
}
[Test]
- public void SetDuneLocations_DuneLocationsNull_ThrowArgumentNullException()
+ public void SetDuneLocations_ReadDuneLocationsNull_ThrowArgumentNullException()
{
// Setup
var failureMechanism = new DuneErosionFailureMechanism();
@@ -77,7 +77,7 @@
// Assert
var exception = Assert.Throws(Call);
- Assert.AreEqual("duneLocations", exception.ParamName);
+ Assert.AreEqual("readDuneLocations", exception.ParamName);
}
[Test]