Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r5b4d76a9812fa9c9f06529c05fe47d6aafdb479c -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 5b4d76a9812fa9c9f06529c05fe47d6aafdb479c)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -60,6 +60,7 @@
Properties\GlobalAssembly.cs
+
@@ -233,6 +234,7 @@
RingtoetsEntities.tt
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructureCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructureCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructureCreateExtensions.cs (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -0,0 +1,92 @@
+// 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.ClosingStructures.Data;
+
+namespace Application.Ringtoets.Storage.Create.ClosingStructures
+{
+ ///
+ /// Extension methods for related to creating
+ /// a .
+ ///
+ internal static class ClosingStructureCreateExtensions
+ {
+ ///
+ /// Creates a based on the information of the .
+ ///
+ /// The structure to create a database entity for.
+ /// The object keeping track of create operations.
+ /// The index at which resides within its parent.
+ /// A new .
+ /// Thrown when is null .
+ internal static ClosingStructureEntity Create(this ClosingStructure structure, PersistenceRegistry registry, int order)
+ {
+ if (registry == null)
+ {
+ throw new ArgumentNullException("registry");
+ }
+ if (registry.Contains(structure))
+ {
+ return registry.Get(structure);
+ }
+
+ var entity = new ClosingStructureEntity
+ {
+ Name = structure.Name.DeepClone(),
+ Id = structure.Id.DeepClone(),
+ X = structure.Location.X.ToNaNAsNull(),
+ Y = structure.Location.Y.ToNaNAsNull(),
+ StructureNormalOrientation = structure.StructureNormalOrientation.Value.ToNaNAsNull(),
+ StorageStructureAreaMean = structure.StorageStructureArea.Mean.Value.ToNaNAsNull(),
+ StorageStructureAreaCoefficientOfVariation = structure.StorageStructureArea.CoefficientOfVariation.Value.ToNaNAsNull(),
+ AllowedLevelIncreaseStorageMean = structure.AllowedLevelIncreaseStorage.Mean.Value.ToNaNAsNull(),
+ AllowedLevelIncreaseStorageStandardDeviation = structure.AllowedLevelIncreaseStorage.StandardDeviation.Value.ToNaNAsNull(),
+ WidthFlowAperturesMean = structure.WidthFlowApertures.Mean.Value.ToNaNAsNull(),
+ WidthFlowAperturesCoefficientOfVariation = structure.WidthFlowApertures.CoefficientOfVariation.Value.ToNaNAsNull(),
+ LevelCrestStructureNotClosingMean = structure.LevelCrestStructureNotClosing.Mean.Value.ToNaNAsNull(),
+ LevelCrestStructureNotClosingStandardDeviation = structure.LevelCrestStructureNotClosing.StandardDeviation.Value.ToNaNAsNull(),
+ InsideWaterLevelMean = structure.InsideWaterLevel.Mean.Value.ToNaNAsNull(),
+ InsideWaterLevelStandardDeviation = structure.InsideWaterLevel.StandardDeviation.Value.ToNaNAsNull(),
+ ThresholdHeightOpenWeirMean = structure.ThresholdHeightOpenWeir.Mean.Value.ToNaNAsNull(),
+ ThresholdHeightOpenWeirStandardDeviation = structure.ThresholdHeightOpenWeir.StandardDeviation.Value.ToNaNAsNull(),
+ AreaFlowAperturesMean = structure.AreaFlowApertures.Mean.Value.ToNaNAsNull(),
+ AreaFlowAperturesStandardDeviation = structure.AreaFlowApertures.StandardDeviation.Value.ToNaNAsNull(),
+ CriticalOvertoppingDischargeMean = structure.CriticalOvertoppingDischarge.Mean.Value.ToNaNAsNull(),
+ CriticalOvertoppingDischargeCoefficientOfVariation = structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value.ToNaNAsNull(),
+ FlowWidthAtBottomProtectionMean = structure.FlowWidthAtBottomProtection.Mean.Value.ToNaNAsNull(),
+ FlowWidthAtBottomProtectionStandardDeviation = structure.FlowWidthAtBottomProtection.StandardDeviation.Value.ToNaNAsNull(),
+ ProbabilityOpenStructureBeforeFlooding = structure.ProbabilityOpenStructureBeforeFlooding.ToNaNAsNull(),
+ FailureProbabilityOpenStructure = structure.FailureProbabilityOpenStructure.ToNaNAsNull(),
+ IdenticalApertures = structure.IdenticalApertures,
+ FailureProbabilityReparation = structure.FailureProbabilityReparation.ToNaNAsNull(),
+ InflowModelType = Convert.ToByte(structure.InflowModelType),
+ Order = order
+ };
+
+ registry.Register(entity, structure);
+
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs
===================================================================
diff -u -r583a729a502f52ca415627efcb2287886e8efb1d -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 583a729a502f52ca415627efcb2287886e8efb1d)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -24,6 +24,7 @@
using System.Linq;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Utils;
+using Ringtoets.ClosingStructures.Data;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.GrassCoverErosionInwards.Data;
@@ -52,6 +53,7 @@
private readonly Dictionary surfaceLines = CreateDictionary();
private readonly Dictionary hydraulicLocations = CreateDictionary();
private readonly Dictionary heightStructures = CreateDictionary();
+ private readonly Dictionary closingStructures = CreateDictionary();
private static Dictionary CreateDictionary()
{
@@ -272,6 +274,22 @@
Register(heightStructures, entity, model);
}
+ ///
+ /// Registers a create operation for and the
+ /// that was constructed with the information.
+ ///
+ /// The to be registered.
+ /// The to be registered.
+ /// Thrown when either:
+ ///
+ /// is null
+ /// is null
+ ///
+ internal void Register(ClosingStructureEntity entity, ClosingStructure model)
+ {
+ Register(closingStructures, entity, model);
+ }
+
#endregion
#region Contains Methods
@@ -386,6 +404,17 @@
return ContainsValue(grassCoverErosionInwardsCalculations, model);
}
+ ///
+ /// Checks whether a create operations has been registered for the given .
+ ///
+ /// The to check for.
+ /// true if the was registered before, false otherwise.
+ /// Thrown when is null .
+ internal bool Contains(ClosingStructure model)
+ {
+ return ContainsValue(closingStructures, model);
+ }
+
#endregion
#region Get Methods
@@ -559,6 +588,22 @@
return Get(heightStructures, model);
}
+ ///
+ /// Obtains the which was registered for the
+ /// given .
+ ///
+ /// The for which a read operation has been registered.
+ /// The constructed .
+ /// Thrown when is null .
+ /// Thrown when no create operation
+ /// has been registered for .
+ /// Use to find out whether a
+ /// create operation has been registered for .
+ internal ClosingStructureEntity Get(ClosingStructure model)
+ {
+ return Get(closingStructures, model);
+ }
+
#endregion
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructureEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructureEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructureEntityReadExtensions.cs (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -0,0 +1,118 @@
+// 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.ClosingStructures.Data;
+
+namespace Application.Ringtoets.Storage.Read.ClosingStructures
+{
+ ///
+ /// This class defines extension methods for read operations for a
+ /// based on the .
+ ///
+ internal static class ClosingStructureEntityReadExtensions
+ {
+ ///
+ /// 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 ClosingStructure Read(this ClosingStructureEntity entity, ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+ if (collector.Contains(entity))
+ {
+ return collector.Get(entity);
+ }
+
+ var structure = new ClosingStructure(new ClosingStructure.ConstructionProperties
+ {
+ Name = entity.Name,
+ Id = entity.Id,
+ Location = new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()),
+ StructureNormalOrientation = entity.StructureNormalOrientation.ToNullAsNaN(),
+ StorageStructureArea =
+ {
+ Mean = (RoundedDouble) entity.StorageStructureAreaMean.ToNullAsNaN(),
+ CoefficientOfVariation = (RoundedDouble) entity.StorageStructureAreaCoefficientOfVariation.ToNullAsNaN()
+ },
+ AllowedLevelIncreaseStorage =
+ {
+ Mean = (RoundedDouble) entity.AllowedLevelIncreaseStorageMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.AllowedLevelIncreaseStorageStandardDeviation.ToNullAsNaN()
+ },
+ WidthFlowApertures =
+ {
+ Mean = (RoundedDouble) entity.WidthFlowAperturesMean.ToNullAsNaN(),
+ CoefficientOfVariation = (RoundedDouble) entity.WidthFlowAperturesCoefficientOfVariation.ToNullAsNaN()
+ },
+ LevelCrestStructureNotClosing =
+ {
+ Mean = (RoundedDouble) entity.LevelCrestStructureNotClosingMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.LevelCrestStructureNotClosingStandardDeviation.ToNullAsNaN()
+ },
+ InsideWaterLevel =
+ {
+ Mean = (RoundedDouble) entity.InsideWaterLevelMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.InsideWaterLevelStandardDeviation.ToNullAsNaN()
+ },
+ ThresholdHeightOpenWeir =
+ {
+ Mean = (RoundedDouble) entity.ThresholdHeightOpenWeirMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.ThresholdHeightOpenWeirStandardDeviation.ToNullAsNaN()
+ },
+ AreaFlowApertures =
+ {
+ Mean = (RoundedDouble) entity.AreaFlowAperturesMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.AreaFlowAperturesStandardDeviation.ToNullAsNaN()
+ },
+ CriticalOvertoppingDischarge =
+ {
+ Mean = (RoundedDouble) entity.CriticalOvertoppingDischargeMean.ToNullAsNaN(),
+ CoefficientOfVariation = (RoundedDouble) entity.CriticalOvertoppingDischargeCoefficientOfVariation.ToNullAsNaN()
+ },
+ FlowWidthAtBottomProtection =
+ {
+ Mean = (RoundedDouble) entity.FlowWidthAtBottomProtectionMean.ToNullAsNaN(),
+ StandardDeviation = (RoundedDouble) entity.FlowWidthAtBottomProtectionStandardDeviation.ToNullAsNaN()
+ },
+ ProbabilityOpenStructureBeforeFlooding = entity.ProbabilityOpenStructureBeforeFlooding.ToNullAsNaN(),
+ FailureProbabilityOpenStructure = entity.FailureProbabilityOpenStructure.ToNullAsNaN(),
+ IdenticalApertures = (int) entity.IdenticalApertures,
+ FailureProbabilityReparation = entity.FailureProbabilityReparation.ToNullAsNaN(),
+ InflowModelType = (ClosingStructureInflowModelType) entity.InflowModelType,
+ });
+
+ collector.Read(entity, structure);
+
+ return structure;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs
===================================================================
diff -u -r583a729a502f52ca415627efcb2287886e8efb1d -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 583a729a502f52ca415627efcb2287886e8efb1d)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Utils;
+using Ringtoets.ClosingStructures.Data;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.GrassCoverErosionInwards.Data;
@@ -50,6 +51,7 @@
private readonly Dictionary foreshoreProfiles = CreateDictionary();
private readonly Dictionary grassCoverErosionInwardsCalculations = CreateDictionary();
private readonly Dictionary heightStructures = CreateDictionary();
+ private readonly Dictionary closingStructures = CreateDictionary();
private static Dictionary CreateDictionary()
{
@@ -847,5 +849,77 @@
}
#endregion
+
+ #region ClosingStructureEntity: Read, Contains, Get
+
+ ///
+ /// Registers a read operation for and the
+ /// that was constructed with the information.
+ ///
+ /// The that was read.
+ /// The that was constructed.
+ /// Thrown when either:
+ ///
+ /// is null
+ /// is null
+ ///
+ internal void Read(ClosingStructureEntity entity, ClosingStructure model)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ if (model == null)
+ {
+ throw new ArgumentNullException("model");
+ }
+
+ closingStructures[entity] = model;
+ }
+
+ ///
+ /// Checks whether a read operation has been registered for a given .
+ ///
+ /// The to check for.
+ /// true if the was read before, false otherwise.
+ /// Thrown when is null .
+ internal bool Contains(ClosingStructureEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ return closingStructures.ContainsKey(entity);
+ }
+
+ ///
+ /// Obtains the which was read for the
+ /// given .
+ ///
+ /// The for which a read
+ /// operation has been registered.
+ /// The constructed .
+ /// Thrown when is null .
+ /// Thrown when no read operation has
+ /// been registered for .
+ /// Use to find out whether a
+ /// read operation has been registered for .
+ internal ClosingStructure Get(ClosingStructureEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+ try
+ {
+ return closingStructures[entity];
+ }
+ catch (KeyNotFoundException e)
+ {
+ throw new InvalidOperationException(e.Message, e);
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r583a729a502f52ca415627efcb2287886e8efb1d -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 583a729a502f52ca415627efcb2287886e8efb1d)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -77,6 +77,7 @@
Properties\GlobalAssembly.cs
+
@@ -85,6 +86,7 @@
+
@@ -233,6 +235,10 @@
{C6309704-D67B-434C-BC98-9F8910BC1D10}
Ringtoets.ClosingStructures.Data
+
+ {f5b43c29-6169-4e9a-859e-09090330b94e}
+ Ringtoets.ClosingStructures.Data.TestUtil
+
{f67e8ae8-1ff0-4680-9817-99e025cd9ff6}
Ringtoets.HeightStructures.Data.TestUtil
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructureCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructureCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructureCreateExtensionsTest.cs (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -0,0 +1,208 @@
+// 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;
+using Application.Ringtoets.Storage.Create.ClosingStructures;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.ClosingStructures.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Create.ClosingStructures
+{
+ [TestFixture]
+ public class ClosingStructureCreateExtensionsTest
+ {
+ [Test]
+ public void Create_PersistenceRegistryNull_ThrowArgumentNullException()
+ {
+ // Setup
+ ClosingStructure structure = new TestClosingStructure();
+
+ // Call
+ TestDelegate call = () => structure.Create(null, 0);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("registry", paramName);
+ }
+
+ [Test]
+ public void Create_ValidStrucuture_ReturnEntity()
+ {
+ // Setup
+ ClosingStructure structure = new TestClosingStructure();
+ var registry = new PersistenceRegistry();
+
+ const int order = 4;
+
+ // Call
+ ClosingStructureEntity entity = structure.Create(registry, order);
+
+ // Assert
+ Assert.AreEqual(structure.Name, entity.Name);
+ Assert.AreNotSame(structure.Name, entity.Name);
+ Assert.AreEqual(structure.Id, entity.Id);
+ Assert.AreNotSame(structure.Id, entity.Id);
+ Assert.AreEqual(structure.Location.X, entity.X);
+ Assert.AreEqual(structure.Location.Y, entity.Y);
+ Assert.AreEqual(structure.StructureNormalOrientation.Value, entity.StructureNormalOrientation);
+
+ Assert.AreEqual(structure.StorageStructureArea.Mean.Value, entity.StorageStructureAreaMean);
+ Assert.AreEqual(structure.StorageStructureArea.CoefficientOfVariation.Value, entity.StorageStructureAreaCoefficientOfVariation);
+ Assert.AreEqual(structure.AllowedLevelIncreaseStorage.Mean.Value, entity.AllowedLevelIncreaseStorageMean);
+ Assert.AreEqual(structure.AllowedLevelIncreaseStorage.StandardDeviation.Value, entity.AllowedLevelIncreaseStorageStandardDeviation);
+ Assert.AreEqual(structure.WidthFlowApertures.Mean.Value, entity.WidthFlowAperturesMean);
+ Assert.AreEqual(structure.WidthFlowApertures.CoefficientOfVariation.Value, entity.WidthFlowAperturesCoefficientOfVariation);
+ Assert.AreEqual(structure.LevelCrestStructureNotClosing.Mean.Value, entity.LevelCrestStructureNotClosingMean);
+ Assert.AreEqual(structure.LevelCrestStructureNotClosing.StandardDeviation.Value, entity.LevelCrestStructureNotClosingStandardDeviation);
+ Assert.AreEqual(structure.InsideWaterLevel.Mean.Value, entity.InsideWaterLevelMean);
+ Assert.AreEqual(structure.InsideWaterLevel.StandardDeviation.Value, entity.InsideWaterLevelStandardDeviation);
+ Assert.AreEqual(structure.ThresholdHeightOpenWeir.Mean.Value, entity.ThresholdHeightOpenWeirMean);
+ Assert.AreEqual(structure.ThresholdHeightOpenWeir.StandardDeviation.Value, entity.ThresholdHeightOpenWeirStandardDeviation);
+ Assert.AreEqual(structure.AreaFlowApertures.Mean.Value, entity.AreaFlowAperturesMean);
+ Assert.AreEqual(structure.AreaFlowApertures.StandardDeviation.Value, entity.AreaFlowAperturesStandardDeviation);
+ Assert.AreEqual(structure.CriticalOvertoppingDischarge.Mean.Value, entity.CriticalOvertoppingDischargeMean);
+ Assert.AreEqual(structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value, entity.CriticalOvertoppingDischargeCoefficientOfVariation);
+ Assert.AreEqual(structure.FlowWidthAtBottomProtection.Mean.Value, entity.FlowWidthAtBottomProtectionMean);
+ Assert.AreEqual(structure.FlowWidthAtBottomProtection.StandardDeviation.Value, entity.FlowWidthAtBottomProtectionStandardDeviation);
+ Assert.AreEqual(structure.ProbabilityOpenStructureBeforeFlooding, entity.ProbabilityOpenStructureBeforeFlooding);
+ Assert.AreEqual(structure.FailureProbabilityOpenStructure, entity.FailureProbabilityOpenStructure);
+ Assert.AreEqual(structure.IdenticalApertures, entity.IdenticalApertures);
+ Assert.AreEqual(structure.FailureProbabilityReparation, entity.FailureProbabilityReparation);
+ Assert.AreEqual(Convert.ToByte(structure.InflowModelType), entity.InflowModelType);
+ Assert.AreEqual(order, entity.Order);
+
+ Assert.IsTrue(registry.Contains(structure));
+ }
+
+ [Test]
+ public void Create_NaNValue_ReturnEntityWithNullValue()
+ {
+ // Setup
+ ClosingStructure structure = new ClosingStructure(new ClosingStructure.ConstructionProperties
+ {
+ Name = "A",
+ Id = "B",
+ Location = new Point2D(double.NaN, double.NaN),
+ StructureNormalOrientation = double.NaN,
+ StorageStructureArea =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ CoefficientOfVariation = (RoundedDouble)double.NaN
+ },
+ AllowedLevelIncreaseStorage =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ StandardDeviation = (RoundedDouble)double.NaN
+ },
+ WidthFlowApertures =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ CoefficientOfVariation = (RoundedDouble)double.NaN
+ },
+ LevelCrestStructureNotClosing =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ StandardDeviation = (RoundedDouble)double.NaN
+ },
+ InsideWaterLevel =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ StandardDeviation = (RoundedDouble)double.NaN
+ },
+ ThresholdHeightOpenWeir =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ StandardDeviation = (RoundedDouble)double.NaN
+ },
+ AreaFlowApertures =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ StandardDeviation = (RoundedDouble)double.NaN
+ },
+ CriticalOvertoppingDischarge =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ CoefficientOfVariation = (RoundedDouble)double.NaN
+ },
+ FlowWidthAtBottomProtection =
+ {
+ Mean = (RoundedDouble)double.NaN,
+ StandardDeviation = (RoundedDouble)double.NaN
+ },
+ ProbabilityOpenStructureBeforeFlooding = double.NaN,
+ FailureProbabilityOpenStructure = double.NaN,
+ FailureProbabilityReparation = double.NaN
+ });
+ var registry = new PersistenceRegistry();
+
+ // Call
+ ClosingStructureEntity entity = structure.Create(registry, 0);
+
+ // Assert
+ Assert.IsNull(entity.X);
+ Assert.IsNull(entity.Y);
+ Assert.IsNull(entity.StructureNormalOrientation);
+ Assert.IsNull(entity.StorageStructureAreaMean);
+ Assert.IsNull(entity.StorageStructureAreaCoefficientOfVariation);
+ Assert.IsNull(entity.AllowedLevelIncreaseStorageMean);
+ Assert.IsNull(entity.AllowedLevelIncreaseStorageStandardDeviation);
+ Assert.IsNull(entity.WidthFlowAperturesMean);
+ Assert.IsNull(entity.WidthFlowAperturesCoefficientOfVariation);
+ Assert.IsNull(entity.LevelCrestStructureNotClosingMean);
+ Assert.IsNull(entity.LevelCrestStructureNotClosingStandardDeviation);
+ Assert.IsNull(entity.InsideWaterLevelMean);
+ Assert.IsNull(entity.InsideWaterLevelStandardDeviation);
+ Assert.IsNull(entity.ThresholdHeightOpenWeirMean);
+ Assert.IsNull(entity.ThresholdHeightOpenWeirStandardDeviation);
+ Assert.IsNull(entity.AreaFlowAperturesMean);
+ Assert.IsNull(entity.AreaFlowAperturesStandardDeviation);
+ Assert.IsNull(entity.CriticalOvertoppingDischargeMean);
+ Assert.IsNull(entity.CriticalOvertoppingDischargeCoefficientOfVariation);
+ Assert.IsNull(entity.FlowWidthAtBottomProtectionMean);
+ Assert.IsNull(entity.FlowWidthAtBottomProtectionStandardDeviation);
+ Assert.IsNull(entity.ProbabilityOpenStructureBeforeFlooding);
+ Assert.IsNull(entity.FailureProbabilityOpenStructure);
+ Assert.IsNull(entity.FailureProbabilityReparation);
+ }
+
+ [Test]
+ public void Create_StructureAlreadyRegistered_ReturnRegisteredEntity()
+ {
+ // Setup
+ ClosingStructure structure = new TestClosingStructure();
+
+ var registeredEntity = new ClosingStructureEntity();
+ var registry = new PersistenceRegistry();
+ registry.Register(registeredEntity, structure);
+
+ // Call
+ ClosingStructureEntity entity = structure.Create(registry, 0);
+
+ // Assert
+ Assert.AreSame(registeredEntity, entity);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs
===================================================================
diff -u -re42bdf3dd379c46bab9212eb7b30f4754c9bc91c -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision e42bdf3dd379c46bab9212eb7b30f4754c9bc91c)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -25,6 +25,8 @@
using Application.Ringtoets.Storage.TestUtil;
using Core.Common.Base.Geometry;
using NUnit.Framework;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.ClosingStructures.Data.TestUtil;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.GrassCoverErosionInwards.Data;
@@ -638,6 +640,67 @@
Assert.IsFalse(result);
}
+ [Test]
+ public void Contains_WithoutClosingStructure_ThrowsArgumentNullException()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ // Call
+ TestDelegate call = () => registry.Contains((ClosingStructure)null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("model", paramName);
+ }
+
+ [Test]
+ public void Contains_ClosingStructureAdded_ReturnsTrue()
+ {
+ // Setup
+ ClosingStructure closingStructure = new TestClosingStructure();
+ var registry = new PersistenceRegistry();
+ registry.Register(new ClosingStructureEntity(), closingStructure);
+
+ // Call
+ bool result = registry.Contains(closingStructure);
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void Contains_OtherClosingStructureAdded_ReturnsFalse()
+ {
+ // Setup
+ ClosingStructure closingStructure = new TestClosingStructure();
+
+ ClosingStructure otherStructure = new TestClosingStructure();
+ var registry = new PersistenceRegistry();
+ registry.Register(new ClosingStructureEntity(), otherStructure);
+
+ // Call
+ bool result = registry.Contains(closingStructure);
+
+ // Assert
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void Contains_NoClosingStructureAdded_ReturnsFalse()
+ {
+ // Setup
+ ClosingStructure closingStructure = new TestClosingStructure();
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ bool result = registry.Contains(closingStructure);
+
+ // Assert
+ Assert.IsFalse(result);
+ }
+
#endregion
#region Get methods
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructureEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructureEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructureEntityReadExtensionsTest.cs (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -0,0 +1,207 @@
+// 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.ClosingStructures;
+using NUnit.Framework;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.ClosingStructures.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Read.ClosingStructures
+{
+ [TestFixture]
+ public class ClosingStructureEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_ReadConversionCollectorNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var entity = new ClosingStructureEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Read_ValidEntity_ReturnClosingStructure()
+ {
+ // Setup
+ var entity = new ClosingStructureEntity
+ {
+ Name = "A",
+ Id = "B",
+ X = 1.1,
+ Y = 2.2,
+ StructureNormalOrientation = 3.3,
+ StorageStructureAreaMean = 4.4,
+ StorageStructureAreaCoefficientOfVariation = 5.5,
+ AllowedLevelIncreaseStorageMean = 6.6,
+ AllowedLevelIncreaseStorageStandardDeviation = 7.7,
+ WidthFlowAperturesMean = 8.8,
+ WidthFlowAperturesCoefficientOfVariation = 9.9,
+ LevelCrestStructureNotClosingMean = 10.10,
+ LevelCrestStructureNotClosingStandardDeviation = 11.11,
+ InsideWaterLevelMean = 12.12,
+ InsideWaterLevelStandardDeviation = 13.13,
+ ThresholdHeightOpenWeirMean = 14.14,
+ ThresholdHeightOpenWeirStandardDeviation = 15.15,
+ AreaFlowAperturesMean = 16.16,
+ AreaFlowAperturesStandardDeviation = 17.17,
+ CriticalOvertoppingDischargeMean = 18.18,
+ CriticalOvertoppingDischargeCoefficientOfVariation = 19.19,
+ FlowWidthAtBottomProtectionMean = 20.20,
+ FlowWidthAtBottomProtectionStandardDeviation = 21.21,
+ ProbabilityOpenStructureBeforeFlooding = 22.22,
+ FailureProbabilityOpenStructure = 23.23,
+ IdenticalApertures = 24,
+ FailureProbabilityReparation = 25.25,
+ InflowModelType = Convert.ToByte(ClosingStructureInflowModelType.FloodedCulvert)
+ };
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ ClosingStructure 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.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.AreEqual(entity.WidthFlowAperturesMean, structure.WidthFlowApertures.Mean.Value);
+ Assert.AreEqual(entity.WidthFlowAperturesCoefficientOfVariation, structure.WidthFlowApertures.CoefficientOfVariation.Value);
+ Assert.AreEqual(entity.LevelCrestStructureNotClosingMean, structure.LevelCrestStructureNotClosing.Mean.Value);
+ Assert.AreEqual(entity.LevelCrestStructureNotClosingStandardDeviation, structure.LevelCrestStructureNotClosing.StandardDeviation.Value);
+ Assert.AreEqual(entity.InsideWaterLevelMean, structure.InsideWaterLevel.Mean.Value);
+ Assert.AreEqual(entity.InsideWaterLevelStandardDeviation, structure.InsideWaterLevel.StandardDeviation.Value);
+ Assert.AreEqual(entity.ThresholdHeightOpenWeirMean, structure.ThresholdHeightOpenWeir.Mean.Value);
+ Assert.AreEqual(entity.ThresholdHeightOpenWeirStandardDeviation, structure.ThresholdHeightOpenWeir.StandardDeviation.Value);
+ Assert.AreEqual(entity.AreaFlowAperturesMean, structure.AreaFlowApertures.Mean.Value);
+ Assert.AreEqual(entity.AreaFlowAperturesStandardDeviation, structure.AreaFlowApertures.StandardDeviation.Value);
+ Assert.AreEqual(entity.CriticalOvertoppingDischargeMean, structure.CriticalOvertoppingDischarge.Mean.Value);
+ Assert.AreEqual(entity.CriticalOvertoppingDischargeCoefficientOfVariation, structure.CriticalOvertoppingDischarge.CoefficientOfVariation.Value);
+ Assert.AreEqual(entity.FlowWidthAtBottomProtectionMean, structure.FlowWidthAtBottomProtection.Mean.Value);
+ Assert.AreEqual(entity.FlowWidthAtBottomProtectionStandardDeviation, structure.FlowWidthAtBottomProtection.StandardDeviation.Value);
+ Assert.AreEqual(entity.ProbabilityOpenStructureBeforeFlooding, structure.ProbabilityOpenStructureBeforeFlooding);
+ Assert.AreEqual(entity.FailureProbabilityOpenStructure, structure.FailureProbabilityOpenStructure);
+ Assert.AreEqual(entity.IdenticalApertures, structure.IdenticalApertures);
+ Assert.AreEqual(entity.FailureProbabilityReparation, structure.FailureProbabilityReparation);
+ Assert.AreEqual((ClosingStructureInflowModelType)entity.InflowModelType, structure.InflowModelType);
+
+ Assert.IsTrue(collector.Contains(entity));
+ }
+
+ [Test]
+ public void Read_NullValues_ReturnClosingStructureWithNaN()
+ {
+ // Setup
+ var entity = new ClosingStructureEntity
+ {
+ Name = "A",
+ Id = "B",
+ X = null,
+ Y = null,
+ StructureNormalOrientation = null,
+ StorageStructureAreaMean = null,
+ StorageStructureAreaCoefficientOfVariation = null,
+ AllowedLevelIncreaseStorageMean = null,
+ AllowedLevelIncreaseStorageStandardDeviation = null,
+ WidthFlowAperturesMean = null,
+ WidthFlowAperturesCoefficientOfVariation = null,
+ LevelCrestStructureNotClosingMean = null,
+ LevelCrestStructureNotClosingStandardDeviation = null,
+ InsideWaterLevelMean = null,
+ InsideWaterLevelStandardDeviation = null,
+ ThresholdHeightOpenWeirMean = null,
+ ThresholdHeightOpenWeirStandardDeviation = null,
+ AreaFlowAperturesMean = null,
+ AreaFlowAperturesStandardDeviation = null,
+ CriticalOvertoppingDischargeMean = null,
+ CriticalOvertoppingDischargeCoefficientOfVariation = null,
+ FlowWidthAtBottomProtectionMean = null,
+ FlowWidthAtBottomProtectionStandardDeviation = null,
+ ProbabilityOpenStructureBeforeFlooding = null,
+ FailureProbabilityOpenStructure = null,
+ IdenticalApertures = 1,
+ InflowModelType = 1
+ };
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ ClosingStructure structure = entity.Read(collector);
+
+ // Assert
+ Assert.IsNaN(structure.Location.X);
+ Assert.IsNaN(structure.Location.Y);
+ Assert.IsNaN(structure.StructureNormalOrientation);
+
+ Assert.IsNaN(structure.StorageStructureArea.Mean);
+ Assert.IsNaN(structure.StorageStructureArea.CoefficientOfVariation);
+ Assert.IsNaN(structure.AllowedLevelIncreaseStorage.Mean);
+ Assert.IsNaN(structure.AllowedLevelIncreaseStorage.StandardDeviation);
+ Assert.IsNaN(structure.WidthFlowApertures.Mean);
+ Assert.IsNaN(structure.WidthFlowApertures.CoefficientOfVariation);
+ Assert.IsNaN(structure.LevelCrestStructureNotClosing.Mean);
+ Assert.IsNaN(structure.LevelCrestStructureNotClosing.StandardDeviation);
+ Assert.IsNaN(structure.InsideWaterLevel.Mean);
+ Assert.IsNaN(structure.InsideWaterLevel.StandardDeviation);
+ Assert.IsNaN(structure.ThresholdHeightOpenWeir.Mean);
+ Assert.IsNaN(structure.ThresholdHeightOpenWeir.StandardDeviation);
+ Assert.IsNaN(structure.AreaFlowApertures.Mean);
+ Assert.IsNaN(structure.AreaFlowApertures.StandardDeviation);
+ Assert.IsNaN(structure.CriticalOvertoppingDischarge.Mean);
+ Assert.IsNaN(structure.CriticalOvertoppingDischarge.CoefficientOfVariation);
+ Assert.IsNaN(structure.FlowWidthAtBottomProtection.Mean);
+ Assert.IsNaN(structure.FlowWidthAtBottomProtection.StandardDeviation);
+ Assert.IsNaN(structure.ProbabilityOpenStructureBeforeFlooding);
+ Assert.IsNaN(structure.FailureProbabilityOpenStructure);
+ Assert.IsNaN(structure.FailureProbabilityReparation);
+ }
+
+ [Test]
+ public void Read_EntityRegistered_ReturnRegisteredStructure()
+ {
+ // Setup
+ var entity = new ClosingStructureEntity();
+ ClosingStructure registeredStructure = new TestClosingStructure();
+ var collector = new ReadConversionCollector();
+ collector.Read(entity, registeredStructure);
+
+ // Call
+ ClosingStructure readStructure = entity.Read(collector);
+
+ // Assert
+ Assert.AreSame(registeredStructure, readStructure);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs
===================================================================
diff -u -re42bdf3dd379c46bab9212eb7b30f4754c9bc91c -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision e42bdf3dd379c46bab9212eb7b30f4754c9bc91c)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -25,6 +25,8 @@
using Application.Ringtoets.Storage.TestUtil;
using Core.Common.Base.Geometry;
using NUnit.Framework;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.ClosingStructures.Data.TestUtil;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.HeightStructures.Data;
@@ -1547,5 +1549,154 @@
}
#endregion
+
+ #region ClosingStructureEntity: Read, Contains, Get
+
+ [Test]
+ public void Contains_WithoutClosingStructureEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => collector.Contains((ClosingStructureEntity)null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Contains_ClosingStructureEntityAdded_ReturnsTrue()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ var entity = new ClosingStructureEntity();
+ collector.Read(entity, new TestClosingStructure());
+
+ // Call
+ var result = collector.Contains(entity);
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void Contains_NoClosingStructureEntityAdded_ReturnsFalse()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ var entity = new ClosingStructureEntity();
+
+ // Call
+ var result = collector.Contains(entity);
+
+ // Assert
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void Contains_OtherClosingStructureEntityAdded_ReturnsFalse()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ var entity = new ClosingStructureEntity();
+ collector.Read(new ClosingStructureEntity(), new TestClosingStructure());
+
+ // Call
+ var result = collector.Contains(entity);
+
+ // Assert
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void Get_WithoutClosingStructureEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => collector.Get((ClosingStructureEntity)null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Get_ClosingStructureEntityAdded_ReturnsHeightStructure()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ ClosingStructure structure = new TestClosingStructure();
+ var entity = new ClosingStructureEntity();
+ collector.Read(entity, structure);
+
+ // Call
+ var result = collector.Get(entity);
+
+ // Assert
+ Assert.AreSame(structure, result);
+ }
+
+ [Test]
+ public void Get_NoClosingStructureEntityAdded_ThrowsInvalidOperationException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ var entity = new ClosingStructureEntity();
+
+ // Call
+ TestDelegate test = () => collector.Get(entity);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Get_OtherClosingStructureEntityAdded_ThrowsInvalidOperationException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ var entity = new ClosingStructureEntity();
+ collector.Read(new ClosingStructureEntity(), new TestClosingStructure());
+
+ // Call
+ TestDelegate test = () => collector.Get(entity);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Read_WithNullClosingStructureEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => collector.Read(null, new TestClosingStructure());
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Read_WithNullClosingStructureForClosingStructureEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => collector.Read(new ClosingStructureEntity(), null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("model", paramName);
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructureInflowModelType.cs
===================================================================
diff -u -r9e3639e810a22019da1a9fdf5aa5c433a43520c1 -r9ee8f17742a5407fd9453aeb12f20cfedb20c73e
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructureInflowModelType.cs (.../ClosingStructureInflowModelType.cs) (revision 9e3639e810a22019da1a9fdf5aa5c433a43520c1)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructureInflowModelType.cs (.../ClosingStructureInflowModelType.cs) (revision 9ee8f17742a5407fd9453aeb12f20cfedb20c73e)
@@ -34,18 +34,18 @@
/// A vertical wall.
///
[ResourcesDisplayName(typeof(Resources), "ClosingStructureInflowModelType_VerticalWall_DisplayName")]
- VerticalWall,
+ VerticalWall = 1,
///
/// A low sill structure.
///
[ResourcesDisplayName(typeof(RingtoetsCommonDataResources), "StructureInflowModelType_LowSill_DisplayName")]
- LowSill,
+ LowSill = 2,
///
/// A flooded culvert structure.
///
[ResourcesDisplayName(typeof(RingtoetsCommonDataResources), "StructureInflowModelType_FloodedCulvert_DisplayName")]
- FloodedCulvert
+ FloodedCulvert = 3
}
}