Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r64ad0bbe91a9c7e9229fa9800b93b65f619b9e31 -rcecb97ce5adb57cec9f89b557d6fafce09c9ed65
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 64ad0bbe91a9c7e9229fa9800b93b65f619b9e31)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -248,7 +248,7 @@
-
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructureEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructureEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructureEntityReadExtensions.cs (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -0,0 +1,99 @@
+// 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.Base.Data;
+using Core.Common.Base.Geometry;
+using Ringtoets.HeightStructures.Data;
+
+namespace Application.Ringtoets.Storage.Read.HeightStructures
+{
+ ///
+ /// This class defines extension methods for read operations for a
+ /// based on the .
+ ///
+ internal static class HeightStructureEntityReadExtensions
+ {
+ ///
+ /// Reads the and use the information to update a
+ /// .
+ ///
+ /// The to create for.
+ /// The object keeping track of read operations.
+ /// A new .
+ /// Thrown when is null.
+ internal static HeightStructure Read(this HeightStructureEntity entity, ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+ if (collector.Contains(entity))
+ {
+ return collector.Get(entity);
+ }
+
+ var structure = new HeightStructure(new HeightStructure.ConstructionProperties
+ {
+ Name = entity.Name,
+ Id = entity.Id,
+ Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()),
+ StructureNormalOrientation = entity.StructureNormalOrientation.ToNullAsNaN(),
+ LevelCrestStructure =
+ {
+ Mean = (RoundedDouble) entity.LevelCrestStructureMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.LevelCrestStructureStandardDeviation.ToNullAsNaN()
+ },
+ FlowWidthAtBottomProtection =
+ {
+ Mean = (RoundedDouble) entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN()
+ },
+ CriticalOvertoppingDischarge =
+ {
+ Mean = (RoundedDouble) entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(),
+ CoefficientOfVariation = (RoundedDouble) entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN()
+ },
+ WidthFlowApertures =
+ {
+ Mean = (RoundedDouble) entity.WidthFlowAperturesMean.ToNullAsNaN(),
+ CoefficientOfVariation = (RoundedDouble) entity.WidthFlowAperturesCoefficientOfVariation.ToNullAsNaN()
+ },
+ FailureProbabilityStructureWithErosion = entity.FailureProbabilityStructureWithErosion.ToNullAsNaN(),
+ StorageStructureArea =
+ {
+ Mean = (RoundedDouble) entity.StorageStructureAreaMean.ToNullAsNaN(),
+ CoefficientOfVariation = (RoundedDouble) entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN()
+ },
+ AllowedLevelIncreaseStorage =
+ {
+ Mean = (RoundedDouble) entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN()
+ }
+ });
+
+ collector.Read(entity, structure);
+
+ return structure;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensions.cs
===================================================================
diff -u -r64ad0bbe91a9c7e9229fa9800b93b65f619b9e31 -rcecb97ce5adb57cec9f89b557d6fafce09c9ed65
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensions.cs (.../HeightStructuresCalculationEntityReadExtensions.cs) (revision 64ad0bbe91a9c7e9229fa9800b93b65f619b9e31)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensions.cs (.../HeightStructuresCalculationEntityReadExtensions.cs) (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -22,6 +22,7 @@
using System;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Base.Data;
+using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.Common.Data.Structures;
using Ringtoets.HeightStructures.Data;
@@ -79,7 +80,13 @@
inputParameters.FlowWidthAtBottomProtection.StandardDeviation = (RoundedDouble) entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN();
inputParameters.CriticalOvertoppingDischarge.Mean = (RoundedDouble) entity.CriticalOvertoppingDischargeMean.ToNullAsNaN();
inputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation = (RoundedDouble) entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN();
- inputParameters.FailureProbabilityStructureWithErosion = entity.FailureProbabilityStructureWithErosion.ToNullAsNaN();
+
+ double failureProbabilityStructureWithErosion = entity.FailureProbabilityStructureWithErosion.ToNullAsNaN();
+ if (!double.IsNaN(failureProbabilityStructureWithErosion) && double.IsNaN(inputParameters.FailureProbabilityStructureWithErosion))
+ {
+ inputParameters.FailureProbabilityStructureWithErosion = failureProbabilityStructureWithErosion;
+ }
+
inputParameters.WidthFlowApertures.Mean = (RoundedDouble) entity.WidthFlowAperturesMean.ToNullAsNaN();
inputParameters.WidthFlowApertures.CoefficientOfVariation = (RoundedDouble) entity.WidthFlowAperturesCoefficientOfVariation.ToNullAsNaN();
Fisheye: Tag cecb97ce5adb57cec9f89b557d6fafce09c9ed65 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HeightStructures/HeightStructuresEntityReadExtensions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r64ad0bbe91a9c7e9229fa9800b93b65f619b9e31 -rcecb97ce5adb57cec9f89b557d6fafce09c9ed65
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 64ad0bbe91a9c7e9229fa9800b93b65f619b9e31)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -97,7 +97,7 @@
-
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructureCreateExtensionsTest.cs
===================================================================
diff -u -r583a729a502f52ca415627efcb2287886e8efb1d -rcecb97ce5adb57cec9f89b557d6fafce09c9ed65
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructureCreateExtensionsTest.cs (.../HeightStructureCreateExtensionsTest.cs) (revision 583a729a502f52ca415627efcb2287886e8efb1d)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructureCreateExtensionsTest.cs (.../HeightStructureCreateExtensionsTest.cs) (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -49,7 +49,7 @@
}
[Test]
- public void Create_ValidStrucuture_ReturnEntity()
+ public void Create_ValidStructure_ReturnEntity()
{
// Setup
HeightStructure structure = new TestHeightStructure();
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/CalculationGroupEntityReadExtentionsTest.cs
===================================================================
diff -u -r64ad0bbe91a9c7e9229fa9800b93b65f619b9e31 -rcecb97ce5adb57cec9f89b557d6fafce09c9ed65
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/CalculationGroupEntityReadExtentionsTest.cs (.../CalculationGroupEntityReadExtentionsTest.cs) (revision 64ad0bbe91a9c7e9229fa9800b93b65f619b9e31)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/CalculationGroupEntityReadExtentionsTest.cs (.../CalculationGroupEntityReadExtentionsTest.cs) (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -797,14 +797,12 @@
new HeightStructuresCalculationEntity
{
Order = 0,
- Name = "1",
- FailureProbabilityStructureWithErosion = 1
+ Name = "1"
},
new HeightStructuresCalculationEntity
{
Order = 1,
- Name = "2",
- FailureProbabilityStructureWithErosion = 1
+ Name = "2"
}
}
};
@@ -837,14 +835,12 @@
new HeightStructuresCalculationEntity
{
Order = 0,
- Name = "calculation1",
- FailureProbabilityStructureWithErosion = 1
+ Name = "calculation1"
},
new HeightStructuresCalculationEntity
{
Order = 2,
- Name = "calculation2",
- FailureProbabilityStructureWithErosion = 1
+ Name = "calculation2"
}
},
CalculationGroupEntity1 =
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructureEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructureEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructureEntityReadExtensionsTest.cs (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -0,0 +1,171 @@
+// 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 Application.Ringtoets.Storage.Read;
+using Application.Ringtoets.Storage.Read.HeightStructures;
+using NUnit.Framework;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.HeightStructures.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Read.HeightStructures
+{
+ [TestFixture]
+ public class HeightStructureEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_ReadConversionCollectorNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var entity = new HeightStructureEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Read_ValidEntity_ReturnHeightStructure()
+ {
+ // Setup
+ var entity = new HeightStructureEntity
+ {
+ Name = "A",
+ Id = "B",
+ X = 1.1,
+ Y = 2.2,
+ StructureNormalOrientation = 3.3,
+ LevelCrestStructureMean = 4.4,
+ LevelCrestStructureStandardDeviation = 5.5,
+ FlowWidthAtBottomProtectionMean = 6.6,
+ FlowWidthAtBottomProtectionStandardDeviation = 7.7,
+ CriticalOvertoppingDischargeMean = 8.8,
+ CriticalOvertoppingDischargeCoefficientOfVariation = 9.9,
+ WidthFlowAperturesMean = 10.10,
+ WidthFlowAperturesCoefficientOfVariation = 11.11,
+ FailureProbabilityStructureWithErosion = 12.12,
+ StorageStructureAreaMean = 13.13,
+ StorageStructureAreaCoefficientOfVariation = 14.14,
+ AllowedLevelIncreaseStorageMean = 15.15,
+ AllowedLevelIncreaseStorageStandardDeviation = 16.16
+ };
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ HeightStructure structure = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(entity.Name, structure.Name);
+ Assert.AreEqual(entity.Id, structure.Id);
+ Assert.AreEqual(entity.X, structure.Location.X);
+ Assert.AreEqual(entity.Y, structure.Location.Y);
+ Assert.AreEqual(entity.StructureNormalOrientation, structure.StructureNormalOrientation.Value);
+
+ Assert.AreEqual(entity.LevelCrestStructureMean, structure.LevelCrestStructure.Mean.Value);
+ Assert.AreEqual(entity.LevelCrestStructureStandardDeviation, structure.LevelCrestStructure.StandardDeviation.Value);
+ Assert.AreEqual(entity.FlowWidthAtBottomProtectionMean, structure.FlowWidthAtBottomProtection.Mean.Value);
+ Assert.AreEqual(entity.FlowWidthAtBottomProtectionStandardDeviation, structure.FlowWidthAtBottomProtection.StandardDeviation.Value);
+ Assert.AreEqual(entity.CriticalOvertoppingDischargeMean, structure.CriticalOvertoppingDischarge.Mean.Value);
+ Assert.AreEqual(entity.CriticalOvertoppingDischargeCoefficientOfVariation, structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value);
+ Assert.AreEqual(entity.WidthFlowAperturesMean, structure.WidthFlowApertures.Mean.Value);
+ Assert.AreEqual(entity.WidthFlowAperturesCoefficientOfVariation, structure.WidthFlowApertures.CoefficientOfVariation.Value);
+ Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, structure.FailureProbabilityStructureWithErosion);
+ Assert.AreEqual(entity.StorageStructureAreaMean, structure.StorageStructureArea.Mean.Value);
+ Assert.AreEqual(entity.StorageStructureAreaCoefficientOfVariation, structure.StorageStructureArea.CoefficientOfVariation.Value);
+ Assert.AreEqual(entity.AllowedLevelIncreaseStorageMean, structure.AllowedLevelIncreaseStorage.Mean.Value);
+ Assert.AreEqual(entity.AllowedLevelIncreaseStorageStandardDeviation, structure.AllowedLevelIncreaseStorage.StandardDeviation.Value);
+
+ Assert.IsTrue(collector.Contains(entity));
+ }
+
+ [Test]
+ public void Read_NullValues_ReturnHeightStructureWithNaN()
+ {
+ // Setup
+ var entity = new HeightStructureEntity
+ {
+ Name = "A",
+ Id = "B",
+ X = null,
+ Y = null,
+ StructureNormalOrientation = null,
+ LevelCrestStructureMean = null,
+ LevelCrestStructureStandardDeviation = null,
+ FlowWidthAtBottomProtectionMean = null,
+ FlowWidthAtBottomProtectionStandardDeviation = null,
+ CriticalOvertoppingDischargeMean = null,
+ CriticalOvertoppingDischargeCoefficientOfVariation = null,
+ WidthFlowAperturesMean = null,
+ WidthFlowAperturesCoefficientOfVariation = null,
+ FailureProbabilityStructureWithErosion = null,
+ StorageStructureAreaMean = null,
+ StorageStructureAreaCoefficientOfVariation = null,
+ AllowedLevelIncreaseStorageMean = null,
+ AllowedLevelIncreaseStorageStandardDeviation = null
+ };
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ HeightStructure structure = entity.Read(collector);
+
+ // Assert
+ Assert.IsNaN(structure.Location.X);
+ Assert.IsNaN(structure.Location.Y);
+ Assert.IsNaN(structure.StructureNormalOrientation);
+
+ Assert.IsNaN(structure.LevelCrestStructure.Mean.Value);
+ Assert.IsNaN(structure.LevelCrestStructure.StandardDeviation.Value);
+ Assert.IsNaN(structure.FlowWidthAtBottomProtection.Mean.Value);
+ Assert.IsNaN(structure.FlowWidthAtBottomProtection.StandardDeviation.Value);
+ Assert.IsNaN(structure.CriticalOvertoppingDischarge.Mean.Value);
+ Assert.IsNaN(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value);
+ Assert.IsNaN(structure.WidthFlowApertures.Mean.Value);
+ Assert.IsNaN(structure.WidthFlowApertures.CoefficientOfVariation.Value);
+ Assert.IsNaN(structure.FailureProbabilityStructureWithErosion);
+ Assert.IsNaN(structure.StorageStructureArea.Mean.Value);
+ Assert.IsNaN(structure.StorageStructureArea.CoefficientOfVariation.Value);
+ Assert.IsNaN(structure.AllowedLevelIncreaseStorage.Mean.Value);
+ Assert.IsNaN(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value);
+ }
+
+ [Test]
+ public void Read_EntityRegistered_ReturnRegisteredStructure()
+ {
+ // Setup
+ var entity = new HeightStructureEntity();
+ HeightStructure registeredStructure = new TestHeightStructure();
+ var collector = new ReadConversionCollector();
+ collector.Read(entity, registeredStructure);
+
+ // Call
+ HeightStructure readStructure = entity.Read(collector);
+
+ // Assert
+ Assert.AreSame(registeredStructure, readStructure);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensionsTest.cs
===================================================================
diff -u -r64ad0bbe91a9c7e9229fa9800b93b65f619b9e31 -rcecb97ce5adb57cec9f89b557d6fafce09c9ed65
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensionsTest.cs (.../HeightStructuresCalculationEntityReadExtensionsTest.cs) (revision 64ad0bbe91a9c7e9229fa9800b93b65f619b9e31)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresCalculationEntityReadExtensionsTest.cs (.../HeightStructuresCalculationEntityReadExtensionsTest.cs) (revision cecb97ce5adb57cec9f89b557d6fafce09c9ed65)
@@ -136,8 +136,7 @@
UseBreakWater = Convert.ToByte(!flagUsage),
ForeshoreProfileEntity = foreshoreEntity,
BreakWaterType = Convert.ToInt16(type),
- BreakWaterHeight = breakWaterHeight,
- FailureProbabilityStructureWithErosion = 1
+ BreakWaterHeight = breakWaterHeight
};
var collector = new ReadConversionCollector();
Fisheye: Tag cecb97ce5adb57cec9f89b557d6fafce09c9ed65 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HeightStructures/HeightStructuresEntityReadExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?