Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r993abad2c25b543f2fce10da1646f98da880a54b -rdb71c07ce0e920be557d203f3e822443c9fe34c4
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 993abad2c25b543f2fce10da1646f98da880a54b)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision db71c07ce0e920be557d203f3e822443c9fe34c4)
@@ -377,6 +377,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/DuneErosion/DuneLocationCalculationCollectionEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/DuneErosion/DuneLocationCalculationCollectionEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/DuneErosion/DuneLocationCalculationCollectionEntityReadExtensions.cs (revision db71c07ce0e920be557d203f3e822443c9fe34c4)
@@ -0,0 +1,76 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Ringtoets.DuneErosion.Data;
+
+namespace Application.Ringtoets.Storage.Read.DuneErosion
+{
+ ///
+ /// This class defines extension methods for read operations for a collection of
+ /// based on the .
+ ///
+ internal static class DuneLocationCalculationCollectionEntityReadExtensions
+ {
+ ///
+ /// Reads the and uses the information
+ /// to update a collection of .
+ ///
+ /// The to update the
+ /// .
+ /// The target of the read operation.
+ /// The object keeping track of the read operations.
+ /// Thrown when any parameter is null.
+ internal static void Read(this DuneLocationCalculationCollectionEntity entity,
+ IEnumerable calculations,
+ ReadConversionCollector collector)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
+ if (calculations == null)
+ {
+ throw new ArgumentNullException(nameof(calculations));
+ }
+
+ if (collector == null)
+ {
+ throw new ArgumentNullException(nameof(collector));
+ }
+
+ Dictionary calculationsLookup =
+ calculations.ToDictionary(calc => calc.DuneLocation, calc => calc);
+
+ foreach (DuneLocationCalculationEntity calculationEntity in entity.DuneLocationCalculationEntities)
+ {
+ DuneLocation duneLocation = collector.Get(calculationEntity.DuneLocationEntity);
+ DuneLocationCalculation calculation = calculationsLookup[duneLocation];
+
+ calculationEntity.Read(calculation);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r993abad2c25b543f2fce10da1646f98da880a54b -rdb71c07ce0e920be557d203f3e822443c9fe34c4
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 993abad2c25b543f2fce10da1646f98da880a54b)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision db71c07ce0e920be557d203f3e822443c9fe34c4)
@@ -96,6 +96,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/DuneErosion/DuneLocationCalculationCollectionEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/DuneErosion/DuneLocationCalculationCollectionEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/DuneErosion/DuneLocationCalculationCollectionEntityReadExtensionsTest.cs (revision db71c07ce0e920be557d203f3e822443c9fe34c4)
@@ -0,0 +1,139 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+using Application.Ringtoets.Storage.Read.DuneErosion;
+using NUnit.Framework;
+using Ringtoets.DuneErosion.Data;
+using Ringtoets.DuneErosion.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Read.DuneErosion
+{
+ [TestFixture]
+ public class DuneLocationCalculationCollectionEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () =>
+ ((DuneLocationCalculationCollectionEntity) null).Read(Enumerable.Empty(),
+ new ReadConversionCollector());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_CalculationsNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new DuneLocationCalculationCollectionEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null, new ReadConversionCollector());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("calculations", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_CollectorNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new DuneLocationCalculationCollectionEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(Enumerable.Empty(),
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("collector", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_EntityWithValidValues_SetsCalculationsWithExpectedValues()
+ {
+ // Setup
+ DuneLocationEntity duneLocationEntityOne = CreateDuneLocationEntity();
+ var calculationEntityWithoutOutput = new DuneLocationCalculationEntity
+ {
+ DuneLocationEntity = duneLocationEntityOne
+ };
+
+ DuneLocationEntity duneLocationEntityTwo = CreateDuneLocationEntity();
+ var calculationEntityWithOutput = new DuneLocationCalculationEntity
+ {
+ DuneLocationEntity = duneLocationEntityTwo,
+ DuneLocationOutputEntities =
+ {
+ new DuneLocationOutputEntity()
+ }
+ };
+
+ var collectionEntity = new DuneLocationCalculationCollectionEntity
+ {
+ DuneLocationCalculationEntities =
+ {
+ calculationEntityWithoutOutput,
+ calculationEntityWithOutput
+ }
+ };
+
+ var duneLocationOne = new TestDuneLocation("1");
+ var duneLocationTwo = new TestDuneLocation("2");
+ var collector = new ReadConversionCollector();
+ collector.Read(duneLocationEntityOne, duneLocationOne);
+ collector.Read(duneLocationEntityTwo, duneLocationTwo);
+
+ var calculationOne = new DuneLocationCalculation(duneLocationOne);
+ var calculationTwo = new DuneLocationCalculation(duneLocationTwo);
+
+ // Call
+ collectionEntity.Read(new []
+ {
+ calculationOne,
+ calculationTwo
+ }, collector);
+
+ // Assert
+ Assert.IsNull(calculationOne.Output);
+ Assert.IsNotNull(calculationTwo.Output);
+ }
+
+ private static DuneLocationEntity CreateDuneLocationEntity()
+ {
+ return new DuneLocationEntity
+ {
+ LocationId = 1,
+ Name = "Dune Location",
+ LocationX = 1,
+ LocationY = 2
+ };
+ }
+ }
+}
\ No newline at end of file