Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r209bfd7b71ef53a57e1a52337f1333d38122282f -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 209bfd7b71ef53a57e1a52337f1333d38122282f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -55,6 +55,8 @@
+
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/CreateConversionCollector.cs
===================================================================
diff -u -r062281754a35164e1095479c9f1ccb8ee821f939 -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/CreateConversionCollector.cs (.../CreateConversionCollector.cs) (revision 062281754a35164e1095479c9f1ccb8ee821f939)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/CreateConversionCollector.cs (.../CreateConversionCollector.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -24,6 +24,7 @@
using System.Linq;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
using Core.Common.Utils;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.HydraRing.Data;
@@ -49,6 +50,7 @@
private readonly Dictionary stochasticSoilProfiles = new Dictionary(new ReferenceEqualityComparer());
private readonly Dictionary soilProfiles = new Dictionary(new ReferenceEqualityComparer());
private readonly Dictionary soilLayers = new Dictionary(new ReferenceEqualityComparer());
+ private readonly Dictionary surfaceLinePoints = new Dictionary(new ReferenceEqualityComparer());
///
/// Registers a create operation for and the that
@@ -221,6 +223,40 @@
}
///
+ /// Registers a create operation for and the
+ /// that was constructed with the information.
+ ///
+ /// The that was constructed.
+ /// The surfaceline geometry corresponding
+ /// the newly create database entity.
+ /// Thrown when either:
+ ///
+ /// - is null
+ /// - is null
+ ///
+ internal void Create(SurfaceLinePointEntity entity, Point3D model)
+ {
+ Create(surfaceLinePoints, entity, model);
+ }
+
+ ///
+ /// Obtains the which was created for the
+ /// given .
+ ///
+ /// The surfaceline geometry for which
+ /// a create operation has been registered.
+ /// The constructed .
+ /// Thrown when is null.
+ /// Thrown when no create operation
+ /// has been registered for .
+ /// Use to find out whether a create operation has
+ /// been registered for .
+ internal SurfaceLinePointEntity GetSurfaceLinePoint(Point3D model)
+ {
+ return Get(surfaceLinePoints, model);
+ }
+
+ ///
/// Transfer ids from the created entities to the domain model objects' property.
///
internal void TransferIds()
@@ -269,6 +305,11 @@
{
soilLayers[entity].StorageId = entity.SoilLayerEntityId;
}
+
+ foreach (var entity in surfaceLinePoints.Keys)
+ {
+ surfaceLinePoints[entity].StorageId = entity.SurfaceLinePointEntityId;
+ }
}
private bool ContainsValue(Dictionary collection, U model)
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLineCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLineCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLineCreateExtensions.cs (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -0,0 +1,93 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+
+using Ringtoets.Piping.Primitives;
+using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
+
+namespace Application.Ringtoets.Storage.Create
+{
+ ///
+ /// Extensions methods for related to creating
+ /// an .
+ ///
+ public static class RingtoetsPipingSurfaceLineCreateExtensions
+ {
+ ///
+ /// Creates a based on the information of the .
+ ///
+ /// The surface line to create a database entity for.
+ /// The object keeping track of create operations.
+ /// a new .
+ /// Thrown when is null.
+ internal static SurfaceLineEntity Create(this RingtoetsPipingSurfaceLine surfaceLine, CreateConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new SurfaceLineEntity
+ {
+ Name = surfaceLine.Name
+ };
+ int order = 0;
+ foreach (Point3D point3D in surfaceLine.Points)
+ {
+ entity.SurfaceLinePointEntities.Add(point3D.CreateSurfaceLinePoint(collector, order++));
+ }
+ if (surfaceLine.BottomDitchPolderSide != null)
+ {
+ SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.BottomDitchPolderSide);
+ entity.BottomDitchPolderSidePointEntity = characteristicPointEntity;
+ }
+ if (surfaceLine.BottomDitchDikeSide != null)
+ {
+ SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.BottomDitchDikeSide);
+ entity.BottomDitchDikeSidePointEntity = characteristicPointEntity;
+ }
+ if (surfaceLine.DikeToeAtPolder != null)
+ {
+ SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.DikeToeAtPolder);
+ entity.DikeToeAtPolderPointEntity = characteristicPointEntity;
+ }
+ if (surfaceLine.DikeToeAtRiver != null)
+ {
+ SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.DikeToeAtRiver);
+ entity.DikeToeAtRiverPointEntity = characteristicPointEntity;
+ }
+ if (surfaceLine.DitchDikeSide != null)
+ {
+ SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.DitchDikeSide);
+ entity.DitchDikeSidePointEntity = characteristicPointEntity;
+ }
+ if (surfaceLine.DitchPolderSide != null)
+ {
+ SurfaceLinePointEntity characteristicPointEntity = collector.GetSurfaceLinePoint(surfaceLine.DitchPolderSide);
+ entity.DitchPolderSidePointEntity = characteristicPointEntity;
+ }
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLinePointCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLinePointCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/RingtoetsPipingSurfaceLinePointCreateExtensions.cs (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -0,0 +1,68 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+
+using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
+
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Create
+{
+ ///
+ /// Extensions methods for related to
+ /// creating an .
+ ///
+ public static class RingtoetsPipingSurfaceLinePointCreateExtensions
+ {
+ ///
+ /// Creates the surface line point.
+ ///
+ /// The geometry point to create a database entity for.
+ /// The object keeping track of create operations.
+ /// The index in .
+ /// A new .
+ /// Thrown when is null.
+ internal static SurfaceLinePointEntity CreateSurfaceLinePoint(this Point3D geometryPoint,
+ CreateConversionCollector collector,
+ int order)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+
+ var entity = new SurfaceLinePointEntity
+ {
+ X = Convert.ToDecimal(geometryPoint.X),
+ Y = Convert.ToDecimal(geometryPoint.Y),
+ Z = Convert.ToDecimal(geometryPoint.Z),
+ Order = order
+ };
+
+ collector.Create(entity, geometryPoint);
+
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r209bfd7b71ef53a57e1a52337f1333d38122282f -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 209bfd7b71ef53a57e1a52337f1333d38122282f)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -84,6 +84,8 @@
+
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/CreateConversionCollectorTest.cs
===================================================================
diff -u -r209bfd7b71ef53a57e1a52337f1333d38122282f -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/CreateConversionCollectorTest.cs (.../CreateConversionCollectorTest.cs) (revision 209bfd7b71ef53a57e1a52337f1333d38122282f)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/CreateConversionCollectorTest.cs (.../CreateConversionCollectorTest.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -158,6 +158,24 @@
Assert.Throws(test);
}
+ [Test]
+ public void GetSurfaceLinePoint_SurfaceLinePointAdded_ReturnsEntity()
+ {
+ // Setup
+ var surfaceLineGeometryPoint = new Point3D(1.1, 2.2, 3.3);
+ var initializedEntity = new SurfaceLinePointEntity();
+
+ var collector = new CreateConversionCollector();
+ collector.Create(initializedEntity, surfaceLineGeometryPoint);
+
+ // Call
+ SurfaceLinePointEntity retrievedEntity = collector.GetSurfaceLinePoint(surfaceLineGeometryPoint);
+
+ // Assert
+ Assert.AreSame(initializedEntity, retrievedEntity);
+
+ }
+
#region Create methods
[Test]
@@ -400,6 +418,34 @@
Assert.AreEqual("model", paramName);
}
+ [Test]
+ public void Create_WithNullSurfaceLinePointEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+
+ // Call
+ TestDelegate call = () => collector.Create(null, new Point3D(1.1, 2.2, 3.3));
+
+ // Assert
+ var paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
+ public void Create_WithNullSurfaceLinePoint_ThrowsArgumentNullException()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+
+ // Call
+ TestDelegate call = () => collector.Create(new SurfaceLinePointEntity(), null);
+
+ // Assert
+ var paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("model", paramName);
+ }
+
#endregion
#region TransferId method
@@ -614,6 +660,27 @@
Assert.AreEqual(storageId, model.StorageId);
}
+ [Test]
+ public void TransferId_WithSurfaceLinePointEntityAdded_EqualSurfaceLinePointEntityIdAndPoint3DStorageId()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+
+ long storageId = new Random(21).Next(1, 4000);
+ var entity = new SurfaceLinePointEntity
+ {
+ SurfaceLinePointEntityId = storageId
+ };
+ var model = new Point3D(1.1, 2.2, 3.3);
+ collector.Create(entity, model);
+
+ // Call
+ collector.TransferIds();
+
+ // Assert
+ Assert.AreEqual(storageId, model.StorageId);
+ }
+
#endregion
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/RingtoetsPipingSurfaceLineCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/RingtoetsPipingSurfaceLineCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/RingtoetsPipingSurfaceLineCreateExtensionsTest.cs (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -0,0 +1,191 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Linq;
+
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
+
+using NUnit.Framework;
+
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLineCreateExtensionsTest
+ {
+ [Test]
+ public void Create_CreateConversionCollectorIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+
+ // Call
+ TestDelegate call = () => surfaceLine.Create(null);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void Create_SurfaceLineWithoutGeometry_ReturnSurfaceLineEntityWithoutAddingPointEntities()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Test"
+ };
+
+ // Call
+ SurfaceLineEntity entity = surfaceLine.Create(collector);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Name, entity.Name);
+
+ Assert.AreEqual(0, entity.SurfaceLineEntityId);
+ Assert.AreEqual(0, entity.FailureMechanismEntityId);
+ Assert.IsNull(entity.FailureMechanismEntity);
+ CollectionAssert.IsEmpty(entity.SurfaceLinePointEntities);
+ }
+
+ [Test]
+ public void Create_SurfaceLineWithGeometryWithoutCharacteristicPoints_ReturnSurfaceLineEntityWithPointEntities()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+ var geometry = new[]
+ {
+ new Point3D(1.1, 2.2, 3.3),
+ new Point3D(4.4, 5.5, 6.6),
+ new Point3D(7.7, 8.8, 9.9)
+ };
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Test"
+ };
+ surfaceLine.SetGeometry(geometry);
+
+ // Call
+ SurfaceLineEntity entity = surfaceLine.Create(collector);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Name, entity.Name);
+
+ Assert.AreEqual(geometry.Length, entity.SurfaceLinePointEntities.Count);
+ SurfaceLinePointEntity[] pointEntities = entity.SurfaceLinePointEntities.ToArray();
+ for (int i = 0; i < geometry.Length; i++)
+ {
+ SurfaceLinePointEntity pointEntity = pointEntities[i];
+ Assert.AreEqual(i, pointEntity.Order);
+
+ Point3D expectedMatchingGeometryPoint = geometry[i];
+ Assert.AreEqual(expectedMatchingGeometryPoint.X, pointEntity.X);
+ Assert.AreEqual(expectedMatchingGeometryPoint.Y, pointEntity.Y);
+ Assert.AreEqual(expectedMatchingGeometryPoint.Z, pointEntity.Z);
+ }
+
+ Assert.AreEqual(0, entity.SurfaceLineEntityId);
+ Assert.AreEqual(0, entity.FailureMechanismEntityId);
+ Assert.IsNull(entity.FailureMechanismEntity);
+ }
+
+ [Test]
+ public void Create_SurfaceLineWithAllData_ReturnSurfaceLineEntityWithPointEntitiesAndCharactersisticPointReferences()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+ var geometry = new[]
+ {
+ new Point3D(1.1, 2.2, 3.3),
+ new Point3D(4.4, 5.5, 6.6),
+ new Point3D(7.7, 8.8, 9.9),
+ new Point3D(10.10, 11.11, 12.12),
+ new Point3D(13.13, 14.14, 15.15),
+ new Point3D(16.16, 17.17, 18.18),
+ new Point3D(19.19, 20.20, 21.21),
+ new Point3D(22.22, 23.23, 24.24),
+ };
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ Name = "Test"
+ };
+ surfaceLine.SetGeometry(geometry);
+ surfaceLine.SetBottomDitchDikeSideAt(geometry[1]);
+ surfaceLine.SetBottomDitchPolderSideAt(geometry[2]);
+ surfaceLine.SetDikeToeAtPolderAt(geometry[3]);
+ surfaceLine.SetDikeToeAtRiverAt(geometry[4]);
+ surfaceLine.SetDitchDikeSideAt(geometry[5]);
+ surfaceLine.SetDitchPolderSideAt(geometry[6]);
+
+ // Call
+ SurfaceLineEntity entity = surfaceLine.Create(collector);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Name, entity.Name);
+
+ Assert.AreEqual(geometry.Length, entity.SurfaceLinePointEntities.Count);
+ SurfaceLinePointEntity[] pointEntities = entity.SurfaceLinePointEntities.ToArray();
+ for (int i = 0; i < geometry.Length; i++)
+ {
+ SurfaceLinePointEntity pointEntity = pointEntities[i];
+ Assert.AreEqual(i, pointEntity.Order);
+
+ Point3D expectedMatchingGeometryPoint = geometry[i];
+ Assert.AreEqual(expectedMatchingGeometryPoint.X, pointEntity.X);
+ Assert.AreEqual(expectedMatchingGeometryPoint.Y, pointEntity.Y);
+ Assert.AreEqual(expectedMatchingGeometryPoint.Z, pointEntity.Z);
+ }
+
+ Assert.AreEqual(geometry[1].X, entity.BottomDitchDikeSidePointEntity.X);
+ Assert.AreEqual(geometry[1].Y, entity.BottomDitchDikeSidePointEntity.Y);
+ Assert.AreEqual(geometry[1].Z, entity.BottomDitchDikeSidePointEntity.Z);
+
+ Assert.AreEqual(geometry[2].X, entity.BottomDitchPolderSidePointEntity.X);
+ Assert.AreEqual(geometry[2].Y, entity.BottomDitchPolderSidePointEntity.Y);
+ Assert.AreEqual(geometry[2].Z, entity.BottomDitchPolderSidePointEntity.Z);
+
+ Assert.AreEqual(geometry[3].X, entity.DikeToeAtPolderPointEntity.X);
+ Assert.AreEqual(geometry[3].Y, entity.DikeToeAtPolderPointEntity.Y);
+ Assert.AreEqual(geometry[3].Z, entity.DikeToeAtPolderPointEntity.Z);
+
+ Assert.AreEqual(geometry[4].X, entity.DikeToeAtRiverPointEntity.X);
+ Assert.AreEqual(geometry[4].Y, entity.DikeToeAtRiverPointEntity.Y);
+ Assert.AreEqual(geometry[4].Z, entity.DikeToeAtRiverPointEntity.Z);
+
+ Assert.AreEqual(geometry[5].X, entity.DitchDikeSidePointEntity.X);
+ Assert.AreEqual(geometry[5].Y, entity.DitchDikeSidePointEntity.Y);
+ Assert.AreEqual(geometry[5].Z, entity.DitchDikeSidePointEntity.Z);
+
+ Assert.AreEqual(geometry[6].X, entity.DitchPolderSidePointEntity.X);
+ Assert.AreEqual(geometry[6].Y, entity.DitchPolderSidePointEntity.Y);
+ Assert.AreEqual(geometry[6].Z, entity.DitchPolderSidePointEntity.Z);
+
+ Assert.AreEqual(0, entity.SurfaceLineEntityId);
+ Assert.AreEqual(0, entity.FailureMechanismEntityId);
+ Assert.IsNull(entity.FailureMechanismEntity);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/RingtoetsPipingSurfaceLinePointCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/RingtoetsPipingSurfaceLinePointCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/RingtoetsPipingSurfaceLinePointCreateExtensionsTest.cs (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -0,0 +1,94 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+
+using Core.Common.Base.Geometry;
+
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLinePointCreateExtensionsTest
+ {
+ [Test]
+ public void CreateSurfaceLinePoint_NoCollector_ThrowArgumentNullException()
+ {
+ // Setup
+ var geometryPoint = new Point3D(1.1, 2.2, 3.3);
+
+ // Call
+ TestDelegate call = () => geometryPoint.CreateSurfaceLinePoint(null, 0);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void CreateSurfaceLinePoint_ValidArguments_CreateSurfaceLinePointEntity()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+ var geometryPoint = new Point3D(2.3, 4.5, 6.7);
+
+ // Call
+ const int expectedOrder = 3;
+ SurfaceLinePointEntity entity = geometryPoint.CreateSurfaceLinePoint(collector, expectedOrder);
+
+ // Assert
+ Assert.AreEqual(geometryPoint.X, entity.X);
+ Assert.AreEqual(geometryPoint.Y, entity.Y);
+ Assert.AreEqual(geometryPoint.Z, entity.Z);
+ Assert.AreEqual(expectedOrder, entity.Order);
+
+ Assert.AreEqual(0, entity.SurfaceLinePointEntityId);
+
+ CollectionAssert.IsEmpty(entity.BottomDitchDikeSidePointParentEntity);
+ CollectionAssert.IsEmpty(entity.BottomDitchPolderSidePointParentEntity);
+ CollectionAssert.IsEmpty(entity.DikeToeAtPolderPointParentEntity);
+ CollectionAssert.IsEmpty(entity.DikeToeAtRiverPointParentEntity);
+ CollectionAssert.IsEmpty(entity.DitchDikeSidePointParentEntity);
+ CollectionAssert.IsEmpty(entity.DitchPolderSidePointParentEntity);
+ Assert.IsNull(entity.SurfaceLineEntity);
+ Assert.AreEqual(0, entity.SurfaceLineEntityId);
+ }
+
+ [Test]
+ public void CreateSurfaceLinePoint_ValidArguments_NewEntityIsRegisteredToCreateConversionCollector()
+ {
+ // Setup
+ var collector = new CreateConversionCollector();
+ var geometryPoint = new Point3D(2.3, 4.5, 6.7);
+
+ // Call
+ const int expectedOrder = 3;
+ SurfaceLinePointEntity entity = geometryPoint.CreateSurfaceLinePoint(collector, expectedOrder);
+
+ // Assert
+ SurfaceLinePointEntity retrievedEntity = collector.GetSurfaceLinePoint(geometryPoint);
+ Assert.AreSame(entity, retrievedEntity);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Base/Geometry/Point3D.cs
===================================================================
diff -u -re04155c0cc0efa8bbd13e0a82cb8643711a2dfd6 -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Core/Common/src/Core.Common.Base/Geometry/Point3D.cs (.../Point3D.cs) (revision e04155c0cc0efa8bbd13e0a82cb8643711a2dfd6)
+++ Core/Common/src/Core.Common.Base/Geometry/Point3D.cs (.../Point3D.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -21,12 +21,14 @@
using System;
+using Core.Common.Base.Storage;
+
namespace Core.Common.Base.Geometry
{
///
/// Defines a mathematical, immutable point in 3D Euclidean space.
///
- public sealed class Point3D
+ public sealed class Point3D : IStorable
{
///
/// Creates a new instance of .
@@ -56,6 +58,8 @@
///
public double Z { get; private set; }
+ public long StorageId { get; set; }
+
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
Index: Core/Common/test/Core.Common.Base.Test/Geometry/Point3DTest.cs
===================================================================
diff -u -r5b63cfab474523f97be999403eb4906a0c376a3d -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Core/Common/test/Core.Common.Base.Test/Geometry/Point3DTest.cs (.../Point3DTest.cs) (revision 5b63cfab474523f97be999403eb4906a0c376a3d)
+++ Core/Common/test/Core.Common.Base.Test/Geometry/Point3DTest.cs (.../Point3DTest.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -1,6 +1,7 @@
using System;
using Core.Common.Base.Geometry;
+using Core.Common.Base.Storage;
using NUnit.Framework;
@@ -21,6 +22,8 @@
var point = new Point3D(x, y, z);
// Assert
+ Assert.IsInstanceOf(point);
+
Assert.AreEqual(1.1, point.X);
Assert.AreEqual(2.2, point.Y);
Assert.AreEqual(-1.1, point.Z);
Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs
===================================================================
diff -u -r3462d84f3304a35ba5ce26c7d3afc9c31cdf9205 -r8a2d2653ceff765beecfcedab41a6be91df7d16e
--- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 3462d84f3304a35ba5ce26c7d3afc9c31cdf9205)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 8a2d2653ceff765beecfcedab41a6be91df7d16e)
@@ -103,6 +103,9 @@
///
public Point3D DikeToeAtPolder { get; private set; }
+ ///
+ /// Gets or sets the reference line intersection point in world coordinates.
+ ///
public Point2D ReferenceLineIntersectionWorldPoint { get; set; }
///