Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -rc5f90c4f9b42d985f16f99ad8732576b9217267a -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision c5f90c4f9b42d985f16f99ad8732576b9217267a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -63,6 +63,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
RingtoetsEntities.tt
@@ -94,6 +113,8 @@
RingtoetsEntities.tt
+
+
@@ -130,6 +151,17 @@
+
+
+
+
+
+
+
+
+
+
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/AssessmentSectionCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,74 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class AssessmentSectionCreateExtensions
+ {
+ public static AssessmentSectionEntity Create(this AssessmentSection section, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new AssessmentSectionEntity
+ {
+ Name = section.Name,
+ Composition = (short) section.Composition
+ };
+
+ CreatePipingFailureMechanism(section, entity, collector);
+ CreateHydraulicDatabase(section, entity, collector);
+ CreateReferenceLine(section, entity);
+ CreateFailureMechanismPlaceHolders(section, entity, collector);
+
+ collector.Add(entity, section);
+ return entity;
+ }
+
+ private static void CreateFailureMechanismPlaceHolders(AssessmentSection section, AssessmentSectionEntity entity, CreateConversionCollector collector)
+ {
+ entity.FailureMechanismEntities.Add(section.MacrostabilityInwards.Create(FailureMechanismType.MacrostabilityInwards, collector));
+ entity.FailureMechanismEntities.Add(section.Overtopping.Create(FailureMechanismType.StructureHeight, collector));
+ entity.FailureMechanismEntities.Add(section.Closing.Create(FailureMechanismType.ReliabilityClosingOfStructure, collector));
+ entity.FailureMechanismEntities.Add(section.FailingOfConstruction.Create(FailureMechanismType.StrengthAndStabilityPointConstruction, collector));
+ entity.FailureMechanismEntities.Add(section.StoneRevetment.Create(FailureMechanismType.StabilityStoneRevetment, collector));
+ entity.FailureMechanismEntities.Add(section.AsphaltRevetment.Create(FailureMechanismType.WaveImpactOnAsphaltRevetment, collector));
+ entity.FailureMechanismEntities.Add(section.GrassRevetment.Create(FailureMechanismType.GrassRevetmentErosionOutwards, collector));
+ entity.FailureMechanismEntities.Add(section.DuneErosion.Create(FailureMechanismType.DuneErosion, collector));
+ }
+
+ private static void CreatePipingFailureMechanism(AssessmentSection section, AssessmentSectionEntity entity, CreateConversionCollector collector)
+ {
+ entity.FailureMechanismEntities.Add(section.PipingFailureMechanism.Create(collector));
+ }
+
+ private static void CreateReferenceLine(AssessmentSection section, AssessmentSectionEntity entity)
+ {
+ if (section.ReferenceLine != null)
+ {
+ var i = 0;
+ foreach (var point2D in section.ReferenceLine.Points)
+ {
+ entity.ReferenceLinePointEntities.Add(point2D.CreateReferenceLinePoint(i++));
+ }
+ }
+ }
+
+ private static void CreateHydraulicDatabase(AssessmentSection section, AssessmentSectionEntity entity, CreateConversionCollector collector)
+ {
+ if (section.HydraulicBoundaryDatabase != null)
+ {
+ entity.HydraulicDatabaseLocation = section.HydraulicBoundaryDatabase.FilePath;
+ entity.HydraulicDatabaseVersion = section.HydraulicBoundaryDatabase.Version;
+
+ foreach (var hydraulicBoundaryLocation in section.HydraulicBoundaryDatabase.Locations)
+ {
+ entity.HydraulicLocationEntities.Add(hydraulicBoundaryLocation.Create(collector));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/CreateConversionCollector.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/CreateConversionCollector.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/CreateConversionCollector.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,134 @@
+using System.Collections.Generic;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Data;
+using Core.Common.Utils;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Data.Placeholders;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Create
+{
+ public class CreateConversionCollector
+ {
+ private readonly Dictionary projects = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary assessmentSections = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary failureMechanisms = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary hydraulicLocations = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary stochasticSoilModels = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary stochasticSoilProfiles = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary soilProfiles = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary soilLayers = new Dictionary(new ReferenceEqualityComparer());
+
+ internal void Add(ProjectEntity entity, Project model)
+ {
+ Add(projects, entity, model);
+ }
+
+ internal void Add(AssessmentSectionEntity entity, AssessmentSection model)
+ {
+ Add(assessmentSections, entity, model);
+ }
+
+ public void Add(HydraulicLocationEntity entity, HydraulicBoundaryLocation model)
+ {
+ Add(hydraulicLocations, entity, model);
+ }
+
+ public void Add(FailureMechanismEntity entity, FailureMechanismPlaceholder model)
+ {
+ Add(failureMechanisms, entity, model);
+ }
+
+ internal void Add(FailureMechanismEntity entity, PipingFailureMechanism model)
+ {
+ Add(failureMechanisms, entity, model);
+ }
+
+ internal void Add(StochasticSoilModelEntity entity, StochasticSoilModel model)
+ {
+ Add(stochasticSoilModels, entity, model);
+ }
+
+ internal void Add(StochasticSoilProfileEntity entity, StochasticSoilProfile model)
+ {
+ Add(stochasticSoilProfiles, entity, model);
+ }
+
+ internal void Add(SoilProfileEntity entity, PipingSoilProfile model)
+ {
+ Add(soilProfiles, entity, model);
+ }
+
+ internal void Add(SoilLayerEntity entity, PipingSoilLayer model)
+ {
+ Add(soilLayers, entity, model);
+ }
+
+ internal bool Contains(PipingSoilProfile model)
+ {
+ return soilProfiles.ContainsValue(model);
+ }
+
+ internal SoilProfileEntity Get(PipingSoilProfile model)
+ {
+ return Get(soilProfiles, model);
+ }
+
+ internal void TransferIds()
+ {
+ foreach (var entity in projects.Keys)
+ {
+ projects[entity].StorageId = entity.ProjectEntityId;
+ }
+
+ foreach (var entity in failureMechanisms.Keys)
+ {
+ failureMechanisms[entity].StorageId = entity.FailureMechanismEntityId;
+ }
+
+ foreach (var entity in assessmentSections.Keys)
+ {
+ assessmentSections[entity].StorageId = entity.AssessmentSectionEntityId;
+ }
+
+ foreach (var entity in hydraulicLocations.Keys)
+ {
+ hydraulicLocations[entity].StorageId = entity.HydraulicLocationEntityId;
+ }
+
+ foreach (var entity in stochasticSoilModels.Keys)
+ {
+ stochasticSoilModels[entity].StorageId = entity.StochasticSoilModelEntityId;
+ }
+
+ foreach (var entity in stochasticSoilProfiles.Keys)
+ {
+ stochasticSoilProfiles[entity].StorageId = entity.StochasticSoilProfileEntityId;
+ }
+
+ foreach (var entity in soilProfiles.Keys)
+ {
+ soilProfiles[entity].StorageId = entity.SoilProfileEntityId;
+ }
+
+ foreach (var entity in soilLayers.Keys)
+ {
+ soilLayers[entity].StorageId = entity.SoilLayerEntityId;
+ }
+ }
+
+ private void Add(Dictionary collection, T entity, U model)
+ {
+ collection[entity] = model;
+ }
+
+ private T Get(Dictionary collection, U model)
+ {
+ return collection.Keys.Single(k => ReferenceEquals(collection[k], model));
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/FailureMechanismPlaceholderCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/FailureMechanismPlaceholderCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/FailureMechanismPlaceholderCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,26 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.Create
+{
+ public static class FailureMechanismPlaceholderCreateExtensions
+ {
+ public static FailureMechanismEntity Create(this FailureMechanismPlaceholder mechanism, FailureMechanismType type, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ FailureMechanismEntity entity = new FailureMechanismEntity
+ {
+ FailureMechanismType = (short)type,
+ IsRelevant = Convert.ToByte(mechanism.IsRelevant)
+ };
+
+ collector.Add(entity, mechanism);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HydraulicBoundaryLocationCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,29 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.HydraRing.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class HydraulicBoundaryLocationCreateExtensions
+ {
+ public static HydraulicLocationEntity Create(this HydraulicBoundaryLocation location, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new HydraulicLocationEntity
+ {
+ LocationId = location.Id,
+ Name = location.Name,
+ LocationX = Convert.ToDecimal(location.Location.X),
+ LocationY = Convert.ToDecimal(location.Location.Y),
+ DesignWaterLevel = Double.IsNaN(location.DesignWaterLevel) ? (double?) null : Convert.ToDouble(location.DesignWaterLevel)
+ };
+
+ collector.Add(entity, location);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingFailureMechanismCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,36 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class PipingFailureMechanismCreateExtensions
+ {
+ public static FailureMechanismEntity Create(this PipingFailureMechanism mechanism, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ FailureMechanismEntity entity = new FailureMechanismEntity
+ {
+ FailureMechanismType = (short) FailureMechanismType.Piping,
+ IsRelevant = Convert.ToByte(mechanism.IsRelevant)
+ };
+
+ CreateStochasticSoilModels(mechanism, collector, entity);
+
+ collector.Add(entity, mechanism);
+ return entity;
+ }
+
+ private static void CreateStochasticSoilModels(PipingFailureMechanism mechanism, CreateConversionCollector collector, FailureMechanismEntity entity)
+ {
+ foreach (var stochasticSoilModel in mechanism.StochasticSoilModels)
+ {
+ entity.StochasticSoilModelEntities.Add(stochasticSoilModel.Create(collector));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingSoilLayerCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingSoilLayerCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingSoilLayerCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,26 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class SoilLayerCreateExtensions
+ {
+ public static SoilLayerEntity Create(this PipingSoilLayer layer, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new SoilLayerEntity
+ {
+ IsAquifer = Convert.ToByte(layer.IsAquifer),
+ Top = Convert.ToDecimal(layer.Top)
+ };
+
+ collector.Add(entity, layer);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingSoilProfileCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingSoilProfileCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PipingSoilProfileCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,40 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class SoilProfileCreateExtensions
+ {
+ public static SoilProfileEntity Create(this PipingSoilProfile profile, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ if (collector.Contains(profile))
+ {
+ return collector.Get(profile);
+ }
+ var entity = new SoilProfileEntity
+ {
+ Name = profile.Name,
+ Bottom = Convert.ToDecimal(profile.Bottom)
+ };
+
+ CreatePipingSoilLayers(profile, collector, entity);
+
+ collector.Add(entity, profile);
+ return entity;
+ }
+
+ private static void CreatePipingSoilLayers(PipingSoilProfile profile, CreateConversionCollector collector, SoilProfileEntity entity)
+ {
+ foreach (var pipingSoilLayer in profile.Layers)
+ {
+ entity.SoilLayerEntities.Add(pipingSoilLayer.Create(collector));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Point2DCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Point2DCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Point2DCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,20 @@
+using System;
+using Core.Common.Base.Geometry;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class ReferenceLinePointCreateExtensions
+ {
+ public static ReferenceLinePointEntity CreateReferenceLinePoint(this Point2D point, int order)
+ {
+ var entity = new ReferenceLinePointEntity
+ {
+ X = Convert.ToDecimal(point.X),
+ Y = Convert.ToDecimal(point.Y),
+ Order = order
+ };
+
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProjectCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProjectCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ProjectCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,37 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Create;
+using Core.Common.Base.Data;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class ProjectCreateExtensions
+ {
+ public static ProjectEntity Create(this Project project, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new ProjectEntity
+ {
+ Description = project.Description
+ };
+
+ CreateAssessmentSections(project, entity, collector);
+
+ collector.Add(entity, project);
+ return entity;
+ }
+
+ private static void CreateAssessmentSections(Project project, ProjectEntity entity, CreateConversionCollector collector)
+ {
+ foreach (var result in project.Items.OfType())
+ {
+ entity.AssessmentSectionEntities.Add(result.Create(collector));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StochasticSoilModelCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StochasticSoilModelCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StochasticSoilModelCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,31 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class StochasticSoilModelCreateExtensions
+ {
+ public static StochasticSoilModelEntity Create(this StochasticSoilModel model, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new StochasticSoilModelEntity
+ {
+ Name = model.Name,
+ SegmentName = model.SegmentName
+ };
+
+ foreach (var stochasticSoilProfile in model.StochasticSoilProfiles)
+ {
+ entity.StochasticSoilProfileEntities.Add(stochasticSoilProfile.Create(collector));
+ }
+
+ collector.Add(entity, model);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StochasticSoilProfileCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StochasticSoilProfileCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/StochasticSoilProfileCreateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,21 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class StochasticSoilProfileCreateExtensions
+ {
+ public static StochasticSoilProfileEntity Create(this StochasticSoilProfile profile, CreateConversionCollector collector)
+ {
+ var entity = new StochasticSoilProfileEntity
+ {
+ Probability = Convert.ToDecimal(profile.Probability),
+ SoilProfileEntity = profile.SoilProfile.Create(collector)
+ };
+
+ collector.Add(entity, profile);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectPersistor.cs
===================================================================
diff -u -r8b5a6f938fe2b04cd78623649df37580e145055f -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectPersistor.cs (.../ProjectPersistor.cs) (revision 8b5a6f938fe2b04cd78623649df37580e145055f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectPersistor.cs (.../ProjectPersistor.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -68,7 +68,7 @@
///
/// A new , loaded from the sequence, or null when not found.
/// Thrown when there are more than one elements in the sequence.
- public Project GetEntityAsModel()
+ public Project Read()
{
var entry = projectEntitySet.SingleOrDefault();
if (entry == null)
@@ -144,16 +144,12 @@
ProjectEntity entity;
try
{
- entity = projectEntitySet.SingleOrDefault(db => db.ProjectEntityId == model.StorageId);
+ entity = projectEntitySet.Single(db => db.ProjectEntityId == model.StorageId);
}
catch (InvalidOperationException exception)
{
throw new EntityNotFoundException(String.Format(Resources.Error_Entity_Not_Found_0_1, "ProjectEntity", model.StorageId), exception);
}
- if (entity == null)
- {
- throw new EntityNotFoundException(String.Format(Resources.Error_Entity_Not_Found_0_1, "ProjectEntity", model.StorageId));
- }
modifiedList.Add(entity);
converter.ConvertModelToEntity(model, entity);
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/AssessmentSectionEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,95 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Read;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Data;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class AssessmentSectionEntity
+ {
+ public AssessmentSection Read(ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var assessmentSection = new AssessmentSection((AssessmentSectionComposition) Composition)
+ {
+ StorageId = AssessmentSectionEntityId,
+ Name = Name
+ };
+
+ ReadPipingFailureMechanism(assessmentSection, collector);
+ ReadHydraulicDatabase(assessmentSection);
+ ReadReferenceLine(assessmentSection);
+ ReadFailureMechanismPlaceholders(assessmentSection);
+
+ return assessmentSection;
+ }
+
+ private void ReadReferenceLine(AssessmentSection assessmentSection)
+ {
+ if (ReferenceLinePointEntities.Any())
+ {
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(ReferenceLinePointEntities.OrderBy(rlpe => rlpe.Order).Select(rlpe => rlpe.Read()));
+ }
+ }
+
+ private void ReadHydraulicDatabase(AssessmentSection assessmentSection)
+ {
+ if (HydraulicDatabaseLocation != null)
+ {
+ assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ FilePath = HydraulicDatabaseLocation,
+ Version = HydraulicDatabaseVersion
+ };
+
+ foreach (var hydraulicLocationEntity in HydraulicLocationEntities)
+ {
+ assessmentSection.HydraulicBoundaryDatabase.Locations.Add(hydraulicLocationEntity.Read());
+ }
+ }
+ }
+
+ private void ReadPipingFailureMechanism(AssessmentSection assessmentSection, ReadConversionCollector collector)
+ {
+ var pipingFailureMechanismEntity = FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int) FailureMechanismType.Piping);
+ if (pipingFailureMechanismEntity != null)
+ {
+ var failureMechanism = pipingFailureMechanismEntity.ReadAsPipingFailureMechanism(collector);
+
+ assessmentSection.PipingFailureMechanism.StochasticSoilModels.AddRange(failureMechanism.StochasticSoilModels);
+ assessmentSection.PipingFailureMechanism.IsRelevant = failureMechanism.IsRelevant;
+ assessmentSection.PipingFailureMechanism.StorageId = failureMechanism.StorageId;
+ }
+ }
+
+ private void ReadFailureMechanismPlaceholders(AssessmentSection assessmentSection)
+ {
+ ReadFailureMechanismPlaceholder(FailureMechanismType.MacrostabilityInwards, assessmentSection.MacrostabilityInwards);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.StructureHeight, assessmentSection.Overtopping);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.ReliabilityClosingOfStructure, assessmentSection.Closing);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.StrengthAndStabilityPointConstruction, assessmentSection.FailingOfConstruction);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.StabilityStoneRevetment, assessmentSection.StoneRevetment);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.WaveImpactOnAsphaltRevetment, assessmentSection.AsphaltRevetment);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.GrassRevetmentErosionOutwards, assessmentSection.GrassRevetment);
+ ReadFailureMechanismPlaceholder(FailureMechanismType.DuneErosion, assessmentSection.DuneErosion);
+ }
+
+ private void ReadFailureMechanismPlaceholder(FailureMechanismType failureMechanismType, FailureMechanismPlaceholder failureMechanismPlaceholder)
+ {
+ var failureMechanismEntity = FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (int) failureMechanismType);
+ if (failureMechanismEntity != null)
+ {
+ failureMechanismPlaceholder.StorageId = failureMechanismEntity.FailureMechanismEntityId;
+ failureMechanismPlaceholder.IsRelevant = Convert.ToBoolean(failureMechanismEntity.IsRelevant);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,30 @@
+using System;
+using Application.Ringtoets.Storage.Read;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class FailureMechanismEntity
+ {
+ public PipingFailureMechanism ReadAsPipingFailureMechanism(ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var failureMechanism = new PipingFailureMechanism
+ {
+ StorageId = FailureMechanismEntityId,
+ IsRelevant = IsRelevant == 1
+ };
+
+ foreach (var stochasticSoilModelEntity in StochasticSoilModelEntities)
+ {
+ failureMechanism.StochasticSoilModels.Add(stochasticSoilModelEntity.Read(collector));
+ }
+
+ return failureMechanism;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HydraulicLocationEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HydraulicLocationEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/HydraulicLocationEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,27 @@
+using System;
+using Ringtoets.HydraRing.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class HydraulicLocationEntity
+ {
+ public HydraulicBoundaryLocation Read()
+ {
+ HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(
+ LocationId,
+ Name,
+ Convert.ToDouble(LocationX),
+ Convert.ToDouble(LocationY))
+ {
+ StorageId = HydraulicLocationEntityId
+ };
+
+ if (DesignWaterLevel.HasValue)
+ {
+ hydraulicBoundaryLocation.DesignWaterLevel = Convert.ToDouble(DesignWaterLevel);
+ }
+
+ return hydraulicBoundaryLocation;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProjectEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProjectEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ProjectEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,25 @@
+using Application.Ringtoets.Storage.Read;
+using Core.Common.Base.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class ProjectEntity
+ {
+ public Project Read()
+ {
+ var collector = new ReadConversionCollector();
+ var project = new Project
+ {
+ StorageId = ProjectEntityId,
+ Description = Description
+ };
+
+ foreach (var assessmentSectionEntity in AssessmentSectionEntities)
+ {
+ project.Items.Add(assessmentSectionEntity.Read(collector));
+ }
+
+ return project;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Utils;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Read
+{
+ public class ReadConversionCollector
+ {
+ private readonly Dictionary soilProfiles = new Dictionary(new ReferenceEqualityComparer());
+
+ internal void Add(SoilProfileEntity entity, PipingSoilProfile profile)
+ {
+ soilProfiles[entity] = profile;
+ }
+
+ internal bool Contains(SoilProfileEntity entity)
+ {
+ return soilProfiles.ContainsKey(entity);
+ }
+
+ internal PipingSoilProfile Get(SoilProfileEntity soilProfileEntity)
+ {
+ return soilProfiles[soilProfileEntity];
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReferenceLinePointEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReferenceLinePointEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReferenceLinePointEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,13 @@
+using System;
+using Core.Common.Base.Geometry;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class ReferenceLinePointEntity
+ {
+ public Point2D Read()
+ {
+ return new Point2D(Convert.ToDouble(X), Convert.ToDouble(Y));
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SoilLayerEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SoilLayerEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SoilLayerEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,17 @@
+using System;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class SoilLayerEntity
+ {
+ public PipingSoilLayer Read()
+ {
+ return new PipingSoilLayer(Convert.ToDouble(Top))
+ {
+ StorageId = SoilLayerEntityId,
+ IsAquifer = Convert.ToBoolean(IsAquifer)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SoilProfileEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SoilProfileEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SoilProfileEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,30 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Read;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class SoilProfileEntity
+ {
+ public PipingSoilProfile Read(ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ if (collector.Contains(this))
+ {
+ return collector.Get(this);
+ }
+ var layers = SoilLayerEntities.Select(sl => sl.Read());
+ var pipingSoilProfile = new PipingSoilProfile(Name, Convert.ToDouble(Bottom), layers, SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = SoilProfileEntityId
+ };
+ collector.Add(this, pipingSoilProfile);
+ return pipingSoilProfile;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,33 @@
+using System;
+using Application.Ringtoets.Storage.Read;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class StochasticSoilModelEntity
+ {
+ public StochasticSoilModel Read(ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var model = new StochasticSoilModel(-1, Name, SegmentName)
+ {
+ StorageId = StochasticSoilModelEntityId
+ };
+ ReadStochasticSoilProfiles(model, collector);
+
+ return model;
+ }
+
+ private void ReadStochasticSoilProfiles(StochasticSoilModel model, ReadConversionCollector collector)
+ {
+ foreach (var stochasticSoilProfileEntity in StochasticSoilProfileEntities)
+ {
+ model.StochasticSoilProfiles.Add(stochasticSoilProfileEntity.Read(collector));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilProfileEntity.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilProfileEntity.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilProfileEntity.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,31 @@
+using System;
+using Application.Ringtoets.Storage.Read;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public partial class StochasticSoilProfileEntity
+ {
+ public StochasticSoilProfile Read(ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var profile = new StochasticSoilProfile(Convert.ToDouble(Probability), SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = StochasticSoilProfileEntityId
+ };
+ ReadSoilProfile(profile, collector);
+
+ return profile;
+ }
+
+ private void ReadSoilProfile(StochasticSoilProfile profile, ReadConversionCollector collector)
+ {
+ profile.SoilProfile = SoilProfileEntity.Read(collector);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs
===================================================================
diff -u -rd7e6a5cb0aae63ca364024bf6740269d7457f7bb -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision d7e6a5cb0aae63ca364024bf6740269d7457f7bb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -24,10 +24,12 @@
using System.Data.Entity;
using System.IO;
using System.Linq;
+using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
using Application.Ringtoets.Storage.Persistors;
using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
using Core.Common.Base.Data;
using Core.Common.Base.Storage;
using Core.Common.Utils;
@@ -70,16 +72,25 @@
///
public int SaveProjectAs(string databaseFilePath, Project project)
{
+ if (project == null)
+ {
+ throw new ArgumentNullException("project");
+ }
+
SetConnectionToNewFile(databaseFilePath);
using (var dbContext = new RingtoetsEntities(connectionString))
{
var projectEntityPersistor = new ProjectPersistor(dbContext);
try
{
- projectEntityPersistor.InsertModel(project);
+// projectEntityPersistor.InsertModel(project);
+
+ var collector = new CreateConversionCollector();
+ dbContext.ProjectEntities.Add(project.Create(collector));
var changes = dbContext.SaveChanges();
+ collector.TransferIds();
- projectEntityPersistor.PerformPostSaveActions();
+// projectEntityPersistor.PerformPostSaveActions();
project.Name = Path.GetFileNameWithoutExtension(databaseFilePath);
@@ -119,20 +130,26 @@
///
public int SaveProject(string databaseFilePath, Project project)
{
- SetConnectionToFile(databaseFilePath);
if (project == null)
{
throw new ArgumentNullException("project");
}
+
+ SetConnectionToFile(databaseFilePath);
using (var dbContext = new RingtoetsEntities(connectionString))
{
var projectEntityPersistor = new ProjectPersistor(dbContext);
try
{
- projectEntityPersistor.UpdateModel(project);
- projectEntityPersistor.RemoveUnModifiedEntries();
+// projectEntityPersistor.UpdateModel(project);
+// projectEntityPersistor.RemoveUnModifiedEntries();
+
+ var updateCollector = new UpdateConversionCollector();
+ project.Update(updateCollector, dbContext);
+ updateCollector.RemoveUntouched(dbContext);
var changes = dbContext.SaveChanges();
- projectEntityPersistor.PerformPostSaveActions();
+ updateCollector.TransferIds();
+// projectEntityPersistor.PerformPostSaveActions();
return changes;
}
catch (EntityNotFoundException)
@@ -175,9 +192,14 @@
{
using (var dbContext = new RingtoetsEntities(connectionString))
{
- var projectEntityPersistor = new ProjectPersistor(dbContext);
- var project = projectEntityPersistor.GetEntityAsModel();
+ var projectEntity = GetSingleProject(dbContext);
+ if (projectEntity == null)
+ {
+ throw CreateStorageReaderException("Het bestand is geen geldig Ringtoets bestand.");
+ }
+ var project = projectEntity.Read();
+
project.Name = Path.GetFileNameWithoutExtension(databaseFilePath);
return project;
}
@@ -192,6 +214,18 @@
}
}
+ private ProjectEntity GetSingleProject(RingtoetsEntities dbContext)
+ {
+ try
+ {
+ return dbContext.ProjectEntities.Single();
+ }
+ catch (InvalidOperationException)
+ {
+ return null;
+ }
+ }
+
public bool HasChanges(Project project)
{
if (string.IsNullOrWhiteSpace(connectionString))
@@ -201,12 +235,16 @@
using (var dbContext = new RingtoetsEntities(connectionString))
{
- var projectEntityPersistor = new ProjectPersistor(dbContext);
-
+// var projectEntityPersistor = new ProjectPersistor(dbContext);
try
{
- projectEntityPersistor.UpdateModel(project);
- projectEntityPersistor.RemoveUnModifiedEntries();
+// projectEntityPersistor.UpdateModel(project);
+// projectEntityPersistor.RemoveUnModifiedEntries();
+
+ var updateConversionCollector = new UpdateConversionCollector();
+ project.Update(updateConversionCollector, dbContext);
+ updateConversionCollector.RemoveUntouched(dbContext);
+
return dbContext.ChangeTracker.HasChanges();
}
catch (EntityNotFoundException) {}
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/AssessmentSectionUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/AssessmentSectionUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/AssessmentSectionUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class AssessmentSectionUpdateExtensions
+ {
+ public static void Update(this AssessmentSection section, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleAssessmentSection(section, context);
+ entity.Name = section.Name;
+ entity.Composition = (short) section.Composition;
+
+ UpdatePipingFailureMechanism(section, collector, context);
+ UpdateHydraulicDatabase(section, entity, collector, context);
+ UpdateReferenceLine(section, entity, context);
+ UpdateFailureMechanismPlaceHolders(section, collector, context);
+
+ collector.Update(entity);
+ }
+
+ private static void UpdateFailureMechanismPlaceHolders(AssessmentSection section, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ section.MacrostabilityInwards.Update(collector, context);
+ section.Overtopping.Update(collector, context);
+ section.Closing.Update(collector, context);
+ section.FailingOfConstruction.Update(collector, context);
+ section.StoneRevetment.Update(collector, context);
+ section.AsphaltRevetment.Update(collector, context);
+ section.GrassRevetment.Update(collector, context);
+ section.DuneErosion.Update(collector, context);
+ }
+
+ private static AssessmentSectionEntity GetSingleAssessmentSection(AssessmentSection section, IRingtoetsEntities context)
+ {
+ try {
+ return context.AssessmentSectionEntities.Single(ase => ase.AssessmentSectionEntityId == section.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(AssessmentSectionEntity).Name, section.StorageId), exception);
+ }
+ }
+
+ private static void UpdatePipingFailureMechanism(AssessmentSection section, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ section.PipingFailureMechanism.Update(collector, context);
+ }
+
+ private static void UpdateReferenceLine(AssessmentSection section, AssessmentSectionEntity entity, IRingtoetsEntities context)
+ {
+ if (HasChanges(entity.ReferenceLinePointEntities, section.ReferenceLine))
+ {
+ context.ReferenceLinePointEntities.RemoveRange(entity.ReferenceLinePointEntities);
+ UpdateReferenceLinePoints(section, entity);
+ }
+ }
+
+ private static void UpdateReferenceLinePoints(AssessmentSection section, AssessmentSectionEntity entity)
+ {
+ if (section.ReferenceLine != null)
+ {
+ var i = 0;
+ foreach (var point2D in section.ReferenceLine.Points)
+ {
+ entity.ReferenceLinePointEntities.Add(point2D.CreateReferenceLinePoint(i++));
+ }
+ }
+ }
+
+ private static void UpdateHydraulicDatabase(AssessmentSection section, AssessmentSectionEntity entity, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (section.HydraulicBoundaryDatabase != null)
+ {
+ entity.HydraulicDatabaseLocation = section.HydraulicBoundaryDatabase.FilePath;
+ entity.HydraulicDatabaseVersion = section.HydraulicBoundaryDatabase.Version;
+
+ foreach (var hydraulicBoundaryLocation in section.HydraulicBoundaryDatabase.Locations)
+ {
+ if (hydraulicBoundaryLocation.IsNew())
+ {
+ entity.HydraulicLocationEntities.Add(hydraulicBoundaryLocation.Create(collector));
+ }
+ else
+ {
+ hydraulicBoundaryLocation.Update(collector, context);
+ }
+ }
+ }
+ }
+
+ private static bool HasChanges(ICollection existingLine, ReferenceLine otherLine)
+ {
+ if (!existingLine.Any())
+ {
+ return otherLine != null;
+ }
+ if (otherLine == null)
+ {
+ return true;
+ }
+
+ var existingPointEntities = existingLine.OrderBy(rlpe => rlpe.Order).ToArray();
+ var otherPointsArray = otherLine.Points.ToArray();
+ if (existingPointEntities.Length != otherPointsArray.Length)
+ {
+ return true;
+ }
+ for (int i = 0; i < existingPointEntities.Length; i++)
+ {
+ var isXAlmostEqual = Math.Abs(Convert.ToDouble(existingPointEntities[i].X) - otherPointsArray[i].X) < 1e-6;
+ var isYAlmostEqual = Math.Abs(Convert.ToDouble(existingPointEntities[i].Y) - otherPointsArray[i].Y) < 1e-6;
+ if (!isXAlmostEqual || !isYAlmostEqual)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismPlaceholderUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismPlaceholderUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismPlaceholderUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,41 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Ringtoets.Integration.Data.Placeholders;
+
+namespace Application.Ringtoets.Storage.Update
+{
+ public static class FailureMechanismPlaceholderUpdateExtensions
+ {
+ public static void Update(this FailureMechanismPlaceholder mechanism, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleFailureMechanism(mechanism, context);
+ entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
+
+ collector.Update(entity);
+ }
+
+ private static FailureMechanismEntity GetSingleFailureMechanism(FailureMechanismPlaceholder mechanism, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.FailureMechanismEntities.Single(fme => fme.FailureMechanismEntityId == mechanism.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(FailureMechanismEntity).Name, mechanism.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HydraulicBoundaryLocationUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HydraulicBoundaryLocationUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/HydraulicBoundaryLocationUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,44 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.HydraRing.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class HydraulicBoundaryLocationUpdateExtensions
+ {
+ public static void Update(this HydraulicBoundaryLocation location, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleHydraulicBoundaryLocation(location, context);
+ entity.Name = location.Name;
+ entity.LocationX = Convert.ToDecimal(location.Location.X);
+ entity.LocationY = Convert.ToDecimal(location.Location.Y);
+ entity.DesignWaterLevel = double.IsNaN(location.DesignWaterLevel) ? (double?) null : Convert.ToDouble(location.DesignWaterLevel);
+
+ collector.Update(entity);
+ }
+
+ private static HydraulicLocationEntity GetSingleHydraulicBoundaryLocation(HydraulicBoundaryLocation location, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.HydraulicLocationEntities.Single(hle => hle.HydraulicLocationEntityId == location.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(HydraulicLocationEntity).Name, location.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IStorableExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IStorableExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/IStorableExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,12 @@
+using Core.Common.Base.Storage;
+
+namespace Application.Ringtoets.Storage.Update
+{
+ public static class IStorableExtensions
+ {
+ public static bool IsNew(this IStorable storable)
+ {
+ return storable.StorageId <= 0;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingFailureMechanismUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,53 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class PipingFailureMechanismUpdateExtensions
+ {
+ public static void Update(this PipingFailureMechanism mechanism, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleFailureMechanism(mechanism, context);
+ entity.IsRelevant = Convert.ToByte(mechanism.IsRelevant);
+
+ foreach (var stochasticSoilModel in mechanism.StochasticSoilModels)
+ {
+ if (stochasticSoilModel.IsNew())
+ {
+ entity.StochasticSoilModelEntities.Add(stochasticSoilModel.Create(collector));
+ }
+ else
+ {
+ stochasticSoilModel.Update(collector, context);
+ }
+ }
+
+ collector.Update(entity);
+ }
+
+ private static FailureMechanismEntity GetSingleFailureMechanism(PipingFailureMechanism mechanism, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.FailureMechanismEntities.Single(fme => fme.FailureMechanismEntityId == mechanism.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(FailureMechanismEntity).Name, mechanism.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilLayerUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilLayerUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilLayerUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,43 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class SoilLayerUpdateExtensions
+ {
+ public static void Update(this PipingSoilLayer layer, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleSoilLayer(layer, context);
+
+ entity.IsAquifer = Convert.ToByte(layer.IsAquifer);
+ entity.Top = Convert.ToDecimal(layer.Top);
+
+ collector.Update(entity);
+ }
+
+ private static SoilLayerEntity GetSingleSoilLayer(PipingSoilLayer layer, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.SoilLayerEntities.Single(sle => sle.SoilLayerEntityId == layer.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(SoilLayerEntity).Name, layer.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilProfileUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilProfileUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/PipingSoilProfileUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,54 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class SoilProfileUpdateExtensions
+ {
+ public static void Update(this PipingSoilProfile profile, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSinglePipingSoilProfile(profile, context);
+ entity.Name = profile.Name;
+ entity.Bottom = Convert.ToDecimal(profile.Bottom);
+
+ foreach (var pipingSoilLayer in profile.Layers)
+ {
+ if (pipingSoilLayer.IsNew())
+ {
+ entity.SoilLayerEntities.Add(pipingSoilLayer.Create(collector));
+ }
+ else
+ {
+ pipingSoilLayer.Update(collector, context);
+ }
+ }
+
+ collector.Update(entity);
+ }
+
+ private static SoilProfileEntity GetSinglePipingSoilProfile(PipingSoilProfile profile, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.SoilProfileEntities.Single(spe => spe.SoilProfileEntityId == profile.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(SoilProfileEntity).Name, profile.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/ProjectUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,54 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Update;
+using Core.Common.Base.Data;
+using Ringtoets.Integration.Data;
+using Resources = Application.Ringtoets.Storage.Properties.Resources;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class ProjectUpdateExtensions
+ {
+ public static void Update(this Project project, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = ReadSingleProject(project, context);
+ entity.Description = project.Description;
+
+ foreach (var result in project.Items.OfType())
+ {
+ if (result.IsNew())
+ {
+ entity.AssessmentSectionEntities.Add(result.Create(collector));
+ }
+ else
+ {
+ result.Update(collector, context);
+ }
+ }
+
+ collector.Update(entity);
+ }
+
+ private static ProjectEntity ReadSingleProject(Project project, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.ProjectEntities.Single(pe => pe.ProjectEntityId == project.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(ProjectEntity).Name, project.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilModelUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilModelUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilModelUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,54 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class StochasticSoilModelUpdateExtensions
+ {
+ public static void Update(this StochasticSoilModel model, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleStochasticSoilModel(model, context);
+ entity.Name = model.Name;
+ entity.SegmentName = model.SegmentName;
+
+ foreach (var stochasticSoilProfile in model.StochasticSoilProfiles)
+ {
+ if (stochasticSoilProfile.IsNew())
+ {
+ entity.StochasticSoilProfileEntities.Add(stochasticSoilProfile.Create(collector));
+ }
+ else
+ {
+ stochasticSoilProfile.Update(collector, context);
+ }
+ }
+
+ collector.Update(entity);
+ }
+
+ private static StochasticSoilModelEntity GetSingleStochasticSoilModel(StochasticSoilModel model, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.StochasticSoilModelEntities.Single(ssme => ssme.StochasticSoilModelEntityId == model.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(StochasticSoilModelEntity).Name, model.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/StochasticSoilProfileUpdateExtensions.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,50 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+using Application.Ringtoets.Storage.Update;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.DbContext
+{
+ public static class StochasticSoilProfileUpdateExtensions
+ {
+ public static void Update(this StochasticSoilProfile profile, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = GetSingleStochasticSoilProfile(profile, context);
+ entity.Probability = Convert.ToDecimal(profile.Probability);
+
+ if (profile.SoilProfile.IsNew())
+ {
+ entity.SoilProfileEntity = profile.SoilProfile.Create(collector);
+ }
+ else
+ {
+ profile.SoilProfile.Update(collector, context);
+ }
+
+ collector.Update(entity);
+ }
+
+ private static StochasticSoilProfileEntity GetSingleStochasticSoilProfile(StochasticSoilProfile profile, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.StochasticSoilProfileEntities.Single(sspe => sspe.StochasticSoilProfileEntityId == profile.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ throw new EntityNotFoundException(string.Format(Resources.Error_Entity_Not_Found_0_1, typeof(StochasticSoilProfileEntity).Name, profile.StorageId), exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/UpdateConversionCollector.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/UpdateConversionCollector.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/UpdateConversionCollector.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,87 @@
+using System.Collections.Generic;
+using System.Linq;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Utils;
+
+namespace Application.Ringtoets.Storage.Update
+{
+ public class UpdateConversionCollector : CreateConversionCollector
+ {
+ private readonly HashSet projects = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet assessmentSections = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet failureMechanisms = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet hydraulicLocations = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet stochasticSoilModels = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet stochasticSoilProfiles = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet soilProfiles = new HashSet(new ReferenceEqualityComparer());
+ private readonly HashSet soilLayers = new HashSet(new ReferenceEqualityComparer());
+
+ internal void Update(ProjectEntity entity)
+ {
+ projects.Add(entity);
+ }
+
+ public void Update(AssessmentSectionEntity entity)
+ {
+ assessmentSections.Add(entity);
+ }
+
+ public void Update(FailureMechanismEntity entity)
+ {
+ failureMechanisms.Add(entity);
+ }
+
+ public void Update(HydraulicLocationEntity entity)
+ {
+ hydraulicLocations.Add(entity);
+ }
+
+ internal void Update(StochasticSoilModelEntity entity)
+ {
+ stochasticSoilModels.Add(entity);
+ }
+
+ internal void Update(StochasticSoilProfileEntity entity)
+ {
+ stochasticSoilProfiles.Add(entity);
+ }
+
+ internal void Update(SoilProfileEntity entity)
+ {
+ soilProfiles.Add(entity);
+ }
+
+ internal void Update(SoilLayerEntity entity)
+ {
+ soilLayers.Add(entity);
+ }
+
+ public void RemoveUntouched(RingtoetsEntities dbContext)
+ {
+ var projectEntities = dbContext.ProjectEntities;
+ projectEntities.RemoveRange(projectEntities.Local.Except(projects));
+
+ var assessmentSectionEntities = dbContext.AssessmentSectionEntities;
+ assessmentSectionEntities.RemoveRange(assessmentSectionEntities.Local.Except(assessmentSections));
+
+ var failureMechanismEntities = dbContext.FailureMechanismEntities;
+ failureMechanismEntities.RemoveRange(failureMechanismEntities.Local.Except(failureMechanisms));
+
+ var hydraulicLocationEntities = dbContext.HydraulicLocationEntities;
+ hydraulicLocationEntities.RemoveRange(hydraulicLocationEntities.Local.Except(hydraulicLocations));
+
+ var stochasticSoilModelEntities = dbContext.StochasticSoilModelEntities;
+ stochasticSoilModelEntities.RemoveRange(stochasticSoilModelEntities.Local.Except(stochasticSoilModels));
+
+ var stochasticSoilProfileEntities = dbContext.StochasticSoilProfileEntities;
+ stochasticSoilProfileEntities.RemoveRange(stochasticSoilProfileEntities.Local.Except(stochasticSoilProfiles));
+
+ var soilProfileEntities = dbContext.SoilProfileEntities;
+ soilProfileEntities.RemoveRange(soilProfileEntities.Local.Except(soilProfiles));
+
+ var soilLayerEntities = dbContext.SoilLayerEntities;
+ soilLayerEntities.RemoveRange(soilLayerEntities.Local.Except(soilLayers));
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r164e03c3a4957d7a0dd4012f146b0ca139a7a4cc -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 164e03c3a4957d7a0dd4012f146b0ca139a7a4cc)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -91,10 +91,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -106,6 +124,15 @@
+
+
+
+
+
+
+
+
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/AssessmentSectionCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/AssessmentSectionCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/AssessmentSectionCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,122 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class AssessmentSectionCreateExtensionsTest
+ {
+ [Test]
+ [TestCase(AssessmentSectionComposition.Dike)]
+ [TestCase(AssessmentSectionComposition.DikeAndDune)]
+ [TestCase(AssessmentSectionComposition.Dune)]
+ public void Create_WithoutCollector_ThrowsArgumentNullException(AssessmentSectionComposition assessmentSectionComposition)
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(assessmentSectionComposition);
+
+ // Call
+ TestDelegate test = () => assessmentSection.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ [TestCase(AssessmentSectionComposition.Dike)]
+ [TestCase(AssessmentSectionComposition.DikeAndDune)]
+ [TestCase(AssessmentSectionComposition.Dune)]
+ public void Create_WithCollector_ReturnsAssessmentSectionEntityWithCompositionAndFailureMechanismForPiping(AssessmentSectionComposition assessmentSectionComposition)
+ {
+ // Setup
+ string testName = "testName";
+ var assessmentSection = new AssessmentSection(assessmentSectionComposition)
+ {
+ Name = testName
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = assessmentSection.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual((short)assessmentSectionComposition, entity.Composition);
+ Assert.AreEqual(testName, entity.Name);
+ Assert.AreEqual(9, entity.FailureMechanismEntities.Count);
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.Piping));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.MacrostabilityInwards));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.StructureHeight));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.ReliabilityClosingOfStructure));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.StrengthAndStabilityPointConstruction));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.StabilityStoneRevetment));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.WaveImpactOnAsphaltRevetment));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.GrassRevetmentErosionOutwards));
+ Assert.IsNotNull(entity.FailureMechanismEntities.SingleOrDefault(fme => fme.FailureMechanismType == (short)FailureMechanismType.DuneErosion));
+
+ Assert.IsNull(entity.HydraulicDatabaseLocation);
+ Assert.IsNull(entity.HydraulicDatabaseVersion);
+ Assert.IsEmpty(entity.HydraulicLocationEntities);
+
+ Assert.IsEmpty(entity.ReferenceLinePointEntities);
+ }
+
+ [Test]
+ public void Create_WithHydraulicBoundaryDatabase_SetsPropertiesAndLocationsToEntity()
+ {
+ // Setup
+ string testFilePath = "path";
+ string testVersion = "1";
+
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ FilePath = testFilePath,
+ Version = testVersion,
+ Locations =
+ {
+ new HydraulicBoundaryLocation(-1, "name", 1, 2)
+ }
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = assessmentSection.Create(collector);
+
+ // Assert
+ Assert.AreEqual(testFilePath, entity.HydraulicDatabaseLocation);
+ Assert.AreEqual(testVersion, entity.HydraulicDatabaseVersion);
+ Assert.AreEqual(1, entity.HydraulicLocationEntities.Count);
+ }
+
+ [Test]
+ public void Create_WithReferenceLine_AddsReferenceLinePointEntities()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ assessmentSection.ReferenceLine.SetGeometry(new []
+ {
+ new Point2D(1,0),
+ new Point2D(2,3),
+ new Point2D(5,3)
+ });
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = assessmentSection.Create(collector);
+
+ // Assert
+ Assert.AreEqual(3, entity.ReferenceLinePointEntities.Count);
+ Assert.AreEqual(new []{0,1,2}, entity.ReferenceLinePointEntities.Select(rpe => rpe.Order));
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,70 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class HydraulicBoundaryLocationCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "testName", 2, 3);
+
+ // Call
+ TestDelegate test = () => hydraulicBoundaryLocation.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ public void Create_WithCollector_ReturnsHydraulicBoundaryLocationEntityWithPropertiesSet()
+ {
+ // Setup
+ var testName = "testName";
+ var random = new Random(21);
+ var coordinateX = random.NextDouble();
+ var coordinateY = random.NextDouble();
+ var id = random.Next(0,150);
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(id, testName, coordinateX, coordinateY);
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = hydraulicBoundaryLocation.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(testName, entity.Name);
+ Assert.AreEqual(Convert.ToDecimal(coordinateX), entity.LocationX);
+ Assert.AreEqual(Convert.ToDecimal(coordinateY), entity.LocationY);
+ Assert.AreEqual(id, entity.LocationId);
+ Assert.IsNull(entity.DesignWaterLevel);
+ }
+
+ [Test]
+ public void Create_WithCollectorAndDesignWaterLevel_ReturnsHydraulicBoundaryLocationEntityWithDesignWaterLevelSet()
+ {
+ // Setup
+ var random = new Random(21);
+ var waterLevel = random.NextDouble();
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "testName", random.NextDouble(), random.NextDouble())
+ {
+ DesignWaterLevel = waterLevel
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = hydraulicBoundaryLocation.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(Convert.ToDecimal(waterLevel), entity.DesignWaterLevel);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingFailureMechanismCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,67 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class PipingFailureMechanismCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ TestDelegate test = () => failureMechanism.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Create_WithCollector_ReturnsFailureMechanismEntityWithPropertiesSet(bool isRelevant)
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism
+ {
+ IsRelevant = isRelevant
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = failureMechanism.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual((short)FailureMechanismType.Piping, entity.FailureMechanismType);
+ Assert.AreEqual(Convert.ToByte(isRelevant), entity.IsRelevant);
+ Assert.IsEmpty(entity.StochasticSoilModelEntities);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Create_WithStochasticSoilModels_ReturnsFailureMechanismEntityWithStochasticSoilModelEntities(bool isRelevant)
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+ failureMechanism.StochasticSoilModels.Add(new StochasticSoilModel(-1, "name", "segmentName"));
+ failureMechanism.StochasticSoilModels.Add(new StochasticSoilModel(-1, "name2", "segmentName2"));
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = failureMechanism.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(2, entity.StochasticSoilModelEntities.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingSoilLayerCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingSoilLayerCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingSoilLayerCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,48 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class PipingSoilLayerCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var soilLayer = new PipingSoilLayer(new Random(21).NextDouble());
+
+ // Call
+ TestDelegate test = () => soilLayer.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Create_WithCollector_ReturnsFailureMechanismEntityWithPropertiesSet(bool isAquifer)
+ {
+ // Setup
+ double top = new Random(21).NextDouble();
+ var soilLayer = new PipingSoilLayer(top)
+ {
+ IsAquifer = isAquifer
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = soilLayer.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(Convert.ToDecimal(top), entity.Top);
+ Assert.AreEqual(Convert.ToByte(isAquifer), entity.IsAquifer);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingSoilProfileCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingSoilProfileCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PipingSoilProfileCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,67 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class PipingSoilProfileCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var soilProfile = new TestPipingSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ public void Create_WithCollectorAndLayers_ReturnsSoilProfileEntityWithPropertiesAndSoilLayerEntitiesSet()
+ {
+ // Setup
+ string testName = "testName";
+ double bottom = new Random(21).NextDouble();
+ var layers = new []
+ {
+ new PipingSoilLayer(bottom + 1),
+ new PipingSoilLayer(bottom + 2)
+ };
+ var soilProfile = new PipingSoilProfile(testName, bottom, layers, SoilProfileType.SoilProfile1D, -1);
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = soilProfile.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(Convert.ToDecimal(bottom), entity.Bottom);
+ Assert.AreEqual(testName, entity.Name);
+ Assert.AreEqual(2, entity.SoilLayerEntities.Count);
+ }
+
+ [Test]
+ public void Create_ForTheSameEntityTwice_ReturnsSameSoilProfileEntityInstance()
+ {
+ // Setup
+ var soilProfile = new TestPipingSoilProfile();
+ var collector = new CreateConversionCollector();
+
+ var firstEntity = soilProfile.Create(collector);
+
+ // Call
+ var secondEntity = soilProfile.Create(collector);
+
+ // Assert
+ Assert.AreSame(firstEntity, secondEntity);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Point2DCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Point2DCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Point2DCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,33 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class Point2DCreateExtensionsTest
+ {
+ [Test]
+ [TestCase(0)]
+ [TestCase(100)]
+ [TestCase(Int32.MaxValue)]
+ [TestCase(Int32.MinValue)]
+ public void CreateReferenceLinePoint_Always_NewReferenceLinePointEntityWithPropertiesSet(int order)
+ {
+ // Setup
+ var random = new Random(21);
+ double x = random.NextDouble();
+ double y = random.NextDouble();
+ var soilProfile = new Point2D(x, y);
+
+ // Call
+ var entity = soilProfile.CreateReferenceLinePoint(order);
+
+ // Assert
+ Assert.AreEqual(Convert.ToDecimal(x), entity.X);
+ Assert.AreEqual(Convert.ToDecimal(y), entity.Y);
+ Assert.AreEqual(order, entity.Order);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProjectCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProjectCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ProjectCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,67 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Base.Data;
+using NUnit.Framework;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class ProjectCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var project = new Project();
+
+ // Call
+ TestDelegate test = () => project.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ public void Create_WithCollector_ReturnsProjectEntityWithDescription()
+ {
+ // Setup
+ var testdescription = "testDescription";
+ var project = new Project
+ {
+ Description = testdescription
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = project.Create(collector);
+
+ // Assert
+ Assert.NotNull(entity);
+ Assert.AreEqual(testdescription, entity.Description);
+ }
+
+ [Test]
+ public void Create_WithAssessmentSections_AddsSectionsToEntity()
+ {
+ // Setup
+ var project = new Project
+ {
+ Items =
+ {
+ new AssessmentSection(AssessmentSectionComposition.Dike)
+ }
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = project.Create(collector);
+
+ // Assert
+ Assert.AreEqual(1, entity.AssessmentSectionEntities.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StochasticSoilModelCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StochasticSoilModelCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StochasticSoilModelCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,71 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Data.TestUtil;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class StochasticSoilModelCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var stochasticSoilModel = new TestStochasticSoilModel();
+
+ // Call
+ TestDelegate test = () => stochasticSoilModel.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ public void Create_WithCollector_ReturnsStochasticSoilModelEntityWithPropertiesSet()
+ {
+ // Setup
+ string testName = "testName";
+ string testSegmentName = "testSegmentName";
+ var stochasticSoilModel = new StochasticSoilModel(-1, testName, testSegmentName);
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = stochasticSoilModel.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(testName, entity.Name);
+ Assert.AreEqual(testSegmentName, entity.SegmentName);
+ Assert.IsEmpty(entity.StochasticSoilProfileEntities);
+ }
+
+ [Test]
+ public void Create_WithStochasticSoilProfiles_ReturnsStochasticSoilModelEntityWithPropertiesAndStochasticSoilProfileEntitiesSet()
+ {
+ // Setup
+ var stochasticSoilModel = new StochasticSoilModel(-1, "testName", "testSegmentName");
+ stochasticSoilModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(50, SoilProfileType.SoilProfile1D, -1)
+ {
+ SoilProfile = new TestPipingSoilProfile()
+ });
+ stochasticSoilModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(50, SoilProfileType.SoilProfile1D, -1)
+ {
+ SoilProfile = new TestPipingSoilProfile()
+ });
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = stochasticSoilModel.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(2, entity.StochasticSoilProfileEntities.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StochasticSoilProfileCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StochasticSoilProfileCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StochasticSoilProfileCreateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,69 @@
+using System;
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ public class StochasticSoilProfileCreateExtensionsTest
+ {
+ [Test]
+ public void Create_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var stochasticSoilProfile = new StochasticSoilProfile(40, SoilProfileType.SoilProfile1D, -1);
+
+ // Call
+ TestDelegate test = () => stochasticSoilProfile.Create(null);
+
+ // Assert
+ var parameterName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameterName);
+ }
+
+ [Test]
+ public void Create_WithCollector_ReturnsStochasticSoilProfileEntityWithPropertiesSet()
+ {
+ // Setup
+ var probability = new Random(21).NextDouble();
+ var stochasticSoilProfile = new StochasticSoilProfile(probability, SoilProfileType.SoilProfile1D, -1)
+ {
+ SoilProfile = new TestPipingSoilProfile()
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var entity = stochasticSoilProfile.Create(collector);
+
+ // Assert
+ Assert.IsNotNull(entity);
+ Assert.AreEqual(probability, entity.Probability);
+ }
+
+ [Test]
+ public void Create_DifferentStochasticSoilProfilesWithSamePipingSoilProfile_ReturnsStochasticSoilProfileEntityWithSameSoilProfileEntitySet()
+ {
+ // Setup
+ var testPipingSoilProfile = new TestPipingSoilProfile();
+ var firstStochasticSoilProfile = new StochasticSoilProfile(new Random(21).NextDouble(), SoilProfileType.SoilProfile1D, -1)
+ {
+ SoilProfile = testPipingSoilProfile
+ };
+ var secondStochasticSoilProfile = new StochasticSoilProfile(new Random(21).NextDouble(), SoilProfileType.SoilProfile1D, -1)
+ {
+ SoilProfile = testPipingSoilProfile
+ };
+ var collector = new CreateConversionCollector();
+
+ // Call
+ var firstEntity = firstStochasticSoilProfile.Create(collector);
+ var secondEntity = secondStochasticSoilProfile.Create(collector);
+
+ // Assert
+ Assert.AreSame(firstEntity.SoilProfileEntity, secondEntity.SoilProfileEntity);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ProjectPersistorTest.cs
===================================================================
diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ProjectPersistorTest.cs (.../ProjectPersistorTest.cs) (revision a9aafffab97152303562110b1d789bacb465ce24)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ProjectPersistorTest.cs (.../ProjectPersistorTest.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -79,7 +79,7 @@
ProjectPersistor persistor = new ProjectPersistor(ringtoetsEntities);
// Call
- TestDelegate test = () => persistor.GetEntityAsModel();
+ TestDelegate test = () => persistor.Read();
// Assert
Assert.DoesNotThrow(test);
@@ -105,7 +105,7 @@
ProjectPersistor persistor = new ProjectPersistor(ringtoetsEntities);
// Call
- Project model = persistor.GetEntityAsModel();
+ Project model = persistor.Read();
// Assert
Assert.IsInstanceOf(model);
@@ -136,7 +136,7 @@
ProjectPersistor persistor = new ProjectPersistor(ringtoetsEntities);
// Call
- Project model = persistor.GetEntityAsModel();
+ Project model = persistor.Read();
// Assert
Assert.IsInstanceOf(model);
@@ -167,7 +167,7 @@
ProjectPersistor persistor = new ProjectPersistor(ringtoetsEntities);
// Call
- TestDelegate test = () => persistor.GetEntityAsModel();
+ TestDelegate test = () => persistor.Read();
// Assert
Assert.Throws(test);
@@ -203,7 +203,7 @@
ProjectPersistor persistor = new ProjectPersistor(ringtoetsEntities);
// Call
- Project model = persistor.GetEntityAsModel();
+ Project model = persistor.Read();
// Assert
Assert.IsInstanceOf(model);
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/AssessmentSectionEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,242 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+using NUnit.Framework;
+using Ringtoets.Common.Data.AssessmentSection;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class AssessmentSectionEntityTest
+ {
+ [Test]
+ public void Read_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new AssessmentSectionEntity();
+
+ // Call
+ TestDelegate test = () => entity.Read(null);
+
+ // Assert
+ var parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameter);
+ }
+
+ [Test]
+ [TestCase(AssessmentSectionComposition.Dike)]
+ [TestCase(AssessmentSectionComposition.DikeAndDune)]
+ [TestCase(AssessmentSectionComposition.Dune)]
+ public void Read_WithCollector_ReturnsNewAssessmentSection(AssessmentSectionComposition assessmentSectionComposition)
+ {
+ // Setup
+ var testName = "testName";
+ var entityId = new Random(21).Next(1, 502);
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = entityId,
+ Name = testName,
+ Composition = (short)assessmentSectionComposition
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var section = entity.Read(collector);
+
+ // Assert
+ Assert.IsNotNull(section);
+ Assert.AreEqual(entityId, section.StorageId);
+ Assert.AreEqual(testName, section.Name);
+ Assert.AreEqual(assessmentSectionComposition, section.Composition);
+ Assert.IsNull(section.HydraulicBoundaryDatabase);
+ Assert.IsNull(section.ReferenceLine);
+ }
+
+ [Test]
+ public void Read_WithReferenceLineEntities_ReturnsNewAssessmentSectionWithReferenceLineSet()
+ {
+ // Setup
+ var entity = new AssessmentSectionEntity();
+
+ var random = new Random(21);
+ double firstX = random.NextDouble();
+ double firstY = random.NextDouble();
+ double secondX = random.NextDouble();
+ double secondY = random.NextDouble();
+ entity.ReferenceLinePointEntities.Add(new ReferenceLinePointEntity { Order = 2, X = Convert.ToDecimal(firstX), Y = Convert.ToDecimal(firstY) });
+ entity.ReferenceLinePointEntities.Add(new ReferenceLinePointEntity { Order = 1, X = Convert.ToDecimal(secondX), Y = Convert.ToDecimal(secondY) });
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var section = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(2, section.ReferenceLine.Points.Count());
+ Assert.AreEqual(secondX, section.ReferenceLine.Points.ElementAt(0).X, 1e-6);
+ Assert.AreEqual(secondY, section.ReferenceLine.Points.ElementAt(0).Y, 1e-6);
+ Assert.AreEqual(firstX, section.ReferenceLine.Points.ElementAt(1).X, 1e-6);
+ Assert.AreEqual(firstY, section.ReferenceLine.Points.ElementAt(1).Y, 1e-6);
+ }
+
+ [Test]
+ public void Read_WithHydraulicDatabaseLocationSet_ReturnsNewAssessmentSectionWithHydraulicDatabaseSet()
+ {
+ // Setup
+ var entity = new AssessmentSectionEntity();
+
+ var testLocation = "testLocation";
+ var testVersion = "testVersion";
+ entity.HydraulicDatabaseLocation = testLocation;
+ entity.HydraulicDatabaseVersion = testVersion;
+ entity.HydraulicLocationEntities.Add(new HydraulicLocationEntity
+ {
+ Name = "someName"
+ });
+ entity.HydraulicLocationEntities.Add(new HydraulicLocationEntity
+ {
+ Name = "someName"
+ });
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var section = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(2, section.HydraulicBoundaryDatabase.Locations.Count);
+ Assert.AreEqual(testLocation, section.HydraulicBoundaryDatabase.FilePath);
+ Assert.AreEqual(testVersion, section.HydraulicBoundaryDatabase.Version);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_WithFailureMechanismWithStochasticSoilModelsSet_ReturnsNewAssessmentSectionWithStochasticSoilModelsInPipingFailureMechanism(bool isRelevant)
+ {
+ // Setup
+ var entity = new AssessmentSectionEntity();
+ var entityId = new Random(21).Next(1, 502);
+
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = entityId,
+ FailureMechanismType = (int)FailureMechanismType.Piping,
+ IsRelevant = Convert.ToByte(isRelevant),
+ StochasticSoilModelEntities =
+ {
+ new StochasticSoilModelEntity(),
+ new StochasticSoilModelEntity()
+ }
+ };
+ entity.FailureMechanismEntities.Add(failureMechanismEntity);
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var section = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(2, section.PipingFailureMechanism.StochasticSoilModels.Count);
+ Assert.AreEqual(entityId, section.PipingFailureMechanism.StorageId);
+ Assert.AreEqual(isRelevant, section.PipingFailureMechanism.IsRelevant);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_WithFailureMechanismPlaceholdersSet_ReturnsNewAssessmentSectionWithFailureMechanismsSet(bool isRelevant)
+ {
+ // Setup
+ var entity = new AssessmentSectionEntity();
+ var macrostabilityInwardsEntityId = 2;
+ var overtoppingEntityId = 3;
+ var closingEntityId = 16;
+ var failingOfConstructionEntityId = 22;
+ var stoneRevetmentEntityId = 36;
+ var asphaltRevetmentEntityId = 77;
+ var grassRevetmentEntityId = 133;
+ var duneErosionEntityId = 256;
+
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = macrostabilityInwardsEntityId,
+ FailureMechanismType = (short)FailureMechanismType.MacrostabilityInwards,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = overtoppingEntityId,
+ FailureMechanismType = (short)FailureMechanismType.StructureHeight,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = closingEntityId,
+ FailureMechanismType = (short)FailureMechanismType.ReliabilityClosingOfStructure,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = failingOfConstructionEntityId,
+ FailureMechanismType = (short)FailureMechanismType.StrengthAndStabilityPointConstruction,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = stoneRevetmentEntityId,
+ FailureMechanismType = (short)FailureMechanismType.StabilityStoneRevetment,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = asphaltRevetmentEntityId,
+ FailureMechanismType = (short)FailureMechanismType.WaveImpactOnAsphaltRevetment,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = grassRevetmentEntityId,
+ FailureMechanismType = (short)FailureMechanismType.GrassRevetmentErosionOutwards,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+ entity.FailureMechanismEntities.Add(new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = duneErosionEntityId,
+ FailureMechanismType = (short)FailureMechanismType.DuneErosion,
+ IsRelevant = Convert.ToByte(isRelevant)
+ });
+
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var section = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(macrostabilityInwardsEntityId, section.MacrostabilityInwards.StorageId);
+ Assert.AreEqual(isRelevant, section.MacrostabilityInwards.IsRelevant);
+
+ Assert.AreEqual(overtoppingEntityId, section.Overtopping.StorageId);
+ Assert.AreEqual(isRelevant, section.Overtopping.IsRelevant);
+
+ Assert.AreEqual(closingEntityId, section.Closing.StorageId);
+ Assert.AreEqual(isRelevant, section.Closing.IsRelevant);
+
+ Assert.AreEqual(failingOfConstructionEntityId, section.FailingOfConstruction.StorageId);
+ Assert.AreEqual(isRelevant, section.FailingOfConstruction.IsRelevant);
+
+ Assert.AreEqual(stoneRevetmentEntityId, section.StoneRevetment.StorageId);
+ Assert.AreEqual(isRelevant, section.StoneRevetment.IsRelevant);
+
+ Assert.AreEqual(asphaltRevetmentEntityId, section.AsphaltRevetment.StorageId);
+ Assert.AreEqual(isRelevant, section.AsphaltRevetment.IsRelevant);
+
+ Assert.AreEqual(grassRevetmentEntityId, section.GrassRevetment.StorageId);
+ Assert.AreEqual(isRelevant, section.GrassRevetment.IsRelevant);
+
+ Assert.AreEqual(duneErosionEntityId, section.DuneErosion.StorageId);
+ Assert.AreEqual(isRelevant, section.DuneErosion.IsRelevant);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,68 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ public class FailureMechanismEntityTest
+ {
+ [Test]
+ public void ReadAsPipingFailureMechanism_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new FailureMechanismEntity();
+
+ // Call
+ TestDelegate test = () => entity.ReadAsPipingFailureMechanism(null);
+
+ // Assert
+ var parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameter);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void ReadAsPipingFailureMechanism_WithCollector_ReturnsNewPipingFailureMechanismWithPropertiesSet(bool isRelevant)
+ {
+ // Setup
+ var entityId = new Random(21).Next(1, 502);
+ var entity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = entityId,
+ IsRelevant = Convert.ToByte(isRelevant),
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var failureMechanism = entity.ReadAsPipingFailureMechanism(collector);
+
+ // Assert
+ Assert.IsNotNull(failureMechanism);
+ Assert.AreEqual(entityId, failureMechanism.StorageId);
+ Assert.AreEqual(isRelevant, failureMechanism.IsRelevant);
+ }
+
+ [Test]
+ public void ReadAsPipingFailureMechanism_WithStochasticSoilModelsSet_ReturnsNewPipingFailureMechanismWithStochasticSoilModels()
+ {
+ // Setup
+ var entity = new FailureMechanismEntity
+ {
+ StochasticSoilModelEntities =
+ {
+ new StochasticSoilModelEntity(),
+ new StochasticSoilModelEntity()
+ }
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var failureMechanism = entity.ReadAsPipingFailureMechanism(collector);
+
+ // Assert
+ Assert.AreEqual(2, failureMechanism.StochasticSoilModels.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HydraulicLocationEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HydraulicLocationEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/HydraulicLocationEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,64 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class HydraulicLocationEntityTest
+ {
+ [Test]
+ public void Read_Always_ReturnsHydraulicBoundaryLocationWithPropertiesSet()
+ {
+ // Setup
+ var random = new Random(21);
+ long testId = random.Next(0, 400);
+ var entityId = new Random(21).Next(1, 502);
+ var testName = "testName";
+ double x = random.NextDouble();
+ double y = random.NextDouble();
+ var entity = new HydraulicLocationEntity
+ {
+ HydraulicLocationEntityId = entityId,
+ LocationId = testId,
+ Name = testName,
+ LocationX = Convert.ToDecimal(x),
+ LocationY = Convert.ToDecimal(y)
+ };
+
+ // Call
+ var location = entity.Read();
+
+ // Assert
+ Assert.IsNotNull(location);
+ Assert.AreEqual(entityId, location.StorageId);
+ Assert.AreEqual(testId, location.Id);
+ Assert.AreEqual(testName, location.Name);
+ Assert.AreEqual(x, location.Location.X, 1e-6);
+ Assert.AreEqual(y, location.Location.Y, 1e-6);
+ }
+
+ [Test]
+ [TestCase(null, double.NaN)]
+ [TestCase(double.MaxValue, double.MaxValue)]
+ [TestCase(double.MinValue, double.MinValue)]
+ [TestCase(1.5, 1.5)]
+ [TestCase(double.NaN, double.NaN)]
+ public void Read_DifferentDesignWaterLevel_ReturnHydraulicBoundaryLocationWithExpectedWaterLevel(double? waterLevel, double expectedWaterLevel)
+ {
+ // Setup
+ var entity = new HydraulicLocationEntity
+ {
+ Name = "someName",
+ DesignWaterLevel = waterLevel
+ };
+
+ // Call
+ var location = entity.Read();
+
+ // Assert
+ Assert.IsNotNull(location);
+ Assert.AreEqual(expectedWaterLevel, location.DesignWaterLevel);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ProjectEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ProjectEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ProjectEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,52 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class ProjectEntityTest
+ {
+ [Test]
+ public void Read_Always_ReturnsNewProjectWithPropertiesSet()
+ {
+ // Setup
+ var testDescription = "testName";
+ var entityId = new Random(21).Next(1,502);
+ var entity = new ProjectEntity
+ {
+ ProjectEntityId = entityId,
+ Description = testDescription
+ };
+
+ // Call
+ var project = entity.Read();
+
+ // Assert
+ Assert.IsNotNull(project);
+ Assert.AreEqual(entityId, project.StorageId);
+ Assert.AreEqual(testDescription, project.Description);
+ }
+
+ [Test]
+ public void Read_WithAssessmentSection_ReturnsNewProjectWithAssessmentSections()
+ {
+ // Setup
+ var entity = new ProjectEntity
+ {
+ Description = "testName",
+ AssessmentSectionEntities =
+ {
+ new AssessmentSectionEntity(),
+ new AssessmentSectionEntity()
+ }
+ };
+
+ // Call
+ var project = entity.Read();
+
+ // Assert
+ Assert.AreEqual(2, project.Items.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReferenceLinePointEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReferenceLinePointEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReferenceLinePointEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,31 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class ReferenceLinePointEntityTest
+ {
+ [Test]
+ public void Read_Always_NewPoint()
+ {
+ // Setup
+ var random = new Random(21);
+ double x = random.NextDouble();
+ double y = random.NextDouble();
+ var entity = new ReferenceLinePointEntity
+ {
+ X = Convert.ToDecimal(x),
+ Y = Convert.ToDecimal(y)
+ };
+
+ // Call
+ var point = entity.Read();
+
+ // Assert
+ Assert.AreEqual(x, point.X, 1e-6);
+ Assert.AreEqual(y, point.Y, 1e-6);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SoilLayerEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SoilLayerEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SoilLayerEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,36 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class SoilLayerEntityTest
+ {
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_Always_NewPoint(bool isAquifer)
+ {
+ // Setup
+ var random = new Random(21);
+ var entityId = random.Next(1, 502);
+ double top = random.NextDouble();
+ var entity = new SoilLayerEntity
+ {
+ SoilLayerEntityId = entityId,
+ Top = Convert.ToDecimal(top),
+ IsAquifer = Convert.ToByte(isAquifer)
+ };
+
+ // Call
+ var layer = entity.Read();
+
+ // Assert
+ Assert.IsNotNull(layer);
+ Assert.AreEqual(entityId, layer.StorageId);
+ Assert.AreEqual(top, layer.Top, 1e-6);
+ Assert.AreEqual(isAquifer, layer.IsAquifer);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SoilProfileEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SoilProfileEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SoilProfileEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,101 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class SoilProfileEntityTest
+ {
+ [Test]
+ public void Read_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new SoilProfileEntity();
+
+ // Call
+ TestDelegate test = () => entity.Read(null);
+
+ // Assert
+ var parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameter);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_WithCollector_ReturnsNewPipingSoilProfileWithPropertiesSet(bool isRelevant)
+ {
+ // Setup
+ string testName = "testName";
+ var random = new Random(21);
+ var entityId = random.Next(1, 502);
+ double bottom = random.NextDouble();
+ var entity = new SoilProfileEntity
+ {
+ SoilProfileEntityId = entityId,
+ Name = testName,
+ Bottom = Convert.ToDecimal(bottom),
+ SoilLayerEntities =
+ {
+ new SoilLayerEntity{ Top = Convert.ToDecimal(bottom + 0.5) },
+ new SoilLayerEntity{ Top = Convert.ToDecimal(bottom + 1.2) }
+ }
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var failureMechanism = entity.Read(collector);
+
+ // Assert
+ Assert.IsNotNull(failureMechanism);
+ Assert.AreEqual(entityId, failureMechanism.StorageId);
+ Assert.AreEqual(testName, failureMechanism.Name);
+ Assert.AreEqual(bottom, failureMechanism.Bottom, 1e-6);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_WithCollectorWithoutLayers_ThrowsArgumentException(bool isRelevant)
+ {
+ // Setup
+ var entity = new SoilProfileEntity();
+ var collector = new ReadConversionCollector();
+
+ // Call
+ TestDelegate test = () => entity.Read(collector);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Read_WithCollectorReadTwice_ReturnsSamePipingSoilProfile()
+ {
+ // Setup
+ string testName = "testName";
+ double bottom = new Random(21).NextDouble();
+ var entity = new SoilProfileEntity
+ {
+ Name = testName,
+ Bottom = Convert.ToDecimal(bottom),
+ SoilLayerEntities =
+ {
+ new SoilLayerEntity{ Top = Convert.ToDecimal(bottom + 0.5) },
+ new SoilLayerEntity{ Top = Convert.ToDecimal(bottom + 1.2) }
+ }
+ };
+ var collector = new ReadConversionCollector();
+
+ var firstFailureMechanism = entity.Read(collector);
+
+ // Call
+ var secondFailureMechanism = entity.Read(collector);
+
+ // Assert
+ Assert.AreSame(firstFailureMechanism, secondFailureMechanism);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,89 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class StochasticSoilModelEntityTest
+ {
+ [Test]
+ public void Read_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new StochasticSoilModelEntity();
+
+ // Call
+ TestDelegate test = () => entity.Read(null);
+
+ // Assert
+ var parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameter);
+ }
+
+ [Test]
+ public void Read_WithCollector_ReturnsNewStochasticSoilModelWithPropertiesSet()
+ {
+ // Setup
+ var entityId = new Random(21).Next(1, 502);
+ string testName = "testName";
+ string testSegmentName = "testSegmentName";
+ var entity = new StochasticSoilModelEntity
+ {
+ StochasticSoilModelEntityId = entityId,
+ Name = testName,
+ SegmentName = testSegmentName,
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var model = entity.Read(collector);
+
+ // Assert
+ Assert.IsNotNull(model);
+ Assert.AreEqual(entityId, model.StorageId);
+ Assert.AreEqual(testName, model.Name);
+ Assert.AreEqual(testSegmentName, model.SegmentName);
+ }
+
+ [Test]
+ public void Read_WithCollectorWithStochasticSoilProfiles_ReturnsNewStochasticSoilModelWithStochasticSoilProfiles()
+ {
+ // Setup
+ var entity = new StochasticSoilModelEntity
+ {
+ StochasticSoilProfileEntities =
+ {
+ new StochasticSoilProfileEntity
+ {
+ SoilProfileEntity = new SoilProfileEntity
+ {
+ SoilLayerEntities =
+ {
+ new SoilLayerEntity()
+ }
+ }
+ },
+ new StochasticSoilProfileEntity
+ {
+ SoilProfileEntity = new SoilProfileEntity
+ {
+ SoilLayerEntities =
+ {
+ new SoilLayerEntity()
+ }
+ }
+ }
+ }
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var model = entity.Read(collector);
+
+ // Assert
+ Assert.AreEqual(2, model.StochasticSoilProfiles.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilProfileEntityTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilProfileEntityTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilProfileEntityTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,89 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class StochasticSoilProfileEntityTest
+ {
+ [Test]
+ public void Read_WithoutCollector_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new StochasticSoilProfileEntity();
+
+ // Call
+ TestDelegate test = () => entity.Read(null);
+
+ // Assert
+ var parameter = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", parameter);
+ }
+
+ [Test]
+ public void Read_WithCollector_ReturnsNewStochasticSoilProfileWithPropertiesSet()
+ {
+ // Setup
+ var random = new Random(21);
+ double probability = random.NextDouble();
+ var entityId = random.Next(1, 502);
+ var entity = new StochasticSoilProfileEntity
+ {
+ StochasticSoilProfileEntityId = entityId,
+ Probability = Convert.ToDecimal(probability),
+ SoilProfileEntity = new SoilProfileEntity
+ {
+ SoilLayerEntities =
+ {
+ new SoilLayerEntity()
+ }
+ }
+ };
+ var collector = new ReadConversionCollector();
+
+ // Call
+ var profile = entity.Read(collector);
+
+ // Assert
+ Assert.IsNotNull(profile);
+ Assert.AreEqual(entityId, profile.StorageId);
+ Assert.AreEqual(probability, profile.Probability, 1e-6);
+ }
+
+ [Test]
+ public void Read_WithCollectorDifferentStochasticSoilProfileEntitiesWithSameSoilProfileEntity_ReturnsStochasticSoilProfilesWithSamePipingSoilProfile()
+ {
+ // Setup
+ double probability = new Random(21).NextDouble();
+ var soilProfileEntity = new SoilProfileEntity
+ {
+ SoilLayerEntities =
+ {
+ new SoilLayerEntity()
+ }
+ };
+ var firstEntity = new StochasticSoilProfileEntity
+ {
+ Probability = Convert.ToDecimal(probability),
+ SoilProfileEntity = soilProfileEntity
+ };
+ var secondEntity = new StochasticSoilProfileEntity
+ {
+ Probability = 1- Convert.ToDecimal(probability),
+ SoilProfileEntity = soilProfileEntity
+ };
+ var collector = new ReadConversionCollector();
+
+ var firstProfile = firstEntity.Read(collector);
+
+ // Call
+ var secondProfile = secondEntity.Read(collector);
+
+ // Assert
+ Assert.AreNotSame(firstProfile, secondProfile);
+ Assert.AreSame(firstProfile.SoilProfile, secondProfile.SoilProfile);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/AssessmentSectionUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/AssessmentSectionUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/AssessmentSectionUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,510 @@
+using System;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using Core.Common.Base.Geometry;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.HydraRing.Data;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class AssessmentSectionUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ // Call
+ TestDelegate test = () => section.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ // Call
+ TestDelegate test = () => section.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoAssessmentSection_EntityNotFoundException()
+ {
+ // Setup
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ // Call
+ TestDelegate test = () => section.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_ContextWithNoAssessmentSectionWithId_EntityNotFoundException()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1
+ };
+
+ ringtoetsEntities.AssessmentSectionEntities.Add(new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 2
+ });
+
+ // Call
+ TestDelegate test = () => section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.Throws(test);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithAssessmentSection_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var newName = "newName";
+ var composition = AssessmentSectionComposition.Dune;
+ var section = new AssessmentSection(composition)
+ {
+ StorageId = 1,
+ Name = newName
+ };
+
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1,
+ Name = string.Empty,
+ Composition = (short) AssessmentSectionComposition.Dike
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for failure mechanisms
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(newName, entity.Name);
+ Assert.AreEqual((short) composition, entity.Composition);
+ Assert.IsEmpty(entity.ReferenceLinePointEntities);
+ Assert.IsEmpty(entity.HydraulicLocationEntities);
+ Assert.IsNull(entity.HydraulicDatabaseLocation);
+ Assert.IsNull(entity.HydraulicDatabaseVersion);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_AssessmentSectionWithNewReferenceLine_ReferenceLineAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ ReferenceLine referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1, 2)
+ });
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1,
+ ReferenceLine = referenceLine
+ };
+
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for failure mechanisms
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, entity.ReferenceLinePointEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_AssessmentSectionWithExistingReferenceLine_PointsRemovedFromContextAndNewPointAddedToEntity()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ ReferenceLine referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1, 2)
+ });
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1,
+ ReferenceLine = referenceLine
+ };
+
+ var referenceLinePointEntity = new ReferenceLinePointEntity
+ {
+ X = 2, Y = 3
+ };
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1,
+ ReferenceLinePointEntities =
+ {
+ referenceLinePointEntity
+ }
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for failure mechanisms
+ ringtoetsEntities.ReferenceLinePointEntities.Add(referenceLinePointEntity);
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(0, ringtoetsEntities.ReferenceLinePointEntities.Count());
+ Assert.AreEqual(1, entity.ReferenceLinePointEntities.Count(p => p.X == 1 && p.Y == 2));
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_AssessmentSectionWithNewHydraulicDatabase_PropertiesUpdatedAndLocationsAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var newVersion = "new version";
+ var filePath = "new path";
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1,
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ FilePath = filePath,
+ Version = newVersion,
+ Locations =
+ {
+ new HydraulicBoundaryLocation(-1, string.Empty, 0, 0)
+ }
+ }
+ };
+
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for failure mechanisms
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(filePath, entity.HydraulicDatabaseLocation);
+ Assert.AreEqual(newVersion, entity.HydraulicDatabaseVersion);
+ Assert.AreEqual(1, entity.HydraulicLocationEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_AssessmentSectionWithUpdatedHydraulicDatabase_PropertiesUpdatedAndLocationUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var newVersion = "new version";
+ var filePath = "new path";
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, string.Empty, 0, 0)
+ {
+ StorageId = 1
+ };
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1,
+ HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase
+ {
+ FilePath = filePath,
+ Version = newVersion,
+ Locations =
+ {
+ hydraulicBoundaryLocation
+ }
+ }
+ };
+
+ var hydraulicLocationEntity = new HydraulicLocationEntity
+ {
+ HydraulicLocationEntityId = 1
+ };
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1,
+ HydraulicDatabaseLocation = "old location",
+ HydraulicDatabaseVersion = "old version",
+ HydraulicLocationEntities =
+ {
+ hydraulicLocationEntity
+ }
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for failure mechanisms
+ ringtoetsEntities.HydraulicLocationEntities.Add(hydraulicLocationEntity);
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(filePath, entity.HydraulicDatabaseLocation);
+ Assert.AreEqual(newVersion, entity.HydraulicDatabaseVersion);
+ CollectionAssert.AreEqual(new[]
+ {
+ hydraulicLocationEntity
+ }, entity.HydraulicLocationEntities);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_AssessmentSectionWithUpdatedPipingFailureMechanism_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1,
+ PipingFailureMechanism =
+ {
+ StorageId = 1,
+ Contribution = 0.5,
+ IsRelevant = true
+ }
+ };
+
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1,
+ FailureMechanismEntities =
+ {
+ failureMechanismEntity
+ }
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for all other failure mechanisms
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ failureMechanismEntity
+ }, entity.FailureMechanismEntities);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_AssessmentSectionWithUpdatedFailureMechanismPlaceholders_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var section = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1,
+ MacrostabilityInwards =
+ {
+ StorageId = 1,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ Overtopping =
+ {
+ StorageId = 2,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ Closing =
+ {
+ StorageId = 3,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ FailingOfConstruction =
+ {
+ StorageId = 4,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ StoneRevetment =
+ {
+ StorageId = 5,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ AsphaltRevetment =
+ {
+ StorageId = 6,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ GrassRevetment =
+ {
+ StorageId = 7,
+ Contribution = 0.5,
+ IsRelevant = true
+ },
+ DuneErosion =
+ {
+ StorageId = 8,
+ Contribution = 0.5,
+ IsRelevant = true
+ }
+ };
+
+ var macrostabilityInwardsEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var overtoppingEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 2,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var closingEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 3,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var failingOfConstructionEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 4,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var stoneRevetmentEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 5,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var asphaltRevetmentEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 6,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var grassRevetmentEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 7,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var duneErosionEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 8,
+ IsRelevant = Convert.ToByte(false)
+ };
+ var entity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1,
+ FailureMechanismEntities =
+ {
+ macrostabilityInwardsEntity,
+ overtoppingEntity,
+ closingEntity,
+ failingOfConstructionEntity,
+ stoneRevetmentEntity,
+ asphaltRevetmentEntity,
+ grassRevetmentEntity,
+ duneErosionEntity
+ }
+ };
+ ringtoetsEntities.AssessmentSectionEntities.Add(entity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity()); // Dummy for piping
+ ringtoetsEntities.FailureMechanismEntities.Add(macrostabilityInwardsEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(overtoppingEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(closingEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(failingOfConstructionEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(stoneRevetmentEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(asphaltRevetmentEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(grassRevetmentEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(duneErosionEntity);
+
+ // Call
+ section.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ CollectionAssert.AreEqual(new[]
+ {
+ macrostabilityInwardsEntity,
+ overtoppingEntity,
+ closingEntity,
+ failingOfConstructionEntity,
+ stoneRevetmentEntity,
+ asphaltRevetmentEntity,
+ grassRevetmentEntity,
+ duneErosionEntity
+ }, entity.FailureMechanismEntities);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/HydraulicBoundaryLocationUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/HydraulicBoundaryLocationUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/HydraulicBoundaryLocationUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,108 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using Core.Common.Base.Data;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.HydraRing.Data;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class HydraulicBoundaryLocationUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+
+ // Call
+ TestDelegate test = () => hydraulicBoundaryLocation.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+
+ // Call
+ TestDelegate test = () => hydraulicBoundaryLocation.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoHydraulicBoundaryLocation_EntityNotFoundException()
+ {
+ // Setup
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+
+ // Call
+ TestDelegate test = () => hydraulicBoundaryLocation.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_WithHydraulicBoundaryLocation_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ double newX = random.NextDouble() * 10;
+ double newY = random.NextDouble() * 10;
+ long newId = 2;
+ string newName = "newName";
+ double newDesignWaterLevel = random.NextDouble() * 10;
+
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(newId, newName, newX, newY)
+ {
+ StorageId = 1,
+ DesignWaterLevel = newDesignWaterLevel
+ };
+
+ var hydraulicLocationEntity = new HydraulicLocationEntity
+ {
+ HydraulicLocationEntityId = 1,
+ DesignWaterLevel = 10,
+ LocationId = 2,
+ LocationX = Convert.ToDecimal(-3.2),
+ LocationY = Convert.ToDecimal(-3.5)
+ };
+
+ ringtoetsEntities.HydraulicLocationEntities.Add(hydraulicLocationEntity);
+
+ // Call
+ hydraulicBoundaryLocation.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(newName, hydraulicLocationEntity.Name);
+ Assert.AreEqual(newId, hydraulicLocationEntity.LocationId);
+ Assert.AreEqual(newX, Convert.ToDouble(hydraulicLocationEntity.LocationX), 1e-6);
+ Assert.AreEqual(newY, Convert.ToDouble(hydraulicLocationEntity.LocationY), 1e-6);
+ Assert.AreEqual(newDesignWaterLevel, hydraulicLocationEntity.DesignWaterLevel, 1e-6);
+
+ mocks.VerifyAll();
+ }
+
+ private class TestHydraulicBoundaryLocation : HydraulicBoundaryLocation
+ {
+ public TestHydraulicBoundaryLocation() : base(-1, string.Empty, 0, 0) {}
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/IStorableExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/IStorableExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/IStorableExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,34 @@
+using System;
+using Application.Ringtoets.Storage.Update;
+using Core.Common.Base.Storage;
+using NUnit.Framework;
+using Rhino.Mocks;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class IStorableExtensionsTest
+ {
+ [Test]
+ [TestCase(0, true)]
+ [TestCase(-1, true)]
+ [TestCase(Int32.MinValue, true)]
+ [TestCase(1, false)]
+ [TestCase(5, false)]
+ [TestCase(Int32.MaxValue, false)]
+ public void IsNew_DifferentIds_ExpectedResult(int val, bool isNew)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var storable = mocks.StrictMock();
+ storable.Expect(s => s.StorageId).Return(val);
+ mocks.ReplayAll();
+
+ // Call
+ var result = storable.IsNew();
+
+ // Assert
+ Assert.AreEqual(isNew, result);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingFailureMechanismUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,170 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class PipingFailureMechanismUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ TestDelegate test = () => failureMechanism.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ TestDelegate test = () => failureMechanism.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoHydraulicBoundaryLocation_EntityNotFoundException()
+ {
+ // Setup
+ var failureMechanism = new PipingFailureMechanism();
+
+ // Call
+ TestDelegate test = () => failureMechanism.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_ContextWithHydraulicBoundaryLocation_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new PipingFailureMechanism
+ {
+ StorageId = 1,
+ IsRelevant = true
+ };
+
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ IsRelevant = Convert.ToByte(false)
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+
+ // Call
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(Convert.ToByte(true), failureMechanismEntity.IsRelevant);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithNewStochasticSoilModel_SoilModelsAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new PipingFailureMechanism
+ {
+ StorageId = 1,
+ IsRelevant = true,
+ StochasticSoilModels =
+ {
+ new StochasticSoilModel(-1, string.Empty, string.Empty)
+ }
+ };
+
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ IsRelevant = Convert.ToByte(false)
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+
+ // Call
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, failureMechanismEntity.StochasticSoilModelEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithUpdatedStochasticSoilModel_NoNewSoilModelAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var failureMechanism = new PipingFailureMechanism
+ {
+ StorageId = 1,
+ StochasticSoilModels =
+ {
+ new StochasticSoilModel(-1, string.Empty, string.Empty)
+ {
+ StorageId = 1
+ }
+ }
+ };
+
+ var stochasticSoilModelEntity = new StochasticSoilModelEntity
+ {
+ StochasticSoilModelEntityId = 1
+ };
+ var failureMechanismEntity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = 1,
+ StochasticSoilModelEntities =
+ {
+ stochasticSoilModelEntity
+ }
+ };
+
+ ringtoetsEntities.FailureMechanismEntities.Add(failureMechanismEntity);
+ ringtoetsEntities.StochasticSoilModelEntities.Add(stochasticSoilModelEntity);
+
+ // Call
+ failureMechanism.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, failureMechanismEntity.StochasticSoilModelEntities.Count);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingSoilLayerUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingSoilLayerUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingSoilLayerUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,92 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class PipingSoilLayerUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var pipingSoilLayer = new PipingSoilLayer(0.5);
+
+ // Call
+ TestDelegate test = () => pipingSoilLayer.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var pipingSoilLayer = new PipingSoilLayer(0.5);
+
+ // Call
+ TestDelegate test = () => pipingSoilLayer.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoHydraulicBoundaryLocation_EntityNotFoundException()
+ {
+ // Setup
+ var pipingSoilLayer = new PipingSoilLayer(0.5);
+
+ // Call
+ TestDelegate test = () => pipingSoilLayer.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_WithHydraulicBoundaryLocation_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ double newTop = random.NextDouble() * 10;
+ var hydraulicBoundaryLocation = new PipingSoilLayer(newTop)
+ {
+ StorageId = 1,
+ IsAquifer = true
+ };
+
+ var soilLayerEntity = new SoilLayerEntity
+ {
+ SoilLayerEntityId = 1,
+ Top = 0,
+ IsAquifer = Convert.ToByte(false)
+ };
+
+ ringtoetsEntities.SoilLayerEntities.Add(soilLayerEntity);
+
+ // Call
+ hydraulicBoundaryLocation.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(Convert.ToDouble(newTop), Convert.ToDouble(soilLayerEntity.Top), 1e-6);
+ Assert.AreEqual(Convert.ToByte(true), soilLayerEntity.IsAquifer);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingSoilProfileUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingSoilProfileUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/PipingSoilProfileUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,144 @@
+using System;
+using System.Collections.Generic;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class PipingSoilProfileUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var soilProfile = new TestPipingSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var soilProfile = new TestPipingSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoStochasticSoilModel_EntityNotFoundException()
+ {
+ // Setup
+ var soilProfile = new TestPipingSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_NewSoilLayer_PropertiesUpdatedAndLayerAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ string newName = "new name";
+ double newBottom = 0.5;
+ IEnumerable newLayers = new[]
+ {
+ new PipingSoilLayer(5.0)
+ };
+ var soilProfile = new PipingSoilProfile(newName, newBottom, newLayers, SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = 1
+ };
+
+ var profileEntity = new SoilProfileEntity
+ {
+ SoilProfileEntityId = 1,
+ Name = string.Empty,
+ Bottom = 0
+ };
+
+ ringtoetsEntities.SoilProfileEntities.Add(profileEntity);
+
+ // Call
+ soilProfile.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(newName, profileEntity.Name);
+ Assert.AreEqual(newBottom, profileEntity.Bottom);
+ Assert.AreEqual(1, profileEntity.SoilLayerEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_UpdatedSoilLayer_StochasticSoilProfileAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ IEnumerable newLayers = new[]
+ {
+ new PipingSoilLayer(5.0)
+ {
+ StorageId = 1
+ }
+ };
+ var soilProfile = new PipingSoilProfile("new name", 0.5, newLayers, SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = 1
+ };
+
+ SoilLayerEntity soilLayerEntity = new SoilLayerEntity
+ {
+ SoilLayerEntityId = 1
+ };
+ var profileEntity = new SoilProfileEntity
+ {
+ SoilProfileEntityId = 1,
+ SoilLayerEntities =
+ {
+ soilLayerEntity
+ }
+ };
+
+ ringtoetsEntities.SoilProfileEntities.Add(profileEntity);
+ ringtoetsEntities.SoilLayerEntities.Add(soilLayerEntity);
+
+ // Call
+ soilProfile.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ CollectionAssert.AreEqual(new [] { soilLayerEntity }, profileEntity.SoilLayerEntities);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProjectUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProjectUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/ProjectUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,233 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using Core.Common.Base.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Integration.Data;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class ProjectUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var project = new Project();
+
+ // Call
+ TestDelegate test = () => project.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var project = new Project();
+
+ // Call
+ TestDelegate test = () => project.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoProject_EntityNotFoundException()
+ {
+ // Setup
+ var project = new Project();
+
+ // Call
+ TestDelegate test = () => project.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_ContextWithNoProjectWithId_EntityNotFoundException()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var project = new Project
+ {
+ StorageId = 1
+ };
+
+ ringtoetsEntities.ProjectEntities.Add(new ProjectEntity
+ {
+ ProjectEntityId = 2
+ });
+
+ // Call
+ TestDelegate test = () => project.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.Throws(test);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithMultipleProjectsWithId_EntityNotFoundException()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var project = new Project
+ {
+ StorageId = 1
+ };
+
+ ringtoetsEntities.ProjectEntities.Add(new ProjectEntity
+ {
+ ProjectEntityId = 1
+ });
+ ringtoetsEntities.ProjectEntities.Add(new ProjectEntity
+ {
+ ProjectEntityId = 1
+ });
+
+ // Call
+ TestDelegate test = () => project.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.Throws(test);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithProject_DescriptionUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var newDescription = "newDescription";
+ var project = new Project
+ {
+ StorageId = 1,
+ Description = newDescription
+ };
+
+ var entity = new ProjectEntity
+ {
+ ProjectEntityId = 1,
+ Description = string.Empty
+ };
+ ringtoetsEntities.ProjectEntities.Add(entity);
+
+ // Call
+ project.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(newDescription, entity.Description);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ProjectWithNewSection_SectionAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var newDescription = "newDescription";
+ var project = new Project
+ {
+ StorageId = 1,
+ Items =
+ {
+ new AssessmentSection(AssessmentSectionComposition.Dike)
+ }
+ };
+
+ var entity = new ProjectEntity
+ {
+ ProjectEntityId = 1
+ };
+ ringtoetsEntities.ProjectEntities.Add(entity);
+
+ // Call
+ project.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, entity.AssessmentSectionEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ProjectWithExistingSection_NoSectionsAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ var project = new Project
+ {
+ StorageId = 1,
+ Items =
+ {
+ new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = 1
+ }
+ }
+ };
+
+ var assessmentSectionEntity = new AssessmentSectionEntity
+ {
+ AssessmentSectionEntityId = 1
+ };
+ var projectEntity = new ProjectEntity
+ {
+ ProjectEntityId = 1,
+ AssessmentSectionEntities =
+ {
+ assessmentSectionEntity
+ }
+ };
+
+ ringtoetsEntities.ProjectEntities.Add(projectEntity);
+ ringtoetsEntities.AssessmentSectionEntities.Add(assessmentSectionEntity);
+ ringtoetsEntities.FailureMechanismEntities.Add(new FailureMechanismEntity());
+
+ // Call
+ project.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ CollectionAssert.AreEqual(new [] {assessmentSectionEntity}, projectEntity.AssessmentSectionEntities);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StochasticSoilModelUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StochasticSoilModelUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StochasticSoilModelUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,178 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.Data.TestUtil;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class StochasticSoilModelUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var soilModel = new TestStochasticSoilModel();
+
+ // Call
+ TestDelegate test = () => soilModel.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var soilModel = new TestStochasticSoilModel();
+
+ // Call
+ TestDelegate test = () => soilModel.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoStochasticSoilModel_EntityNotFoundException()
+ {
+ // Setup
+ var soilModel = new TestStochasticSoilModel();
+
+ // Call
+ TestDelegate test = () => soilModel.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_ContextWithStochasticSoilModel_PropertiesUpdated()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ string newName = "new name";
+ string newSegmentName = "new segment name";
+ var soilModel = new StochasticSoilModel(-1, newName, newSegmentName)
+ {
+ StorageId = 1,
+ };
+
+ var modelEntity = new StochasticSoilModelEntity
+ {
+ StochasticSoilModelEntityId = 1,
+ Name = string.Empty,
+ SegmentName = string.Empty
+ };
+
+ ringtoetsEntities.StochasticSoilModelEntities.Add(modelEntity);
+
+ // Call
+ soilModel.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(newName, modelEntity.Name);
+ Assert.AreEqual(newSegmentName, modelEntity.SegmentName);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_WithNewStochasticSoilProfile_StochasticSoilProfileAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var soilModel = new StochasticSoilModel(-1, string.Empty, string.Empty)
+ {
+ StorageId = 1,
+ StochasticSoilProfiles =
+ {
+ new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -1)
+ {
+ SoilProfile = new TestPipingSoilProfile()
+ }
+ }
+ };
+
+ var soilModelEntity = new StochasticSoilModelEntity
+ {
+ StochasticSoilModelEntityId = 1
+ };
+
+ ringtoetsEntities.StochasticSoilModelEntities.Add(soilModelEntity);
+
+ // Call
+ soilModel.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(1, soilModelEntity.StochasticSoilProfileEntities.Count);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_WithUpdatedStochasticSoilProfile_NoNewStochasticSoilProfileAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var soilModel = new StochasticSoilModel(-1, string.Empty, string.Empty)
+ {
+ StorageId = 1,
+ StochasticSoilProfiles =
+ {
+ new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = 1,
+ SoilProfile = new TestPipingSoilProfile()
+ }
+ }
+ };
+
+ var soilProfileEntity = new StochasticSoilProfileEntity
+ {
+ StochasticSoilProfileEntityId = 1
+ };
+ var soilModelEntity = new StochasticSoilModelEntity
+ {
+ StochasticSoilModelEntityId = 1,
+ StochasticSoilProfileEntities =
+ {
+ soilProfileEntity
+ }
+ };
+
+ ringtoetsEntities.StochasticSoilModelEntities.Add(soilModelEntity);
+ ringtoetsEntities.StochasticSoilProfileEntities.Add(soilProfileEntity);
+
+ // Call
+ soilModel.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ CollectionAssert.AreEqual(new [] {soilProfileEntity}, soilModelEntity.StochasticSoilProfileEntities);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StochasticSoilProfileUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StochasticSoilProfileUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/StochasticSoilProfileUpdateExtensionsTest.cs (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -0,0 +1,136 @@
+using System;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Piping.Data;
+using Ringtoets.Piping.KernelWrapper.TestUtil;
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class StochasticSoilProfileUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_WithoutContext_ArgumentNullException()
+ {
+ // Setup
+ var soilProfile = new TestStochasticSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Update(new UpdateConversionCollector(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_WithoutCollector_ArgumentNullException()
+ {
+ // Setup
+ var soilProfile = new TestStochasticSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Update(null, new RingtoetsEntities());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ public void Update_ContextWithNoStochasticSoilProfile_EntityNotFoundException()
+ {
+ // Setup
+ var soilProfile = new TestStochasticSoilProfile();
+
+ // Call
+ TestDelegate test = () => soilProfile.Update(new UpdateConversionCollector(), new RingtoetsEntities());
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Update_WithNewSoilProfile_PropertiesUpdatedSoilProfileAdded()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var newProbability = 0.5;
+ var soilProfile = new StochasticSoilProfile(newProbability, SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = 1,
+ SoilProfile = new TestPipingSoilProfile()
+ };
+
+ var soilProfileEntity = new StochasticSoilProfileEntity
+ {
+ StochasticSoilProfileEntityId = 1,
+ Probability = 0
+ };
+
+ ringtoetsEntities.StochasticSoilProfileEntities.Add(soilProfileEntity);
+
+ // Call
+ soilProfile.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(newProbability, soilProfileEntity.Probability);
+ Assert.NotNull(soilProfileEntity.SoilProfileEntity);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_WithUpdatedSoilProfile_InstanceReferenceNotChanged()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.Create(mocks);
+
+ mocks.ReplayAll();
+
+ var soilProfile = new StochasticSoilProfile(0.5, SoilProfileType.SoilProfile1D, -1)
+ {
+ StorageId = 1,
+ SoilProfile = new TestPipingSoilProfile
+ {
+ StorageId = 1
+ }
+ };
+
+ var soilProfileEntity = new SoilProfileEntity
+ {
+ SoilProfileEntityId = 1
+ };
+ var stochasticSoilProfileEntity = new StochasticSoilProfileEntity
+ {
+ StochasticSoilProfileEntityId = 1,
+ SoilProfileEntity = soilProfileEntity
+ };
+
+ ringtoetsEntities.StochasticSoilProfileEntities.Add(stochasticSoilProfileEntity);
+ ringtoetsEntities.SoilProfileEntities.Add(soilProfileEntity);
+
+ // Call
+ soilProfile.Update(new UpdateConversionCollector(), ringtoetsEntities);
+
+ // Assert
+ Assert.AreSame(soilProfileEntity, stochasticSoilProfileEntity.SoilProfileEntity);
+
+ mocks.VerifyAll();
+ }
+ }
+
+ public class TestStochasticSoilProfile : StochasticSoilProfile {
+ public TestStochasticSoilProfile() : base(0.5, SoilProfileType.SoilProfile1D, -1) {}
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs
===================================================================
diff -u -r4e14ed090d09a220a790b3562ceb4232dab1cce6 -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs (.../StochasticSoilModel.cs) (revision 4e14ed090d09a220a790b3562ceb4232dab1cce6)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilModel.cs (.../StochasticSoilModel.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -21,14 +21,15 @@
using System.Collections.Generic;
using Core.Common.Base.Geometry;
+using Core.Common.Base.Storage;
namespace Ringtoets.Piping.Data
{
///
/// This class represents a stochastic soil model which consists out of a collection of .
/// A stochastic soil model contains a segment for which the model applies.
///
- public class StochasticSoilModel
+ public class StochasticSoilModel : IStorable
{
///
/// Creates a new instance of .
Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs
===================================================================
diff -u -r6d514ec60f68620d78015ac58ba6a966ef6b14e3 -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision 6d514ec60f68620d78015ac58ba6a966ef6b14e3)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Data/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -19,14 +19,15 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using Core.Common.Base.Storage;
using Ringtoets.Piping.Primitives;
namespace Ringtoets.Piping.Data
{
///
/// This class couples a SoilProfile to a probability of occurrence.
///
- public class StochasticSoilProfile
+ public class StochasticSoilProfile : IStorable
{
///
/// Creates a new instance of .
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs
===================================================================
diff -u -r10779bb6a6db2d00f4627b2bc190e7e35e1fee3e -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision 10779bb6a6db2d00f4627b2bc190e7e35e1fee3e)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilLayer.cs (.../PipingSoilLayer.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -19,13 +19,15 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using Core.Common.Base.Storage;
+
namespace Ringtoets.Piping.Primitives
{
///
/// This class represents profiles that were imported from D-Soil Model and will later on be used to create the
/// necessary input for executing a piping calculation.
///
- public class PipingSoilLayer
+ public class PipingSoilLayer : IStorable
{
///
/// Creates a new instance of , where the top is set to .
@@ -62,5 +64,7 @@
/// Gets or sets the dry unit weight for the .
///
public double? DryUnitWeight { get; set; }
+
+ public long StorageId { get; set; }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs
===================================================================
diff -u -r6d514ec60f68620d78015ac58ba6a966ef6b14e3 -rb6432b2cbcb2db9bd326d9f006fb2d8b2528d263
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision 6d514ec60f68620d78015ac58ba6a966ef6b14e3)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/PipingSoilProfile.cs (.../PipingSoilProfile.cs) (revision b6432b2cbcb2db9bd326d9f006fb2d8b2528d263)
@@ -22,14 +22,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Core.Common.Base.Storage;
using Ringtoets.Piping.Primitives.Properties;
namespace Ringtoets.Piping.Primitives
{
///
/// This class represents a soil profile, which was imported for use in a piping calculation.
///
- public class PipingSoilProfile
+ public class PipingSoilProfile : IStorable
{
private IEnumerable layers;
@@ -212,5 +213,7 @@
}
return thickness;
}
+
+ public long StorageId { get; set; }
}
}
\ No newline at end of file