Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r29ce0aca4c6fd2ec13fb73e10bd14f32d6b821c9 -rfcfed8afc6a404167356e37de68e18d561af7389
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 29ce0aca4c6fd2ec13fb73e10bd14f32d6b821c9)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision fcfed8afc6a404167356e37de68e18d561af7389)
@@ -46,7 +46,7 @@
-
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationCalculationOutputCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationCalculationOutputCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationCalculationOutputCreateExtensions.cs (revision fcfed8afc6a404167356e37de68e18d561af7389)
@@ -0,0 +1,60 @@
+// 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 Application.Ringtoets.Storage.Create.IllustrationPoints;
+using Application.Ringtoets.Storage.DbContext;
+using Ringtoets.Common.Data.Hydraulics;
+
+namespace Application.Ringtoets.Storage.Create
+{
+ ///
+ /// Extension methods for related to creating a hydraulic boundary location output entity.
+ ///
+ internal static class HydraulicBoundaryLocationCalculationOutputCreateExtensions
+ {
+ ///
+ /// Creates a based
+ /// on the information of the .
+ ///
+ /// The output to create a database entity for.
+ /// A new .
+ /// Thrown when is null.
+ internal static HydraulicLocationOutputEntity CreateHydraulicLocationOutputEntity(this HydraulicBoundaryLocationCalculationOutput output)
+ {
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+
+ return new HydraulicLocationOutputEntity
+ {
+ Result = output.Result.ToNaNAsNull(),
+ TargetProbability = output.TargetProbability.ToNaNAsNull(),
+ TargetReliability = output.TargetReliability.ToNaNAsNull(),
+ CalculatedProbability = output.CalculatedProbability.ToNaNAsNull(),
+ CalculatedReliability = output.CalculatedReliability.ToNaNAsNull(),
+ CalculationConvergence = (byte) output.CalculationConvergence,
+ GeneralResultSubMechanismIllustrationPointEntity = output.GeneralResult?.CreateGeneralResultSubMechanismIllustrationPointEntity()
+ };
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag fcfed8afc6a404167356e37de68e18d561af7389 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationOutputCreateExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r29ce0aca4c6fd2ec13fb73e10bd14f32d6b821c9 -rfcfed8afc6a404167356e37de68e18d561af7389
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 29ce0aca4c6fd2ec13fb73e10bd14f32d6b821c9)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision fcfed8afc6a404167356e37de68e18d561af7389)
@@ -56,7 +56,7 @@
-
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCalculationOutputCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCalculationOutputCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCalculationOutputCreateExtensionsTest.cs (revision fcfed8afc6a404167356e37de68e18d561af7389)
@@ -0,0 +1,151 @@
+// 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.Create;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Data.TestUtil.IllustrationPoints;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class HydraulicBoundaryLocationCalculationOutputCreateExtensionsTest
+ {
+ [Test]
+ public void CreateHydraulicLocationOutputEntity_HydraulicBoundaryLocationCalculationOutputNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((HydraulicBoundaryLocationCalculationOutput) null).CreateHydraulicLocationOutputEntity();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("output", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateHydraulicLocationOutputEntity_WithValidParameters_ReturnsHydraulicLocationEntityWithOutputSet()
+ {
+ // Setup
+ var random = new Random(21);
+ var output = new HydraulicBoundaryLocationCalculationOutput(
+ random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(),
+ random.NextDouble(), random.NextEnumValue(), null);
+
+ // Call
+ HydraulicLocationOutputEntity entity = output.CreateHydraulicLocationOutputEntity();
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(output.Result, entity.Result, output.Result.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);
+
+ AssertGeneralResult(output.GeneralResult, entity.GeneralResultSubMechanismIllustrationPointEntity);
+ }
+
+ [Test]
+ public void CreateHydraulicLocationOutputEntity_WithNaNParameters_ReturnsHydraulicLocationEntityWithOutputNaN()
+ {
+ // Setup
+ var random = new Random(21);
+ var output = new HydraulicBoundaryLocationCalculationOutput(double.NaN, double.NaN, double.NaN,
+ double.NaN, double.NaN, random.NextEnumValue(), null);
+
+ // Call
+ HydraulicLocationOutputEntity entity = output.CreateHydraulicLocationOutputEntity();
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.IsNull(entity.Result);
+ Assert.IsNull(entity.TargetProbability);
+ Assert.IsNull(entity.TargetReliability);
+ Assert.IsNull(entity.CalculatedProbability);
+ Assert.IsNull(entity.CalculatedReliability);
+ Assert.AreEqual((byte) output.CalculationConvergence, entity.CalculationConvergence);
+
+ AssertGeneralResult(output.GeneralResult, entity.GeneralResultSubMechanismIllustrationPointEntity);
+ }
+
+ [Test]
+ public void CreateHydraulicLocationOutputEntity_WithGeneralResult_ReturnsHydraulicLocationEntityWithGeneralResult()
+ {
+ // Setup
+ var random = new Random(21);
+ var output = new HydraulicBoundaryLocationCalculationOutput(double.NaN, double.NaN, double.NaN,
+ double.NaN, double.NaN, random.NextEnumValue(),
+ GetGeneralResult());
+
+ // Call
+ HydraulicLocationOutputEntity entity = output.CreateHydraulicLocationOutputEntity();
+
+ // Assert
+ AssertGeneralResult(output.GeneralResult, entity.GeneralResultSubMechanismIllustrationPointEntity);
+ }
+
+ private static GeneralResult GetGeneralResult()
+ {
+ var random = new Random(55);
+ var generalResult = new GeneralResult(
+ WindDirectionTestFactory.CreateTestWindDirection(),
+ new[]
+ {
+ new Stochast("stochastOne", random.NextDouble(), random.NextDouble())
+ },
+ new[]
+ {
+ new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(),
+ "IllustrationPointTwo",
+ new TestSubMechanismIllustrationPoint())
+ });
+
+ return generalResult;
+ }
+
+ private static void AssertGeneralResult(GeneralResult illustrationPoint,
+ GeneralResultSubMechanismIllustrationPointEntity entity)
+ {
+ if (illustrationPoint == null)
+ {
+ Assert.IsNull(entity);
+ return;
+ }
+
+ Assert.IsNotNull(entity);
+ WindDirection governingWindDirection = illustrationPoint.GoverningWindDirection;
+ TestHelper.AssertAreEqualButNotSame(governingWindDirection.Name, entity.GoverningWindDirectionName);
+ Assert.AreEqual(governingWindDirection.Angle, entity.GoverningWindDirectionAngle,
+ governingWindDirection.Angle.GetAccuracy());
+
+ Assert.AreEqual(illustrationPoint.Stochasts.Count(), entity.StochastEntities.Count);
+ Assert.AreEqual(illustrationPoint.TopLevelIllustrationPoints.Count(),
+ entity.TopLevelSubMechanismIllustrationPointEntities.Count);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag fcfed8afc6a404167356e37de68e18d561af7389 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationOutputCreateExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs
===================================================================
diff -u -rda7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7 -rfcfed8afc6a404167356e37de68e18d561af7389
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision da7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision fcfed8afc6a404167356e37de68e18d561af7389)
@@ -2112,11 +2112,11 @@
{
AssertHydraulicBoundaryLocation(expected.HydraulicBoundaryLocation, actual.HydraulicBoundaryLocation);
Assert.AreEqual(expected.InputParameters.ShouldIllustrationPointsBeCalculated, actual.InputParameters.ShouldIllustrationPointsBeCalculated);
- AssertHydraulicBoundaryLocationOutput(expected.Output, actual.Output);
+ AssertHydraulicBoundaryLocationCalculationOutput(expected.Output, actual.Output);
}
- private static void AssertHydraulicBoundaryLocationOutput(HydraulicBoundaryLocationCalculationOutput expectedOutput,
- HydraulicBoundaryLocationCalculationOutput actualOutput)
+ private static void AssertHydraulicBoundaryLocationCalculationOutput(HydraulicBoundaryLocationCalculationOutput expectedOutput,
+ HydraulicBoundaryLocationCalculationOutput actualOutput)
{
if (expectedOutput == null)
{
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HydraulicLocationOutputEntityReadExtensionsTest.cs
===================================================================
diff -u -rda7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7 -rfcfed8afc6a404167356e37de68e18d561af7389
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HydraulicLocationOutputEntityReadExtensionsTest.cs (.../HydraulicLocationOutputEntityReadExtensionsTest.cs) (revision da7bb9a6d96d7118d6dcdc2ee17a11d5b43f44c7)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HydraulicLocationOutputEntityReadExtensionsTest.cs (.../HydraulicLocationOutputEntityReadExtensionsTest.cs) (revision fcfed8afc6a404167356e37de68e18d561af7389)
@@ -47,7 +47,7 @@
}
[Test]
- public void Read_ValidParameters_ReturnsHydraulicBoundaryLocationOutput()
+ public void Read_ValidParameters_ReturnsHydraulicBoundaryLocationCalculationOutput()
{
// Setup
var random = new Random(22);
@@ -81,7 +81,7 @@
}
[Test]
- public void Read_NaNParameters_ReturnsHydraulicBoundaryLocationOutputWithNaN()
+ public void Read_NaNParameters_ReturnsHydraulicBoundaryLocationCalculationOutputWithNaN()
{
// Setup
var random = new Random(21);
@@ -111,7 +111,7 @@
}
[Test]
- public void Read_EntityWithIllustrationPoints_ReturnsHydraulicBoundaryLocationOutputWithGeneralResult()
+ public void Read_EntityWithIllustrationPoints_ReturnsHydraulicBoundaryLocationCalculationOutputWithGeneralResult()
{
// Setup
var random = new Random(21);