Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -ra9de3fc0976012a64596de0e8ffe383de71d7656 -r5d8400ac58258556db30c8bada70701332d687a8
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision a9de3fc0976012a64596de0e8ffe383de71d7656)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -62,6 +62,9 @@
+
+
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneErosionFailureMechanismCreateExtensions.cs
===================================================================
diff -u -ra4cd22ab000aa81906e43b5fd2898e52fee0e366 -r5d8400ac58258556db30c8bada70701332d687a8
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneErosionFailureMechanismCreateExtensions.cs (.../DuneErosionFailureMechanismCreateExtensions.cs) (revision a4cd22ab000aa81906e43b5fd2898e52fee0e366)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneErosionFailureMechanismCreateExtensions.cs (.../DuneErosionFailureMechanismCreateExtensions.cs) (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Application.Ringtoets.Storage.DbContext;
using Ringtoets.DuneErosion.Data;
@@ -42,7 +43,8 @@
{
var entity = mechanism.Create(FailureMechanismType.DuneErosion, registry);
AddEntitiesForSectionResults(mechanism.SectionResults, registry);
-
+ AddEntitiesForFailureMechanismMeta(mechanism.GeneralInput, entity);
+ AddEntitiesForDuneLocations(mechanism.DuneLocations.ToList(), entity, registry);
return entity;
}
@@ -57,5 +59,19 @@
section.DuneErosionSectionResultEntities.Add(sectionResultEntity);
}
}
+
+ private static void AddEntitiesForFailureMechanismMeta(GeneralDuneErosionInput generalInput, FailureMechanismEntity entity)
+ {
+ entity.DuneErosionFailureMechanismMetaEntities.Add(generalInput.Create());
+ }
+
+ private static void AddEntitiesForDuneLocations(IList locations, FailureMechanismEntity entity, PersistenceRegistry registry)
+ {
+ for (var i = 0; i < locations.Count; i++)
+ {
+ DuneLocation duneLocation = locations[i];
+ entity.DuneLocationEntities.Add(duneLocation.Create(registry, i));
+ }
+ }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneLocationCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneLocationCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneLocationCreateExtensions.cs (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -0,0 +1,76 @@
+// Copyright (C) Stichting Deltares 2016. 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 Application.Ringtoets.Storage.DbContext;
+using Core.Common.Utils.Extensions;
+using Ringtoets.DuneErosion.Data;
+
+namespace Application.Ringtoets.Storage.Create.DuneErosion
+{
+ ///
+ /// Extension methods for related to creating a .
+ ///
+ internal static class DuneLocationCreateExtensions
+ {
+ ///
+ /// Creates a based on the information of the .
+ ///
+ /// The location to create a database entity for.
+ /// The object keeping track of create operations.
+ /// Index at which this instance resides inside its parent container.
+ /// A new .
+ /// Thrown when is null.
+ internal static DuneLocationEntity Create(this DuneLocation location, PersistenceRegistry registry, int order)
+ {
+ if (registry == null)
+ {
+ throw new ArgumentNullException(nameof(registry));
+ }
+ if (registry.Contains(location))
+ {
+ return registry.Get(location);
+ }
+
+ var entity = new DuneLocationEntity
+ {
+ LocationId = location.Id,
+ Name = location.Name.DeepClone(),
+ LocationX = location.Location.X.ToNaNAsNull(),
+ LocationY = location.Location.Y.ToNaNAsNull(),
+ Order = order
+ };
+
+ CreateDuneLocationOutput(entity, location.Output);
+
+ registry.Register(entity, location);
+ return entity;
+ }
+
+ private static void CreateDuneLocationOutput(DuneLocationEntity entity, DuneLocationOutput output)
+ {
+ if (output != null)
+ {
+ entity.DuneLocationOutputEntities.Add(output.Create());
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneLocationOutputCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneLocationOutputCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/DuneErosion/DuneLocationOutputCreateExtensions.cs (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -0,0 +1,72 @@
+// Copyright (C) Stichting Deltares 2016. 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 Application.Ringtoets.Storage.DbContext;
+using Ringtoets.DuneErosion.Data;
+
+namespace Application.Ringtoets.Storage.Create.DuneErosion
+{
+ ///
+ /// Extension methods for related to creating a .
+ ///
+ internal static class DuneLocationOutputCreateExtensions
+ {
+ ///
+ /// Creates a based on the information of the .
+ ///
+ /// The output to create a database entity for.
+ /// A new .
+ /// Thrown when is null.
+ internal static DuneLocationOutputEntity Create(this DuneLocationOutput output)
+ {
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+ return new DuneLocationOutputEntity
+ {
+ WaterLevel = double.IsNaN(output.WaterLevel)
+ ? (double?) null
+ : output.WaterLevel,
+ WaveHeight = double.IsNaN(output.WaveHeight)
+ ? (double?) null
+ : output.WaveHeight,
+ WavePeriod = double.IsNaN(output.WavePeriod)
+ ? (double?) null
+ : output.WavePeriod,
+ TargetProbability = double.IsNaN(output.TargetProbability)
+ ? (double?) null
+ : output.TargetProbability,
+ TargetReliability = double.IsNaN(output.TargetReliability)
+ ? (double?) null
+ : output.TargetReliability,
+ CalculatedProbability = double.IsNaN(output.CalculatedProbability)
+ ? (double?) null
+ : output.CalculatedProbability,
+ CalculatedReliability = double.IsNaN(output.CalculatedReliability)
+ ? (double?) null
+ : output.CalculatedReliability,
+ CalculationConvergence = (byte) output.CalculationConvergence,
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs
===================================================================
diff -u -rcfe96542ea5c45ef77ee3a770f1cbd21b38ebadc -r5d8400ac58258556db30c8bada70701332d687a8
--- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision cfe96542ea5c45ef77ee3a770f1cbd21b38ebadc)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.Designer.cs (.../RingtoetsEntities.Designer.cs) (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -1,4 +1,25 @@
-// T4 code generation is enabled for model 'D:\repos\WettelijkToetsInstrumentarium\Application\Ringtoets\src\Application.Ringtoets.Storage\DbContext\RingtoetsEntities.edmx'.
+// Copyright (C) Stichting Deltares 2016. 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.
+
+// T4 code generation is enabled for model 'D:\repos\WettelijkToetsInstrumentarium\Application\Ringtoets\src\Application.Ringtoets.Storage\DbContext\RingtoetsEntities.edmx'.
// To enable legacy code generation, change the value of the 'Code Generation Strategy' designer
// property to 'Legacy ObjectContext'. This property is available in the Properties Window when the model
// is open in the designer.
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r9f82ad8e7921a16326a1f351d3a31b458e204850 -r5d8400ac58258556db30c8bada70701332d687a8
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 9f82ad8e7921a16326a1f351d3a31b458e204850)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -80,6 +80,9 @@
+
+
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneErosionFailureMechanismCreateExtensionsTest.cs
===================================================================
diff -u -ra4cd22ab000aa81906e43b5fd2898e52fee0e366 -r5d8400ac58258556db30c8bada70701332d687a8
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneErosionFailureMechanismCreateExtensionsTest.cs (.../DuneErosionFailureMechanismCreateExtensionsTest.cs) (revision a4cd22ab000aa81906e43b5fd2898e52fee0e366)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneErosionFailureMechanismCreateExtensionsTest.cs (.../DuneErosionFailureMechanismCreateExtensionsTest.cs) (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -25,7 +25,9 @@
using Application.Ringtoets.Storage.Create.DuneErosion;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.TestUtil;
+using Core.Common.TestUtil;
using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
using Ringtoets.DuneErosion.Data;
namespace Application.Ringtoets.Storage.Test.Create.DuneErosion
@@ -48,11 +50,10 @@
}
[Test]
- [TestCase(true)]
- [TestCase(false)]
- public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant)
+ public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet()
{
// Setup
+ bool isRelevant = new Random(21).NextBoolean();
var failureMechanism = new DuneErosionFailureMechanism
{
IsRelevant = isRelevant,
@@ -72,7 +73,7 @@
var registry = new PersistenceRegistry();
// Call
- var entity = failureMechanism.Create(registry);
+ FailureMechanismEntity entity = failureMechanism.Create(registry);
// Assert
Assert.IsNotNull(entity);
@@ -81,6 +82,9 @@
Assert.AreEqual(failureMechanism.InputComments.Body, entity.InputComments);
Assert.AreEqual(failureMechanism.OutputComments.Body, entity.OutputComments);
Assert.AreEqual(failureMechanism.NotRelevantComments.Body, entity.NotRelevantComments);
+
+ DuneErosionFailureMechanismMetaEntity metaEntity = entity.DuneErosionFailureMechanismMetaEntities.First();
+ Assert.AreEqual(failureMechanism.GeneralInput.N, metaEntity.N, failureMechanism.GeneralInput.N.GetAccuracy());
}
[Test]
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneLocationCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneLocationCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneLocationCreateExtensionsTest.cs (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -0,0 +1,162 @@
+// Copyright (C) Stichting Deltares 2016. 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.Create;
+using Application.Ringtoets.Storage.Create.DuneErosion;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.DuneErosion.Data;
+using Ringtoets.DuneErosion.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Create.DuneErosion
+{
+ [TestFixture]
+ public class DuneLocationCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException()
+ {
+ // Setup
+ var location = new TestDuneLocation();
+
+ // Call
+ TestDelegate test = () => location.Create(null, 0);
+
+ // Assert
+ string parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("registry", parameterName);
+ }
+
+ [Test]
+ public void Create_WithPersistenceRegistry_ReturnsDuneLocationEntityWithPropertiesSet()
+ {
+ // Setup
+ var testName = "testName";
+ var random = new Random(21);
+ double coordinateX = random.NextDouble();
+ double coordinateY = random.NextDouble();
+ int id = random.Next(0, 150);
+ int order = random.Next();
+ var registry = new PersistenceRegistry();
+
+ var location = new DuneLocation(id, testName, new Point2D(coordinateX, coordinateY),
+ new DuneLocation.ConstructionProperties());
+
+ // Call
+ DuneLocationEntity entity = location.Create(registry, order);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(testName, entity.Name);
+ Assert.AreEqual(coordinateX, entity.LocationX);
+ Assert.AreEqual(coordinateY, entity.LocationY);
+ Assert.AreEqual(id, entity.LocationId);
+ Assert.IsEmpty(entity.DuneLocationOutputEntities);
+ Assert.AreEqual(order, entity.Order);
+ }
+
+ [Test]
+ public void Create_StringPropertiesDoNotShareReferences()
+ {
+ // Setup
+ var testName = "original name";
+ var location = new DuneLocation(1, testName, new Point2D(0, 0), new DuneLocation.ConstructionProperties());
+ var registry = new PersistenceRegistry();
+
+ // Call
+ DuneLocationEntity entity = location.Create(registry, 0);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreNotSame(testName, entity.Name,
+ "To create stable binary representations/fingerprints, it's really important that strings are not shared.");
+ Assert.AreEqual(testName, entity.Name);
+ }
+
+ [Test]
+ public void Create_WithPersistenceRegistryAndInitializer_ReturnsDuneLocationEntityWithOutputSet()
+ {
+ // Setup
+ var random = new Random(21);
+ var duneLocationOutput = new DuneLocationOutput(random.NextEnumValue(),
+ new DuneLocationOutput.ConstructionProperties
+ {
+ WaterLevel = random.NextDouble(),
+ WaveHeight = random.NextDouble(),
+ WavePeriod = random.NextDouble(),
+ TargetProbability = random.NextDouble(),
+ TargetReliability = random.NextDouble(),
+ CalculatedProbability = random.NextDouble(),
+ CalculatedReliability = random.NextDouble()
+ });
+
+ var location = new TestDuneLocation
+ {
+ Output = duneLocationOutput
+ };
+ var registry = new PersistenceRegistry();
+
+ // Call
+ DuneLocationEntity entity = location.Create(registry, 0);
+
+ // Assert
+ Assert.IsNotNull(entity);
+
+ DuneLocationOutputEntity duneLocationOutputEntity = entity.DuneLocationOutputEntities.SingleOrDefault();
+ Assert.IsNotNull(duneLocationOutputEntity);
+ AssertDuneBoundaryLocationOutput(duneLocationOutput, duneLocationOutputEntity);
+ }
+
+ [Test]
+ public void Create_DuneLocationSavedMultipleTimes_ReturnSameEntity()
+ {
+ // Setup
+ var location = new TestDuneLocation();
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ DuneLocationEntity entity1 = location.Create(registry, 0);
+ DuneLocationEntity entity2 = location.Create(registry, 1);
+
+ // Assert
+ Assert.AreSame(entity1, entity2);
+ }
+
+ private static void AssertDuneBoundaryLocationOutput(DuneLocationOutput output, DuneLocationOutputEntity entity)
+ {
+ Assert.AreEqual(output.WaterLevel, entity.WaterLevel, output.WaterLevel.GetAccuracy());
+ Assert.AreEqual(output.WaveHeight, entity.WaveHeight, output.WaveHeight.GetAccuracy());
+ Assert.AreEqual(output.WavePeriod, entity.WavePeriod, output.WavePeriod.GetAccuracy());
+ Assert.AreEqual(output.TargetProbability, entity.TargetProbability, output.TargetProbability);
+ Assert.AreEqual(output.TargetReliability, entity.TargetReliability, output.TargetReliability.GetAccuracy());
+ Assert.AreEqual(output.CalculatedProbability, entity.CalculatedProbability, output.CalculatedProbability);
+ Assert.AreEqual(output.CalculatedReliability, entity.CalculatedReliability, output.CalculatedReliability.GetAccuracy());
+ Assert.AreEqual(output.CalculationConvergence, (CalculationConvergence) entity.CalculationConvergence);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneLocationOutputCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneLocationOutputCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/DuneLocationOutputCreateExtensionsTest.cs (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -0,0 +1,113 @@
+// Copyright (C) Stichting Deltares 2016. 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 Application.Ringtoets.Storage.Create.DuneErosion;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.DuneErosion.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create.DuneErosion
+{
+ [TestFixture]
+ public class DuneLocationOutputCreateExtensionsTest
+ {
+ [Test]
+ public void Create_DuneLocationOutputNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ DuneLocationOutput duneLocationOutput = null;
+
+ // Call
+ TestDelegate call = () => duneLocationOutput.Create();
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("output", paramName);
+ }
+
+ [Test]
+ public void Create_WithValidParameters_ReturnsDuneLocationEntityWithOutputSet()
+ {
+ // Setup
+ var random = new Random(21);
+ var output = new DuneLocationOutput(random.NextEnumValue(), new DuneLocationOutput.ConstructionProperties
+ {
+ WaterLevel = random.NextDouble(),
+ WaveHeight = random.NextDouble(),
+ WavePeriod = random.NextDouble(),
+ TargetProbability = random.NextDouble(),
+ TargetReliability = random.NextDouble(),
+ CalculatedProbability = random.NextDouble(),
+ CalculatedReliability = random.NextDouble()
+ });
+
+ // Call
+ DuneLocationOutputEntity entity = output.Create();
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(output.WaterLevel, entity.WaterLevel, output.WaterLevel.GetAccuracy());
+ Assert.AreEqual(output.WaveHeight, entity.WaveHeight, output.WaveHeight.GetAccuracy());
+ Assert.AreEqual(output.WavePeriod, entity.WavePeriod, output.WavePeriod.GetAccuracy());
+ Assert.AreEqual(output.TargetProbability, entity.TargetProbability);
+ Assert.AreEqual(output.TargetReliability, entity.TargetReliability, output.TargetReliability.GetAccuracy());
+ Assert.AreEqual(output.CalculatedProbability, entity.CalculatedProbability);
+ Assert.AreEqual(output.CalculatedReliability, entity.CalculatedReliability, output.CalculatedReliability.GetAccuracy());
+ Assert.AreEqual((byte) output.CalculationConvergence, entity.CalculationConvergence);
+ }
+
+ [Test]
+ public void Create_WithNaNParameters_ReturnsDuneLocationEntityWithOutputSet()
+ {
+ // Setup
+ var random = new Random(21);
+ var output = new DuneLocationOutput(random.NextEnumValue(), new DuneLocationOutput.ConstructionProperties
+ {
+ WaterLevel = RoundedDouble.NaN,
+ WaveHeight = RoundedDouble.NaN,
+ WavePeriod = RoundedDouble.NaN,
+ TargetProbability = RoundedDouble.NaN,
+ TargetReliability = RoundedDouble.NaN,
+ CalculatedProbability = RoundedDouble.NaN,
+ CalculatedReliability = RoundedDouble.NaN
+ });
+
+ // Call
+ DuneLocationOutputEntity entity = output.Create();
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.IsNull(entity.WaterLevel);
+ Assert.IsNull(entity.WaveHeight);
+ Assert.IsNull(entity.WavePeriod);
+ Assert.IsNull(entity.TargetProbability);
+ Assert.IsNull(entity.TargetReliability);
+ Assert.IsNull(entity.CalculatedProbability);
+ Assert.IsNull(entity.CalculatedReliability);
+ Assert.AreEqual((byte) output.CalculationConvergence, entity.CalculationConvergence);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/GeneralDuneErosionInputCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/GeneralDuneErosionInputCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/DuneErosion/GeneralDuneErosionInputCreateExtensionsTest.cs (revision 5d8400ac58258556db30c8bada70701332d687a8)
@@ -0,0 +1,71 @@
+// Copyright (C) Stichting Deltares 2016. 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 Application.Ringtoets.Storage.Create.DuneErosion;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.DuneErosion.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create.DuneErosion
+{
+ [TestFixture]
+ public class GeneralDuneErosionInputCreateExtensionsTest
+ {
+ [Test]
+ public void Create_NullInput_ThrowsArgumentNullException()
+ {
+ // Setup
+ GeneralDuneErosionInput generalinput = null;
+
+ // Call
+ TestDelegate call = () => generalinput.Create();
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("input", paramName);
+ }
+
+ [Test]
+ public void Create_ValidInput_ReturnMetaEntity()
+ {
+ // Setup
+ var random = new Random(45);
+ var generalinput = new GeneralDuneErosionInput
+ {
+ N = (RoundedDouble) random.GetFromRange(1, 20)
+ };
+
+ // Call
+ DuneErosionFailureMechanismMetaEntity entity = generalinput.Create();
+
+ // Assert
+ Assert.AreEqual(generalinput.N, entity.N, generalinput.N.GetAccuracy());
+
+ Assert.IsNull(entity.FailureMechanismEntity);
+ Assert.AreEqual(0, entity.DuneErosionFailureMechanismMetaEntityId);
+ Assert.AreEqual(0, entity.FailureMechanismEntityId);
+ }
+ }
+}
\ No newline at end of file