Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r54e6baff4fab535777949f737314f052853e818a -r845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 54e6baff4fab535777949f737314f052853e818a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6)
@@ -154,6 +154,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/RingtoetsPipingSurfaceLineUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/RingtoetsPipingSurfaceLineUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/RingtoetsPipingSurfaceLineUpdateExtensions.cs (revision 845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6)
@@ -0,0 +1,185 @@
+// 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 Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.Properties;
+
+using Core.Common.Base.Geometry;
+
+using Ringtoets.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Update
+{
+ ///
+ /// Extension methods for related to updating
+ /// an .
+ ///
+ internal static class RingtoetsPipingSurfaceLineUpdateExtensions
+ {
+ ///
+ /// Updates a in the database based on the information
+ /// of the .
+ ///
+ /// The piping surfaceline to update the database entity for.
+ /// The object keeping track of update operations.
+ /// The context to obtain the existing entity from.
+ /// Thrown when either:
+ ///
+ /// - is null
+ /// - is null
+ ///
+ /// When no
+ /// can be found in that matches .
+ internal static void Update(this RingtoetsPipingSurfaceLine surfaceLine, UpdateConversionCollector collector, IRingtoetsEntities context)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+
+ SurfaceLineEntity entity = GetCorrespondingSurfaceLineEntity(surfaceLine, context);
+
+ entity.Name = surfaceLine.Name;
+ entity.ReferenceLineIntersectionX = Convert.ToDecimal(surfaceLine.ReferenceLineIntersectionWorldPoint.X);
+ entity.ReferenceLineIntersectionY = Convert.ToDecimal(surfaceLine.ReferenceLineIntersectionWorldPoint.Y);
+
+ UpdateGeometry(surfaceLine, entity, context, collector);
+ UpdateCharacteristicPoints(surfaceLine, entity, collector);
+ }
+
+ private static void UpdateGeometry(RingtoetsPipingSurfaceLine surfaceLine, SurfaceLineEntity entity, IRingtoetsEntities context, UpdateConversionCollector collector)
+ {
+ if (HasGeometryChanges(surfaceLine, entity))
+ {
+ context.SurfaceLinePointEntities.RemoveRange(entity.SurfaceLinePointEntities);
+ UpdateGeometryPoints(surfaceLine, entity, collector);
+ }
+ }
+
+ private static bool HasGeometryChanges(RingtoetsPipingSurfaceLine surfaceLine, SurfaceLineEntity entity)
+ {
+ if (surfaceLine.Points.Length != entity.SurfaceLinePointEntities.Count)
+ {
+ return true;
+ }
+ var existingSurfaceLinePointEntities = entity.SurfaceLinePointEntities.OrderBy(pe => pe.Order).ToArray();
+ for (int i = 0; i < surfaceLine.Points.Length; i++)
+ {
+ // Note: Point3D is immutable, therefore checking for identity is enough.
+ if (surfaceLine.Points[i].StorageId != existingSurfaceLinePointEntities[i].SurfaceLinePointEntityId)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static void UpdateGeometryPoints(RingtoetsPipingSurfaceLine surfaceLine, SurfaceLineEntity entity, UpdateConversionCollector collector)
+ {
+ int order = 0;
+ foreach (Point3D geometryPoint in surfaceLine.Points)
+ {
+ entity.SurfaceLinePointEntities.Add(geometryPoint.CreateSurfaceLinePoint(collector, order++));
+ }
+ }
+
+ private static void UpdateCharacteristicPoints(RingtoetsPipingSurfaceLine surfaceLine, SurfaceLineEntity entity, UpdateConversionCollector collector)
+ {
+ UpdateCharacteristicPoint(surfaceLine.BottomDitchDikeSide,
+ entity.BottomDitchDikeSidePointEntity,
+ pointEntity => entity.BottomDitchDikeSidePointEntity = pointEntity,
+ collector);
+ UpdateCharacteristicPoint(surfaceLine.BottomDitchPolderSide,
+ entity.BottomDitchPolderSidePointEntity,
+ pointEntity => entity.BottomDitchPolderSidePointEntity = pointEntity,
+ collector);
+ UpdateCharacteristicPoint(surfaceLine.DikeToeAtPolder,
+ entity.DikeToeAtPolderPointEntity,
+ pointEntity => entity.DikeToeAtPolderPointEntity = pointEntity,
+ collector);
+ UpdateCharacteristicPoint(surfaceLine.DikeToeAtRiver,
+ entity.DikeToeAtRiverPointEntity,
+ pointEntity => entity.DikeToeAtRiverPointEntity = pointEntity,
+ collector);
+ UpdateCharacteristicPoint(surfaceLine.DitchDikeSide,
+ entity.DitchDikeSidePointEntity,
+ pointEntity => entity.DitchDikeSidePointEntity = pointEntity,
+ collector);
+ UpdateCharacteristicPoint(surfaceLine.DitchPolderSide,
+ entity.DitchPolderSidePointEntity,
+ pointEntity => entity.DitchPolderSidePointEntity = pointEntity,
+ collector);
+ }
+
+ private static void UpdateCharacteristicPoint(Point3D characteristicPoint, SurfaceLinePointEntity currentCharacteristicPointEntity,
+ Action replaceCharacteristicPointEntity,
+ UpdateConversionCollector collector)
+ {
+ if (characteristicPoint == null && currentCharacteristicPointEntity != null)
+ {
+ replaceCharacteristicPointEntity(null);
+ }
+ else if (characteristicPoint != null && IsEntityDifferentFromCurrentCharacteristicPoint(characteristicPoint, currentCharacteristicPointEntity))
+ {
+ replaceCharacteristicPointEntity(collector.GetSurfaceLinePoint(characteristicPoint));
+ }
+ }
+
+ private static bool IsEntityDifferentFromCurrentCharacteristicPoint(Point3D characteristicPoint, SurfaceLinePointEntity currentCharacteristicPointEntity)
+ {
+ return currentCharacteristicPointEntity == null ||
+ characteristicPoint.StorageId != currentCharacteristicPointEntity.SurfaceLinePointEntityId;
+ }
+
+ ///
+ /// Gets the from a
+ /// corresponding to an already saved instance.
+ ///
+ /// The surface line.
+ /// The context.
+ /// The .
+ /// When no
+ /// can be found in that matches .
+ private static SurfaceLineEntity GetCorrespondingSurfaceLineEntity(RingtoetsPipingSurfaceLine surfaceLine, IRingtoetsEntities context)
+ {
+ try
+ {
+ return context.SurfaceLineEntities.Single(sle => sle.SurfaceLineEntityId == surfaceLine.StorageId);
+ }
+ catch (InvalidOperationException exception)
+ {
+ string message = string.Format(Resources.Error_Entity_Not_Found_0_1,
+ typeof(SurfaceLineEntity).Name,
+ surfaceLine.StorageId);
+ throw new EntityNotFoundException(message, exception);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r54e6baff4fab535777949f737314f052853e818a -r845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 54e6baff4fab535777949f737314f052853e818a)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6)
@@ -126,6 +126,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/RingtoetsPipingSurfaceLineUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/RingtoetsPipingSurfaceLineUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/RingtoetsPipingSurfaceLineUpdateExtensionsTest.cs (revision 845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6)
@@ -0,0 +1,361 @@
+// 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 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.Piping.Primitives;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class RingtoetsPipingSurfaceLineUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_UpdateConversionCollectorIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ IRingtoetsEntities context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ RingtoetsPipingSurfaceLine surfaceLine = CreateSavedSurfaceLineWithData();
+
+ // Call
+ TestDelegate call = () => surfaceLine.Update(null, context);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("collector", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_RingtoetsEntitiesIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var collector = new UpdateConversionCollector();
+
+ RingtoetsPipingSurfaceLine surfaceLine = CreateSavedSurfaceLineWithData();
+
+ // Call
+ TestDelegate call = () => surfaceLine.Update(collector, null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_SurfaceLineNotSaved_ThrowEntityNotFoundException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ var collector = new UpdateConversionCollector();
+
+ var surfaceLine = new RingtoetsPipingSurfaceLine();
+
+ // Precondition
+ const long unsavedObjectId = 0;
+ Assert.AreEqual(unsavedObjectId, surfaceLine.StorageId);
+
+ // Call
+ TestDelegate call = () => surfaceLine.Update(collector, context);
+
+ // Assert
+ var expectedMessage = String.Format("Het object 'SurfaceLineEntity' met id '{0}' is niet gevonden.", unsavedObjectId);
+ EntityNotFoundException exception = Assert.Throws(call);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_SurfaceLineWithoutGeometry_SurfaceLineEntityUpdated()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ RingtoetsPipingSurfaceLine surfaceLine = CreateSavedSurfaceLineWithoutGeometry();
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = surfaceLine.StorageId,
+ Name = "",
+ ReferenceLineIntersectionX = 9876.5432m,
+ ReferenceLineIntersectionY = 9182.8374m
+ };
+ context.SurfaceLineEntities.Add(entity);
+
+ var collector = new UpdateConversionCollector();
+
+ // Call
+ surfaceLine.Update(collector, context);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Name, entity.Name);
+ Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.X, entity.ReferenceLineIntersectionX);
+ Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.Y, entity.ReferenceLineIntersectionY);
+
+ CollectionAssert.IsEmpty(entity.SurfaceLinePointEntities);
+ CollectionAssert.IsEmpty(context.SurfaceLinePointEntities);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_SurfaceLineWithNewGeometry_SurfaceLineEntityUpdatedAndGeometrySaved()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ RingtoetsPipingSurfaceLine surfaceLine = CreateSavedSurfaceLineWithGeometry();
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = surfaceLine.StorageId,
+ Name = "",
+ ReferenceLineIntersectionX = 91.28m,
+ ReferenceLineIntersectionY = 37.46m
+ };
+ context.SurfaceLineEntities.Add(entity);
+
+ // Precondition
+ CollectionAssert.IsEmpty(context.SurfaceLinePointEntities);
+
+ var collector = new UpdateConversionCollector();
+
+ // Call
+ surfaceLine.Update(collector, context);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Name, entity.Name);
+ Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.X, entity.ReferenceLineIntersectionX);
+ Assert.AreEqual(surfaceLine.ReferenceLineIntersectionWorldPoint.Y, entity.ReferenceLineIntersectionY);
+
+ Assert.AreEqual(surfaceLine.Points.Length, entity.SurfaceLinePointEntities.Count);
+ for (int i = 0; i < surfaceLine.Points.Length; i++)
+ {
+ Point3D geometryPoint = surfaceLine.Points[i];
+ SurfaceLinePointEntity pointEntity = entity.SurfaceLinePointEntities.ElementAt(i);
+
+ Assert.AreEqual(geometryPoint.X, pointEntity.X);
+ Assert.AreEqual(geometryPoint.Y, pointEntity.Y);
+ Assert.AreEqual(geometryPoint.Z, pointEntity.Z);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_SurfaceLineIdenticalGeometry_SurfaceLineEntityUpdatedAndGeometrySaved()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ RingtoetsPipingSurfaceLine surfaceLine = CreateSavedSurfaceLineWithGeometry();
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = surfaceLine.StorageId
+ };
+ context.SurfaceLineEntities.Add(entity);
+ var createCollector = new CreateConversionCollector();
+ for (int i = 0; i < surfaceLine.Points.Length; i++)
+ {
+ var geometryPoint = surfaceLine.Points[i];
+ SurfaceLinePointEntity pointEntity = geometryPoint.CreateSurfaceLinePoint(createCollector, i);
+
+ geometryPoint.StorageId = i + 1;
+ pointEntity.SurfaceLinePointEntityId = geometryPoint.StorageId;
+
+ entity.SurfaceLinePointEntities.Add(pointEntity);
+ context.SurfaceLinePointEntities.Add(pointEntity);
+ }
+
+ var updateCollector = new UpdateConversionCollector();
+
+ // Call
+ surfaceLine.Update(updateCollector, context);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Points.Length, entity.SurfaceLinePointEntities.Count);
+ for (int i = 0; i < surfaceLine.Points.Length; i++)
+ {
+ Point3D geometryPoint = surfaceLine.Points[i];
+ SurfaceLinePointEntity pointEntity = entity.SurfaceLinePointEntities.ElementAt(i);
+
+ Assert.AreEqual(geometryPoint.X, pointEntity.X);
+ Assert.AreEqual(geometryPoint.Y, pointEntity.Y);
+ Assert.AreEqual(geometryPoint.Z, pointEntity.Z);
+ Assert.AreEqual(geometryPoint.StorageId, pointEntity.SurfaceLinePointEntityId);
+ }
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_SurfaceLineWithNewGeometryAndCharacteristicPoints_SurfaceLineEntityUpdatedAndGeometryPlusCharacteristicPointsSaved()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ RingtoetsPipingSurfaceLine surfaceLine = CreateSavedSurfaceLineWithData();
+
+ var entity = new SurfaceLineEntity
+ {
+ SurfaceLineEntityId = surfaceLine.StorageId
+ };
+ context.SurfaceLineEntities.Add(entity);
+
+ var collector = new UpdateConversionCollector();
+
+ // Call
+ surfaceLine.Update(collector, context);
+
+ // Assert
+ Assert.AreEqual(surfaceLine.Points.Length, entity.SurfaceLinePointEntities.Count);
+ for (int i = 0; i < surfaceLine.Points.Length; i++)
+ {
+ Point3D geometryPoint = surfaceLine.Points[i];
+ SurfaceLinePointEntity pointEntity = entity.SurfaceLinePointEntities.ElementAt(i);
+
+ Assert.AreEqual(geometryPoint.X, pointEntity.X);
+ Assert.AreEqual(geometryPoint.Y, pointEntity.Y);
+ Assert.AreEqual(geometryPoint.Z, pointEntity.Z);
+ }
+
+ Assert.AreEqual(surfaceLine.BottomDitchDikeSide.X, entity.BottomDitchDikeSidePointEntity.X);
+ Assert.AreEqual(surfaceLine.BottomDitchDikeSide.Y, entity.BottomDitchDikeSidePointEntity.Y);
+ Assert.AreEqual(surfaceLine.BottomDitchDikeSide.Z, entity.BottomDitchDikeSidePointEntity.Z);
+ Assert.AreEqual(GetGeometryPointIndexForCharacteristicPoint(surfaceLine, surfaceLine.BottomDitchDikeSide), entity.BottomDitchDikeSidePointEntity.Order);
+ Assert.AreEqual(surfaceLine.BottomDitchPolderSide.X, entity.BottomDitchPolderSidePointEntity.X);
+ Assert.AreEqual(surfaceLine.BottomDitchPolderSide.Y, entity.BottomDitchPolderSidePointEntity.Y);
+ Assert.AreEqual(surfaceLine.BottomDitchPolderSide.Z, entity.BottomDitchPolderSidePointEntity.Z);
+ Assert.AreEqual(GetGeometryPointIndexForCharacteristicPoint(surfaceLine, surfaceLine.BottomDitchPolderSide), entity.BottomDitchPolderSidePointEntity.Order);
+ Assert.AreEqual(surfaceLine.DikeToeAtPolder.X, entity.DikeToeAtPolderPointEntity.X);
+ Assert.AreEqual(surfaceLine.DikeToeAtPolder.Y, entity.DikeToeAtPolderPointEntity.Y);
+ Assert.AreEqual(surfaceLine.DikeToeAtPolder.Z, entity.DikeToeAtPolderPointEntity.Z);
+ Assert.AreEqual(GetGeometryPointIndexForCharacteristicPoint(surfaceLine, surfaceLine.DikeToeAtPolder), entity.DikeToeAtPolderPointEntity.Order);
+ Assert.AreEqual(surfaceLine.DikeToeAtRiver.X, entity.DikeToeAtRiverPointEntity.X);
+ Assert.AreEqual(surfaceLine.DikeToeAtRiver.Y, entity.DikeToeAtRiverPointEntity.Y);
+ Assert.AreEqual(surfaceLine.DikeToeAtRiver.Z, entity.DikeToeAtRiverPointEntity.Z);
+ Assert.AreEqual(GetGeometryPointIndexForCharacteristicPoint(surfaceLine, surfaceLine.DikeToeAtRiver), entity.DikeToeAtRiverPointEntity.Order);
+ Assert.AreEqual(surfaceLine.DitchDikeSide.X, entity.DitchDikeSidePointEntity.X);
+ Assert.AreEqual(surfaceLine.DitchDikeSide.Y, entity.DitchDikeSidePointEntity.Y);
+ Assert.AreEqual(surfaceLine.DitchDikeSide.Z, entity.DitchDikeSidePointEntity.Z);
+ Assert.AreEqual(GetGeometryPointIndexForCharacteristicPoint(surfaceLine, surfaceLine.DitchDikeSide), entity.DitchDikeSidePointEntity.Order);
+ Assert.AreEqual(surfaceLine.DitchPolderSide.X, entity.DitchPolderSidePointEntity.X);
+ Assert.AreEqual(surfaceLine.DitchPolderSide.Y, entity.DitchPolderSidePointEntity.Y);
+ Assert.AreEqual(surfaceLine.DitchPolderSide.Z, entity.DitchPolderSidePointEntity.Z);
+ Assert.AreEqual(GetGeometryPointIndexForCharacteristicPoint(surfaceLine, surfaceLine.DitchPolderSide), entity.DitchPolderSidePointEntity.Order);
+ mocks.VerifyAll();
+ }
+
+ private static int GetGeometryPointIndexForCharacteristicPoint(RingtoetsPipingSurfaceLine surfaceLine, Point3D characteristicPoint)
+ {
+ int index = -1;
+ for (int i = 0; i < surfaceLine.Points.Length; i++)
+ {
+ if (surfaceLine.Points[i].Equals(characteristicPoint))
+ {
+ return i;
+ }
+ }
+ return index;
+ }
+
+ private static RingtoetsPipingSurfaceLine CreateSavedSurfaceLineWithGeometry()
+ {
+ var geometryPoints = new[]
+ {
+ new Point3D(1.1, 2.2, 3.3),
+ new Point3D(4.4, 5.5, 6.6)
+ };
+ var surfaceLine = new RingtoetsPipingSurfaceLine
+ {
+ StorageId = 14843246,
+ Name = "",
+ ReferenceLineIntersectionWorldPoint = new Point2D(08.05, 20.16)
+ };
+ surfaceLine.SetGeometry(geometryPoints);
+ return surfaceLine;
+ }
+
+ private static RingtoetsPipingSurfaceLine CreateSavedSurfaceLineWithData()
+ {
+ var geometryPoints = 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
+ {
+ StorageId = 4256,
+ Name = "",
+ ReferenceLineIntersectionWorldPoint = new Point2D(07.11, 19.87)
+ };
+ surfaceLine.SetGeometry(geometryPoints);
+ surfaceLine.SetBottomDitchDikeSideAt(geometryPoints[0]);
+ surfaceLine.SetBottomDitchPolderSideAt(geometryPoints[2]);
+ surfaceLine.SetDikeToeAtPolderAt(geometryPoints[3]);
+ surfaceLine.SetDikeToeAtRiverAt(geometryPoints[4]);
+ surfaceLine.SetDitchDikeSideAt(geometryPoints[5]);
+ surfaceLine.SetDitchPolderSideAt(geometryPoints[7]);
+ return surfaceLine;
+ }
+
+ private RingtoetsPipingSurfaceLine CreateSavedSurfaceLineWithoutGeometry()
+ {
+ return new RingtoetsPipingSurfaceLine
+ {
+ StorageId = 93584793,
+ Name = "",
+ ReferenceLineIntersectionWorldPoint = new Point2D(1.2, 3.4)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs
===================================================================
diff -u -r64d5609bb2912cd52dc74deffdd189222e240599 -r845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision 64d5609bb2912cd52dc74deffdd189222e240599)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsEntitiesHelper.cs (.../RingtoetsEntitiesHelper.cs) (revision 845d2b0230eca6b2e9e94a2aec3fa36bd3c916b6)
@@ -20,6 +20,8 @@
// All rights reserved.
using System.Collections.ObjectModel;
+using System.Data.Entity;
+
using Application.Ringtoets.Storage.DbContext;
using Rhino.Mocks;
@@ -29,30 +31,40 @@
{
public static IRingtoetsEntities Create(MockRepository mockRepository)
{
+ DbSet projectsSet = CreateEmptyTestDbSet();
+ DbSet hydraylicLocationsSet = CreateEmptyTestDbSet();
+ DbSet failureMechanismsSet = CreateEmptyTestDbSet();
+ DbSet failureMechanismSectionsSet = CreateEmptyTestDbSet();
+ DbSet failureMechanismSectionPointsSet = CreateEmptyTestDbSet();
+ DbSet assessmentSectionsSet = CreateEmptyTestDbSet();
+ DbSet referenceLinesSet = CreateEmptyTestDbSet();
+ DbSet stochasticSoilModelsSet = CreateEmptyTestDbSet();
+ DbSet stochasticSoilProfilesSet = CreateEmptyTestDbSet();
+ DbSet soilProfilesSet = CreateEmptyTestDbSet();
+ DbSet soilLayersSet = CreateEmptyTestDbSet();
+ DbSet surfaceLinesSet = CreateEmptyTestDbSet();
+ DbSet surfaceLinePointsSet = CreateEmptyTestDbSet();
+
var ringtoetsEntities = mockRepository.Stub();
- var pSet = new TestDbSet(new ObservableCollection());
- var hlSet = new TestDbSet(new ObservableCollection());
- var fmSet = new TestDbSet(new ObservableCollection());
- var fmsSet = new TestDbSet(new ObservableCollection());
- var fmspSet = new TestDbSet(new ObservableCollection());
- var dasSet = new TestDbSet(new ObservableCollection());
- var rlpSet = new TestDbSet(new ObservableCollection());
- var ssmSet = new TestDbSet(new ObservableCollection());
- var sspSet = new TestDbSet(new ObservableCollection());
- var spSet = new TestDbSet(new ObservableCollection());
- var slSet = new TestDbSet(new ObservableCollection());
- ringtoetsEntities.Stub(r => r.ProjectEntities).Return(pSet);
- ringtoetsEntities.Stub(r => r.HydraulicLocationEntities).Return(hlSet);
- ringtoetsEntities.Stub(r => r.FailureMechanismEntities).Return(fmSet);
- ringtoetsEntities.Stub(r => r.FailureMechanismSectionEntities).Return(fmsSet);
- ringtoetsEntities.Stub(r => r.FailureMechanismSectionPointEntities).Return(fmspSet);
- ringtoetsEntities.Stub(r => r.AssessmentSectionEntities).Return(dasSet);
- ringtoetsEntities.Stub(r => r.ReferenceLinePointEntities).Return(rlpSet);
- ringtoetsEntities.Stub(r => r.StochasticSoilModelEntities).Return(ssmSet);
- ringtoetsEntities.Stub(r => r.StochasticSoilProfileEntities).Return(sspSet);
- ringtoetsEntities.Stub(r => r.SoilProfileEntities).Return(spSet);
- ringtoetsEntities.Stub(r => r.SoilLayerEntities).Return(slSet);
+ ringtoetsEntities.Stub(r => r.ProjectEntities).Return(projectsSet);
+ ringtoetsEntities.Stub(r => r.HydraulicLocationEntities).Return(hydraylicLocationsSet);
+ ringtoetsEntities.Stub(r => r.FailureMechanismEntities).Return(failureMechanismsSet);
+ ringtoetsEntities.Stub(r => r.FailureMechanismSectionEntities).Return(failureMechanismSectionsSet);
+ ringtoetsEntities.Stub(r => r.FailureMechanismSectionPointEntities).Return(failureMechanismSectionPointsSet);
+ ringtoetsEntities.Stub(r => r.AssessmentSectionEntities).Return(assessmentSectionsSet);
+ ringtoetsEntities.Stub(r => r.ReferenceLinePointEntities).Return(referenceLinesSet);
+ ringtoetsEntities.Stub(r => r.StochasticSoilModelEntities).Return(stochasticSoilModelsSet);
+ ringtoetsEntities.Stub(r => r.StochasticSoilProfileEntities).Return(stochasticSoilProfilesSet);
+ ringtoetsEntities.Stub(r => r.SoilProfileEntities).Return(soilProfilesSet);
+ ringtoetsEntities.Stub(r => r.SoilLayerEntities).Return(soilLayersSet);
+ ringtoetsEntities.Stub(r => r.SurfaceLineEntities).Return(surfaceLinesSet);
+ ringtoetsEntities.Stub(r => r.SurfaceLinePointEntities).Return(surfaceLinePointsSet);
return ringtoetsEntities;
}
+
+ private static DbSet CreateEmptyTestDbSet() where T : class
+ {
+ return new TestDbSet(new ObservableCollection());
+ }
}
}
\ No newline at end of file