Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/StochasticSoilModelConverter.cs
===================================================================
diff -u -r8843d5b6f7e369308169a90ab4cfc97220a7847a -rf132d31ed525b40c7707b7f3f4c999ad04c39b86
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/StochasticSoilModelConverter.cs (.../StochasticSoilModelConverter.cs) (revision 8843d5b6f7e369308169a90ab4cfc97220a7847a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/StochasticSoilModelConverter.cs (.../StochasticSoilModelConverter.cs) (revision f132d31ed525b40c7707b7f3f4c999ad04c39b86)
@@ -28,7 +28,8 @@
///
/// Converts into a and vice versa.
///
- public class StochasticSoilModelConverter : IEntityConverter {
+ public class StochasticSoilModelConverter : IEntityConverter
+ {
public StochasticSoilModel ConvertEntityToModel(StochasticSoilModelEntity entity)
{
if (entity == null)
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/StochasticSoilProfileConverter.cs
===================================================================
diff -u -r8843d5b6f7e369308169a90ab4cfc97220a7847a -rf132d31ed525b40c7707b7f3f4c999ad04c39b86
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/StochasticSoilProfileConverter.cs (.../StochasticSoilProfileConverter.cs) (revision 8843d5b6f7e369308169a90ab4cfc97220a7847a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/StochasticSoilProfileConverter.cs (.../StochasticSoilProfileConverter.cs) (revision f132d31ed525b40c7707b7f3f4c999ad04c39b86)
@@ -24,7 +24,7 @@
IsAquifer = sl.IsAquifer == 1
});
- return new StochasticSoilProfile((double)entity.Probability, SoilProfileType.SoilProfile1D, -1)
+ return new StochasticSoilProfile((double) entity.Probability, SoilProfileType.SoilProfile1D, -1)
{
SoilProfile = new PipingSoilProfile(entity.SoilProfileEntity.Name, (double) entity.SoilProfileEntity.Bottom, layers, SoilProfileType.SoilProfile1D, -1),
StorageId = entity.StochasticSoilProfileEntityId
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicBoundaryLocationPersistorTest.cs
===================================================================
diff -u -r4e14ed090d09a220a790b3562ceb4232dab1cce6 -rf132d31ed525b40c7707b7f3f4c999ad04c39b86
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicBoundaryLocationPersistorTest.cs (.../HydraulicBoundaryLocationPersistorTest.cs) (revision 4e14ed090d09a220a790b3562ceb4232dab1cce6)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicBoundaryLocationPersistorTest.cs (.../HydraulicBoundaryLocationPersistorTest.cs) (revision f132d31ed525b40c7707b7f3f4c999ad04c39b86)
@@ -374,6 +374,28 @@
}
[Test]
+ public void UpdateModel_LocationNull_ThrowsArgumentException()
+ {
+ // Setup
+ var ringtoetsEntitiesMock = RingtoetsEntitiesHelper.Create(mockRepository);
+ mockRepository.ReplayAll();
+
+ var persistor = new HydraulicBoundaryLocationPersistor(ringtoetsEntitiesMock);
+ IList parentNavigationProperty = new List();
+
+ HydraulicBoundaryDatabase hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+ hydraulicBoundaryDatabase.Locations.Add(null);
+
+ // Call
+ TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, hydraulicBoundaryDatabase);
+
+ // Assert
+ Assert.Throws(test);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void UpdateModel_SingleEntityInParentNavigationPropertySingleHydraulicLocationWithStorageId_UpdatedHydraulicLocationAsEntityInParentNavigationProperty()
{
// Setup
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ReferenceLinePersistorTest.cs
===================================================================
diff -u -ra9aafffab97152303562110b1d789bacb465ce24 -rf132d31ed525b40c7707b7f3f4c999ad04c39b86
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ReferenceLinePersistorTest.cs (.../ReferenceLinePersistorTest.cs) (revision a9aafffab97152303562110b1d789bacb465ce24)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/ReferenceLinePersistorTest.cs (.../ReferenceLinePersistorTest.cs) (revision f132d31ed525b40c7707b7f3f4c999ad04c39b86)
@@ -28,7 +28,6 @@
using Core.Common.Base.Geometry;
using NUnit.Framework;
using Rhino.Mocks;
-using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
namespace Application.Ringtoets.Storage.Test.Persistors
@@ -127,7 +126,7 @@
}
[Test]
- public void InsertModel_WithNonEmptyEntityCollectionWithReferenceLine_EntityCollectionClearedAddsNewEntitiesToContext()
+ public void InsertModel_WithNonEmptyEntityCollectionWithReferenceLineWithOneDifferentPoint_EntityCollectionClearedAddsNewEntitiesToContext()
{
// Setup
var mocks = new MockRepository();
@@ -166,15 +165,91 @@
}
[Test]
- public void InsertModel_EmptyCollectionNullReferenceLine_ShouldNotClearCollection()
+ public void InsertModel_WithNonEmptyEntityCollectionWithReferenceLineWithOneMorePoint_EntityCollectionClearedAddsNewEntitiesToContext()
{
// Setup
- var backingList = new List();
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+ var entities = new List();
+ for (int i = 0; i < 3; i++)
+ {
+ entities.Add(new ReferenceLinePointEntity
+ {
+ Order = i
+ });
+ }
+
+ context.ReferenceLinePointEntities.Add(entities[0]);
+ context.ReferenceLinePointEntities.Add(entities[1]);
+ context.ReferenceLinePointEntities.Add(new ReferenceLinePointEntity());
+
+ var persistor = new ReferenceLinePersistor(context);
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1, 1),
+ new Point2D(3, 2),
+ new Point2D(1, 3),
+ new Point2D(6, 3)
+ });
+
+ // Call
+ persistor.InsertModel(entities, referenceLine);
+
+ // Assert
+ AssertCreatedEntities(entities, referenceLine);
+ Assert.AreEqual(1, context.ReferenceLinePointEntities.Count());
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void InsertModel_WithNonEmptyEntityCollectionWithReferenceLineWithOneLessPoint_EntityCollectionClearedAddsNewEntitiesToContext()
+ {
+ // Setup
var mocks = new MockRepository();
var context = RingtoetsEntitiesHelper.Create(mocks);
+ mocks.ReplayAll();
+
+ var entities = new List();
+ for (int i = 0; i < 3; i++)
+ {
+ entities.Add(new ReferenceLinePointEntity
+ {
+ Order = i
+ });
+ }
+
+ context.ReferenceLinePointEntities.Add(entities[0]);
+ context.ReferenceLinePointEntities.Add(entities[1]);
+ context.ReferenceLinePointEntities.Add(new ReferenceLinePointEntity());
+
+ var persistor = new ReferenceLinePersistor(context);
+ var referenceLine = new ReferenceLine();
+ referenceLine.SetGeometry(new[]
+ {
+ new Point2D(1, 1),
+ new Point2D(3, 2),
+ });
+
+ // Call
+ persistor.InsertModel(entities, referenceLine);
+
+ // Assert
+ AssertCreatedEntities(entities, referenceLine);
+ Assert.AreEqual(1, context.ReferenceLinePointEntities.Count());
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void InsertModel_EmptyCollectionNullReferenceLine_ShouldNotClearCollection()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var context = RingtoetsEntitiesHelper.Create(mocks);
var entities = mocks.StrictMock>();
- entities.Expect(e => e.GetEnumerator()).Return(backingList.GetEnumerator());
+ entities.Expect(e => e.GetEnumerator()).Return(new List().GetEnumerator());
mocks.ReplayAll();
var persistor = new ReferenceLinePersistor(context);