Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -53,7 +53,7 @@
Properties\GlobalAssembly.cs
-
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs
===================================================================
diff -u -raf521f167fabb7052a06e6a3d12575d3c3f18ab4 -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs (.../DikeAssessmentSectionEntityConverter.cs) (revision af521f167fabb7052a06e6a3d12575d3c3f18ab4)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/DikeAssessmentSectionEntityConverter.cs (.../DikeAssessmentSectionEntityConverter.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -39,26 +39,14 @@
/// The to obtain the model.
/// A new instance of , based on the properties of .
/// Thrown when or is null.
- public DikeAssessmentSection ConvertEntityToModel(DikeAssessmentSectionEntity entity, Func model)
+ public DikeAssessmentSection ConvertEntityToModel(DikeAssessmentSectionEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException("entity");
}
- try
- {
- if (model() == null)
- {
- throw new ArgumentNullException("model");
- }
- }
- catch (NullReferenceException)
- {
- throw new ArgumentNullException("model");
- }
-
- var dikeAssessmentSection = model();
+ var dikeAssessmentSection = new DikeAssessmentSection();
dikeAssessmentSection.StorageId = entity.DikeAssessmentSectionEntityId;
dikeAssessmentSection.Name = entity.Name ?? string.Empty;
dikeAssessmentSection.FailureMechanismContribution.Norm = entity.Norm;
Fisheye: Tag d242e89e13ef602facae6a1ef91660242bcef340 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/FailureMechanismEntityConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/HydraulicLocationConverter.cs
===================================================================
diff -u -rb50153c7b2f1c9c34f4575a599605f68844f43ca -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/HydraulicLocationConverter.cs (.../HydraulicLocationConverter.cs) (revision b50153c7b2f1c9c34f4575a599605f68844f43ca)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/HydraulicLocationConverter.cs (.../HydraulicLocationConverter.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -32,26 +32,14 @@
///
public class HydraulicLocationConverter : IEntityConverter
{
- public HydraulicBoundaryLocation ConvertEntityToModel(HydraulicLocationEntity entity, Func model)
+ public HydraulicBoundaryLocation ConvertEntityToModel(HydraulicLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException("entity");
}
-
- try
- {
- if (model() == null)
- {
- throw new ArgumentNullException("model");
- }
- }
- catch (NullReferenceException)
- {
- throw new ArgumentNullException("model");
- }
-
- HydraulicBoundaryLocation hydraulicBoundaryLocation = model();
+
+ HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation();
hydraulicBoundaryLocation.Id = entity.LocationId;
hydraulicBoundaryLocation.StorageId = entity.HydraulicLocationEntityId;
hydraulicBoundaryLocation.Name = entity.Name;
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs (.../IEntityConverter.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/IEntityConverter.cs (.../IEntityConverter.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -19,9 +19,6 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
-using Core.Common.Base.Storage;
-
namespace Application.Ringtoets.Storage.Converters
{
///
@@ -30,12 +27,11 @@
public interface IEntityConverter where TEntity : class
{
///
- /// Converts to .
+ /// Creates a new instance of based on information on .
///
/// The to convert.
- /// The to obtain the model.
- /// A new instance of , based on the properties of .
- TModel ConvertEntityToModel(TEntity entity, Func model);
+ /// A new instance of type .
+ TModel ConvertEntityToModel(TEntity entity);
///
/// Converts to .
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/PipingFailureMechanismEntityConverter.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/PipingFailureMechanismEntityConverter.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/PipingFailureMechanismEntityConverter.cs (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -0,0 +1,64 @@
+// 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 Ringtoets.Common.Data;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.Converters
+{
+ ///
+ /// Converter for to
+ /// and to .
+ ///
+ public class PipingFailureMechanismEntityConverter : IEntityConverter
+ {
+ public PipingFailureMechanism ConvertEntityToModel(FailureMechanismEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+
+ var failureMechanism = new PipingFailureMechanism();
+ failureMechanism.StorageId = entity.FailureMechanismEntityId;
+
+ return failureMechanism;
+ }
+
+ public void ConvertModelToEntity(PipingFailureMechanism modelObject, FailureMechanismEntity entity)
+ {
+ if (modelObject == null)
+ {
+ throw new ArgumentNullException("modelObject");
+ }
+
+ if (entity == null)
+ {
+ throw new ArgumentNullException("entity");
+ }
+
+ entity.FailureMechanismEntityId = modelObject.StorageId;
+ entity.FailureMechanismType = (int) FailureMechanismType.DikesPipingFailureMechanism;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/ProjectEntityConverter.cs
===================================================================
diff -u -raf521f167fabb7052a06e6a3d12575d3c3f18ab4 -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/ProjectEntityConverter.cs (.../ProjectEntityConverter.cs) (revision af521f167fabb7052a06e6a3d12575d3c3f18ab4)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Converters/ProjectEntityConverter.cs (.../ProjectEntityConverter.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -38,26 +38,14 @@
/// The to obtain the model.
/// A new instance of , based on the properties of .
/// Thrown when or is null.
- public Project ConvertEntityToModel(ProjectEntity entity, Func model)
+ public Project ConvertEntityToModel(ProjectEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException("entity");
}
- try
- {
- if (model() == null)
- {
- throw new ArgumentNullException("model");
- }
- }
- catch (NullReferenceException)
- {
- throw new ArgumentNullException("model");
- }
-
- var project = model();
+ var project = new Project();
project.StorageId = entity.ProjectEntityId;
project.Description = entity.Description;
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikeAssessmentSectionEntityPersistor.cs (.../DikeAssessmentSectionEntityPersistor.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -28,7 +28,6 @@
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Exceptions;
using Application.Ringtoets.Storage.Properties;
-using Ringtoets.HydraRing.Data;
using Ringtoets.Integration.Data;
namespace Application.Ringtoets.Storage.Persistors
@@ -71,20 +70,20 @@
/// The to load.
/// The to obtain the model.
/// A new instance of , based on the properties of .
- public DikeAssessmentSection LoadModel(DikeAssessmentSectionEntity entity, Func model)
+ public DikeAssessmentSection LoadModel(DikeAssessmentSectionEntity entity)
{
- var dikeAssessmentSection = converter.ConvertEntityToModel(entity, model);
+ var dikeAssessmentSection = converter.ConvertEntityToModel(entity);
foreach (var hydraulicLocationEntity in entity.HydraulicLocationEntities)
{
- dikeAssessmentSection.HydraulicBoundaryDatabase.Locations.Add(hydraulicLocationEntityPersistor.LoadModel(hydraulicLocationEntity, () => new HydraulicBoundaryLocation()));
+ dikeAssessmentSection.HydraulicBoundaryDatabase.Locations.Add(hydraulicLocationEntityPersistor.LoadModel(hydraulicLocationEntity));
}
foreach (var failureMechanismEntity in entity.FailureMechanismEntities)
{
if (failureMechanismEntity.FailureMechanismType == (int) FailureMechanismType.DikesPipingFailureMechanism)
{
- dikePipingFailureMechanismEntityPersistor.LoadModel(failureMechanismEntity, () => dikeAssessmentSection.PipingFailureMechanism);
+ dikePipingFailureMechanismEntityPersistor.LoadModel(failureMechanismEntity, dikeAssessmentSection.PipingFailureMechanism);
}
}
@@ -191,7 +190,7 @@
/// Referenced .
private void UpdateChildren(DikeAssessmentSection model, DikeAssessmentSectionEntity entity)
{
- dikePipingFailureMechanismEntityPersistor.UpdateModel(entity.FailureMechanismEntities, model.PipingFailureMechanism, 0);
+ dikePipingFailureMechanismEntityPersistor.UpdateModel(entity.FailureMechanismEntities, model.PipingFailureMechanism);
dikePipingFailureMechanismEntityPersistor.RemoveUnModifiedEntries(entity.FailureMechanismEntities);
}
@@ -202,7 +201,7 @@
/// Referenced .
private void InsertChildren(DikeAssessmentSection model, DikeAssessmentSectionEntity entity)
{
- dikePipingFailureMechanismEntityPersistor.InsertModel(entity.FailureMechanismEntities, model.PipingFailureMechanism, 0);
+ dikePipingFailureMechanismEntityPersistor.InsertModel(entity.FailureMechanismEntities, model.PipingFailureMechanism);
dikePipingFailureMechanismEntityPersistor.RemoveUnModifiedEntries(entity.FailureMechanismEntities);
if (model.HydraulicBoundaryDatabase != null)
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikesPipingFailureMechanismEntityPersistor.cs
===================================================================
diff -u -rbd8a3e95f0145815fa6724a162404a76c9dc9f5a -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikesPipingFailureMechanismEntityPersistor.cs (.../DikesPipingFailureMechanismEntityPersistor.cs) (revision bd8a3e95f0145815fa6724a162404a76c9dc9f5a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/DikesPipingFailureMechanismEntityPersistor.cs (.../DikesPipingFailureMechanismEntityPersistor.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -20,8 +20,10 @@
// All rights reserved.
using System;
+using Application.Ringtoets.Storage.Converters;
using Application.Ringtoets.Storage.DbContext;
using Ringtoets.Common.Data;
+using Ringtoets.Integration.Data;
using Ringtoets.Piping.Data;
namespace Application.Ringtoets.Storage.Persistors
@@ -31,39 +33,54 @@
///
public class DikesPipingFailureMechanismEntityPersistor : FailureMechanismEntityPersistorBase
{
+ private PipingFailureMechanismEntityConverter converter;
+
///
/// New instance of .
///
/// The storage context.
/// Thrown when is null.
- public DikesPipingFailureMechanismEntityPersistor(IRingtoetsEntities ringtoetsContext) : base(ringtoetsContext) {}
+ public DikesPipingFailureMechanismEntityPersistor(IRingtoetsEntities ringtoetsContext) : base(ringtoetsContext) {
+ converter = new PipingFailureMechanismEntityConverter();
+ }
///
/// Loads the as .
///
/// to load from.
- /// The to obtain the model.
+ /// The piping failure mechanism to load data in.
/// Thrown when:
/// - is null.
+ /// - is null.
///
- /// Thrown when is not of type .
- public override PipingFailureMechanism LoadModel(FailureMechanismEntity entity, Func model)
+ public override void LoadModel(FailureMechanismEntity entity, PipingFailureMechanism pipingFailureMechanism)
{
if (entity == null)
{
throw new ArgumentNullException("entity");
}
-
- if (model() == null)
+ if (pipingFailureMechanism == null)
{
- throw new ArgumentNullException("model");
+ throw new ArgumentNullException("pipingFailureMechanism");
}
if (entity.FailureMechanismType != (int) FailureMechanismType.DikesPipingFailureMechanism)
{
- throw new ArgumentException("Incorrect modelType", "entity");
+ throw new ArgumentException(@"Incorrect modelType", "entity");
}
- return base.LoadModel(entity, model);
+
+ var model = ConvertEntityToModel(entity);
+ pipingFailureMechanism.StorageId = model.StorageId;
}
+
+ protected override void ConvertModelToEntity(PipingFailureMechanism model, FailureMechanismEntity entity)
+ {
+ converter.ConvertModelToEntity(model, entity);
+ }
+
+ protected override PipingFailureMechanism ConvertEntityToModel(FailureMechanismEntity entity)
+ {
+ return converter.ConvertEntityToModel(entity);
+ }
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs (.../FailureMechanismEntityPersistorBase.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/FailureMechanismEntityPersistorBase.cs (.../FailureMechanismEntityPersistorBase.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -28,6 +28,7 @@
using Application.Ringtoets.Storage.Exceptions;
using Application.Ringtoets.Storage.Properties;
using Ringtoets.Common.Data;
+using Ringtoets.Integration.Data;
using Ringtoets.Piping.Data;
namespace Application.Ringtoets.Storage.Persistors
@@ -40,10 +41,9 @@
private readonly IRingtoetsEntities dbContext;
private readonly Dictionary insertedList = new Dictionary();
private readonly ICollection modifiedList = new List();
- private readonly FailureMechanismEntityConverter converter;
///
- /// New instance of .
+ /// New instance of .
///
/// The storage context.
/// Thrown when is null.
@@ -54,8 +54,6 @@
throw new ArgumentNullException("ringtoetsContext");
}
dbContext = ringtoetsContext;
-
- converter = new FailureMechanismEntityConverter();
}
///
@@ -72,15 +70,15 @@
/// - More than one element found in that should have been unique.
/// - No such element exists in .
///
- public void UpdateModel(ICollection parentNavigationProperty, T model, int order)
+ public void UpdateModel(ICollection parentNavigationProperty, T model)
{
if (model == null)
{
throw new ArgumentNullException("model");
}
if (model.StorageId < 1)
{
- InsertModel(parentNavigationProperty, model, 0);
+ InsertModel(parentNavigationProperty, model);
return;
}
@@ -105,7 +103,7 @@
modifiedList.Add(entity);
- converter.ConvertModelToEntity(model, entity);
+ ConvertModelToEntity(model, entity);
}
///
@@ -117,7 +115,7 @@
/// - is null.
/// - is null.
///
- public void InsertModel(ICollection parentNavigationProperty, T model, int order)
+ public void InsertModel(ICollection parentNavigationProperty, T model)
{
if (parentNavigationProperty == null)
{
@@ -128,7 +126,7 @@
parentNavigationProperty.Add(entity);
insertedList.Add(entity, model);
- converter.ConvertModelToEntity(model, entity);
+ ConvertModelToEntity(model, entity);
if (model.StorageId > 0)
{
@@ -140,11 +138,8 @@
/// Loads a new model of type based on the .
///
/// Database entity containing information for the new model.
- /// A new instance of type .
- public virtual T LoadModel(FailureMechanismEntity entity, Func model)
- {
- return converter.ConvertEntityToModel(entity, model);
- }
+ /// The assessment section to add the failure mechanism to.
+ public abstract void LoadModel(FailureMechanismEntity entity, T dikeAssessmentSection);
///
/// All unmodified in will be removed.
@@ -182,5 +177,8 @@
}
insertedList.Clear();
}
+
+ protected abstract void ConvertModelToEntity(T model, FailureMechanismEntity entity);
+ protected abstract T ConvertEntityToModel(FailureMechanismEntity entity);
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs (.../HydraulicLocationEntityPersistor.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/HydraulicLocationEntityPersistor.cs (.../HydraulicLocationEntityPersistor.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -149,26 +149,14 @@
insertedList.Clear();
}
- public HydraulicBoundaryLocation LoadModel(HydraulicLocationEntity entity, Func model)
+ public HydraulicBoundaryLocation LoadModel(HydraulicLocationEntity entity)
{
if (entity == null)
{
throw new ArgumentNullException("entity");
}
- try
- {
- if (model() == null)
- {
- throw new ArgumentNullException("model");
- }
- }
- catch (NullReferenceException)
- {
- throw new ArgumentNullException("model");
- }
-
- return converter.ConvertEntityToModel(entity, model);
+ return converter.ConvertEntityToModel(entity);
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs (.../ProjectEntityPersistor.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Persistors/ProjectEntityPersistor.cs (.../ProjectEntityPersistor.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -74,7 +74,7 @@
{
var entry = dbSet.SingleOrDefault();
- return LoadModel(entry, () => new Project());
+ return LoadModel(entry);
}
///
@@ -187,20 +187,20 @@
InsertChildren(project, entity);
}
- private Project LoadModel(ProjectEntity entity, Func model)
+ private Project LoadModel(ProjectEntity entity)
{
if (entity == null)
{
return null;
}
- var project = converter.ConvertEntityToModel(entity, model);
+ var project = converter.ConvertEntityToModel(entity);
var nrOfItems = entity.DikeAssessmentSectionEntities.Count;
var assessmentSections = new object[nrOfItems];
foreach (var sectionEntity in entity.DikeAssessmentSectionEntities)
{
- assessmentSections[sectionEntity.Order] = dikeAssessmentSectionEntityPersistor.LoadModel(sectionEntity, () => new DikeAssessmentSection());
+ assessmentSections[sectionEntity.Order] = dikeAssessmentSectionEntityPersistor.LoadModel(sectionEntity);
}
// Add to items sorted
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -raf521f167fabb7052a06e6a3d12575d3c3f18ab4 -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision af521f167fabb7052a06e6a3d12575d3c3f18ab4)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -81,7 +81,8 @@
-
+
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/DikeAssessmentSectionEntityConverterTest.cs
===================================================================
diff -u -raf521f167fabb7052a06e6a3d12575d3c3f18ab4 -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/DikeAssessmentSectionEntityConverterTest.cs (.../DikeAssessmentSectionEntityConverterTest.cs) (revision af521f167fabb7052a06e6a3d12575d3c3f18ab4)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/DikeAssessmentSectionEntityConverterTest.cs (.../DikeAssessmentSectionEntityConverterTest.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -1,5 +1,25 @@
-using System;
-using System.Collections.Generic;
+// 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.Converters;
using Application.Ringtoets.Storage.DbContext;
using NUnit.Framework;
@@ -11,15 +31,6 @@
[TestFixture]
public class DikeAssessmentSectionEntityConverterTest
{
- private static IEnumerable> TestCases
- {
- get
- {
- yield return () => null;
- yield return null;
- }
- }
-
[Test]
public void DefaultConstructor_Always_NewDikeAssessmentSectionEntityConverter()
{
@@ -37,39 +48,13 @@
DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
// Call
- TestDelegate test = () => converter.ConvertEntityToModel(null, () => new DikeAssessmentSection());
+ TestDelegate test = () => converter.ConvertEntityToModel(null);
// Assert
Assert.Throws(test);
}
[Test]
- [TestCaseSource("TestCases")]
- public void ConvertEntityToModel_ValidDikeAssessmentSectionEntityNullModel_ThrowsArgumentNullException(Func func)
- {
- // Setup
- const long storageId = 1234L;
- const long projectId = 1L;
- const int norm = 30000;
- const string name = "test";
- DikeAssessmentSectionEntity dikeAssessmentSectionEntity = new DikeAssessmentSectionEntity()
- {
- DikeAssessmentSectionEntityId = storageId,
- Name = name,
- ProjectEntityId = projectId,
- Norm = norm
- };
-
- DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
-
- // Call
- TestDelegate test = () => converter.ConvertEntityToModel(dikeAssessmentSectionEntity, func);
-
- // Assert
- Assert.Throws(test);
- }
-
- [Test]
public void ConvertEntityToModel_ValidDikeAssessmentSectionEntity_ReturnsTheDikeAssessmentSectionEntityAsDikeAssessmentSection()
{
// Setup
@@ -91,7 +76,7 @@
DikeAssessmentSectionEntityConverter converter = new DikeAssessmentSectionEntityConverter();
// Call
- DikeAssessmentSection assessmentSection = converter.ConvertEntityToModel(dikeAssessmentSectionEntity, () => new DikeAssessmentSection());
+ DikeAssessmentSection assessmentSection = converter.ConvertEntityToModel(dikeAssessmentSectionEntity);
// Assert
Assert.AreNotEqual(dikeAssessmentSectionEntity, assessmentSection);
Fisheye: Tag d242e89e13ef602facae6a1ef91660242bcef340 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/FailureMechanismEntityConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/HydraulicLocationConverterTest.cs
===================================================================
diff -u -rb50153c7b2f1c9c34f4575a599605f68844f43ca -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/HydraulicLocationConverterTest.cs (.../HydraulicLocationConverterTest.cs) (revision b50153c7b2f1c9c34f4575a599605f68844f43ca)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/HydraulicLocationConverterTest.cs (.../HydraulicLocationConverterTest.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -20,7 +20,6 @@
// All rights reserved.
using System;
-using System.Collections.Generic;
using Application.Ringtoets.Storage.Converters;
using Application.Ringtoets.Storage.DbContext;
using NUnit.Framework;
@@ -31,15 +30,6 @@
[TestFixture]
public class HydraulicLocationConverterTest
{
- private static IEnumerable> TestCases
- {
- get
- {
- yield return () => null;
- yield return null;
- }
- }
-
[Test]
public void Constructor_Always_NewInstance()
{
@@ -57,29 +47,14 @@
HydraulicLocationConverter converter = new HydraulicLocationConverter();
// Call
- TestDelegate test = () => converter.ConvertEntityToModel(null, () => new HydraulicBoundaryLocation());
+ TestDelegate test = () => converter.ConvertEntityToModel(null);
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("entity", exception.ParamName);
}
[Test]
- [TestCaseSource("TestCases")]
- public void ConvertEntityToModel_NullModel_ThrowsArgumentNullException(Func funcModel)
- {
- // Setup
- HydraulicLocationConverter converter = new HydraulicLocationConverter();
-
- // Call
- TestDelegate test = () => converter.ConvertEntityToModel(new HydraulicLocationEntity(), funcModel);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("model", exception.ParamName);
- }
-
- [Test]
public void ConvertEntityToModel_ValidEntityValidModel_ReturnsTheEntityAsModel()
{
// Setup
@@ -101,7 +76,7 @@
HydraulicLocationConverter converter = new HydraulicLocationConverter();
// Call
- HydraulicBoundaryLocation location = converter.ConvertEntityToModel(entity, () => new HydraulicBoundaryLocation());
+ HydraulicBoundaryLocation location = converter.ConvertEntityToModel(entity);
// Assert
Assert.AreNotEqual(entity, location);
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/PipingFailureMechanismEntityConverterTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/PipingFailureMechanismEntityConverterTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/PipingFailureMechanismEntityConverterTest.cs (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -0,0 +1,132 @@
+// 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.Converters;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data;
+using Ringtoets.Piping.Data;
+
+namespace Application.Ringtoets.Storage.Test.Converters
+{
+ [TestFixture]
+ public class PipingFailureMechanismEntityConverterTest
+ {
+ [Test]
+ public void DefaultConstructor_Always_NewFailureMechanismEntityConverter()
+ {
+ // Call
+ PipingFailureMechanismEntityConverter converter = new PipingFailureMechanismEntityConverter();
+
+ // Assert
+ Assert.IsInstanceOf>(converter);
+ }
+
+ [Test]
+ public void ConvertEntityToModel_NullEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ PipingFailureMechanismEntityConverter converter = new PipingFailureMechanismEntityConverter();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => converter.ConvertEntityToModel(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("entity", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void ConvertEntityToModel_ValidEntityValidModel_ReturnsEntityAsModel()
+ {
+ // Setup
+ PipingFailureMechanismEntityConverter converter = new PipingFailureMechanismEntityConverter();
+
+ const long storageId = 1234L;
+ FailureMechanismEntity entity = new FailureMechanismEntity
+ {
+ FailureMechanismEntityId = storageId,
+ FailureMechanismType = (int)FailureMechanismType.DikesPipingFailureMechanism,
+ };
+
+ // Call
+ PipingFailureMechanism failureMechanism = converter.ConvertEntityToModel(entity);
+
+ // Assert
+ Assert.AreEqual(entity.FailureMechanismEntityId, failureMechanism.StorageId);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_NullModel_ThrowsArgumentNullException()
+ {
+ // Setup
+ PipingFailureMechanismEntityConverter converter = new PipingFailureMechanismEntityConverter();
+
+ // Call
+ TestDelegate test = () => converter.ConvertModelToEntity(null, new FailureMechanismEntity());
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("modelObject", exception.ParamName);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_NullEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ PipingFailureMechanismEntityConverter converter = new PipingFailureMechanismEntityConverter();
+
+ // Call
+ TestDelegate test = () => converter.ConvertModelToEntity(new PipingFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_ValidModelValidEntity_ReturnsModelAsEntity()
+ {
+ // Setup
+ PipingFailureMechanismEntityConverter converter = new PipingFailureMechanismEntityConverter();
+
+ const long storageId = 1234L;
+ var entity = new FailureMechanismEntity();
+
+ var model = new PipingFailureMechanism
+ {
+ StorageId = storageId
+ };
+
+ // Call
+ converter.ConvertModelToEntity(model, entity);
+
+ // Assert
+ Assert.AreEqual(model.StorageId, entity.FailureMechanismEntityId);
+ }
+ }
+}
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/ProjectEntityConverterTest.cs
===================================================================
diff -u -raf521f167fabb7052a06e6a3d12575d3c3f18ab4 -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/ProjectEntityConverterTest.cs (.../ProjectEntityConverterTest.cs) (revision af521f167fabb7052a06e6a3d12575d3c3f18ab4)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/ProjectEntityConverterTest.cs (.../ProjectEntityConverterTest.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -1,5 +1,25 @@
-using System;
-using System.Collections.Generic;
+// 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.Converters;
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Base.Data;
@@ -10,15 +30,6 @@
[TestFixture]
public class ProjectEntityConverterTest
{
- private static IEnumerable> TestCases
- {
- get
- {
- yield return () => null;
- yield return null;
- }
- }
-
[Test]
public void DefaultConstructor_Always_NewProjectEntityConverter()
{
@@ -36,35 +47,13 @@
ProjectEntityConverter converter = new ProjectEntityConverter();
// Call
- TestDelegate test = () => converter.ConvertEntityToModel(null, () => new Project());
+ TestDelegate test = () => converter.ConvertEntityToModel(null);
// Assert
Assert.Throws(test);
}
[Test]
- [TestCaseSource("TestCases")]
- public void ConvertEntityToModel_ValidProjectEntityNullModel_ThrowsArgumentNullException(Func func)
- {
- // SetUp
- const long storageId = 1234L;
- const string description = "Description";
- ProjectEntity projectEntity = new ProjectEntity()
- {
- ProjectEntityId = storageId,
- Description = description
- };
-
- ProjectEntityConverter converter = new ProjectEntityConverter();
-
- // Call
- TestDelegate test = () => converter.ConvertEntityToModel(projectEntity, func);
-
- // Assert
- Assert.Throws(test);
- }
-
- [Test]
public void ConvertEntityToModel_ValidProjectEntity_ReturnsTheProjectEntityAsProject()
{
// SetUp
@@ -78,7 +67,7 @@
ProjectEntityConverter converter = new ProjectEntityConverter();
// Call
- Project project = converter.ConvertEntityToModel(projectEntity, () => new Project());
+ Project project = converter.ConvertEntityToModel(projectEntity);
// Assert
Assert.AreNotEqual(projectEntity, project);
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/ReferenceLineConverterTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/ReferenceLineConverterTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Converters/ReferenceLineConverterTest.cs (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -0,0 +1,152 @@
+// 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.Collections.Generic;
+using Application.Ringtoets.Storage.Converters;
+using Application.Ringtoets.Storage.DbContext;
+using NUnit.Framework;
+using Ringtoets.HydraRing.Data;
+
+namespace Application.Ringtoets.Storage.Test.Converters
+{
+ [TestFixture]
+ public class ReferenceLineConverterTest
+ {
+ [Test]
+ public void Constructor_Always_NewInstance()
+ {
+ // Call
+ HydraulicLocationConverter converter = new HydraulicLocationConverter();
+
+ // Assert
+ Assert.IsInstanceOf>(converter);
+ }
+
+ [Test]
+ public void ConvertEntityToModel_NullEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ HydraulicLocationConverter converter = new HydraulicLocationConverter();
+
+ // Call
+ TestDelegate test = () => converter.ConvertEntityToModel(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void ConvertEntityToModel_ValidEntityValidModel_ReturnsTheEntityAsModel()
+ {
+ // Setup
+ const string name = "test";
+ const double designWaterLevel = 15.6;
+ const long locationId = 1300001;
+ const long storageId = 1234L;
+ const decimal locationX = 253;
+ const decimal locationY = 123;
+ var entity = new HydraulicLocationEntity()
+ {
+ LocationId = locationId,
+ Name = name,
+ DesignWaterLevel = designWaterLevel,
+ HydraulicLocationEntityId = storageId,
+ LocationX = locationX,
+ LocationY = locationY
+ };
+ HydraulicLocationConverter converter = new HydraulicLocationConverter();
+
+ // Call
+ HydraulicBoundaryLocation location = converter.ConvertEntityToModel(entity);
+
+ // Assert
+ Assert.AreNotEqual(entity, location);
+ Assert.AreEqual(locationId, location.Id);
+ Assert.AreEqual(storageId, location.StorageId);
+ Assert.AreEqual(name, location.Name);
+ Assert.AreEqual(designWaterLevel, location.DesignWaterLevel);
+ Assert.AreEqual(locationX, location.Location.X);
+ Assert.AreEqual(locationY, location.Location.Y);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_NullModel_ThrowsArgumentNullException()
+ {
+ // Setup
+ HydraulicLocationConverter converter = new HydraulicLocationConverter();
+
+ // Call
+ TestDelegate test = () => converter.ConvertModelToEntity(null, new HydraulicLocationEntity());
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("modelObject", exception.ParamName);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_NullEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ HydraulicLocationConverter converter = new HydraulicLocationConverter();
+
+ // Call
+ TestDelegate test = () => converter.ConvertModelToEntity(new HydraulicBoundaryLocation(), null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void ConvertModelToEntity_ValidModelValidEntity_ReturnsModelAsEntity()
+ {
+ // Setup
+ HydraulicLocationConverter converter = new HydraulicLocationConverter();
+
+ var entity = new HydraulicLocationEntity();
+ const long storageId = 1234L;
+ const long locationId = 130002;
+ const string name = "test";
+ const double locationX = 39.3;
+ const double locationY = 583.2;
+ const double designWaterLever = 14.7;
+
+ var model = new HydraulicBoundaryLocation(locationId, name, locationX, locationY)
+ {
+ StorageId = storageId,
+ DesignWaterLevel = designWaterLever
+ };
+
+ // Call
+ converter.ConvertModelToEntity(model, entity);
+
+ // Assert
+ Assert.AreEqual(model.StorageId, entity.HydraulicLocationEntityId);
+ Assert.AreEqual(model.Id, entity.LocationId);
+ Assert.AreEqual(model.Name, entity.Name);
+ Assert.AreEqual(model.Location.X, entity.LocationX);
+ Assert.AreEqual(model.Location.Y, entity.LocationY);
+ Assert.AreEqual(model.DesignWaterLevel, entity.DesignWaterLevel);
+ }
+ }
+}
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs (.../DikeAssessmentSectionEntityPersistorTest.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikeAssessmentSectionEntityPersistorTest.cs (.../DikeAssessmentSectionEntityPersistorTest.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -66,7 +66,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.LoadModel(null, () => new DikeAssessmentSection());
+ TestDelegate test = () => persistor.LoadModel(null);
// Assert
Assert.Throws(test);
@@ -75,41 +75,6 @@
}
[Test]
- [TestCaseSource("TestCases")]
- public void LoadModel_ValidEntityNullModel_ThrowsArgumentNullException(Func func)
- {
- // Setup
- const long storageId = 1234L;
- const string name = "test";
- const int norm = 30000;
- const long pipingFailureMechanismStorageId = 1L;
- var ringtoetsEntities = mockRepository.StrictMock();
- DikeAssessmentSectionEntityPersistor persistor = new DikeAssessmentSectionEntityPersistor(ringtoetsEntities);
- var entity = new DikeAssessmentSectionEntity
- {
- DikeAssessmentSectionEntityId = storageId,
- Name = name,
- Norm = norm,
- FailureMechanismEntities = new List
- {
- new FailureMechanismEntity
- {
- FailureMechanismType = (int) FailureMechanismType.DikesPipingFailureMechanism, FailureMechanismEntityId = pipingFailureMechanismStorageId
- }
- }
- };
- mockRepository.ReplayAll();
-
- // Call
- TestDelegate test = () => persistor.LoadModel(entity, func);
-
- // Assert
- Assert.Throws(test);
-
- mockRepository.VerifyAll();
- }
-
- [Test]
public void LoadModel_ValidEntity_EntityAsModel()
{
// Setup
@@ -163,7 +128,7 @@
mockRepository.ReplayAll();
// Call
- DikeAssessmentSection section = persistor.LoadModel(entity, () => new DikeAssessmentSection());
+ DikeAssessmentSection section = persistor.LoadModel(entity);
// Assert
Assert.AreEqual(storageId, section.StorageId);
@@ -213,7 +178,7 @@
mockRepository.ReplayAll();
// Call
- var loadedModels = parentNavigationProperty.Select(entity => persistor.LoadModel(entity, () => new DikeAssessmentSection()));
+ var loadedModels = parentNavigationProperty.Select(entity => persistor.LoadModel(entity));
// Assert
var parentNavigationPropertyList = parentNavigationProperty.ToList();
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikesPipingFailureMechanismEntityPersistorTest.cs
===================================================================
diff -u -rb50153c7b2f1c9c34f4575a599605f68844f43ca -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikesPipingFailureMechanismEntityPersistorTest.cs (.../DikesPipingFailureMechanismEntityPersistorTest.cs) (revision b50153c7b2f1c9c34f4575a599605f68844f43ca)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/DikesPipingFailureMechanismEntityPersistorTest.cs (.../DikesPipingFailureMechanismEntityPersistorTest.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -8,6 +8,7 @@
using Application.Ringtoets.Storage.Test.DbContext;
using NUnit.Framework;
using Rhino.Mocks;
+using Ringtoets.Integration.Data;
using Ringtoets.Piping.Data;
namespace Application.Ringtoets.Storage.Test.Persistors
@@ -55,32 +56,27 @@
DikesPipingFailureMechanismEntityPersistor persistor = new DikesPipingFailureMechanismEntityPersistor(ringtoetsEntities);
// Call
- TestDelegate test = () => persistor.LoadModel(null, () => new PipingFailureMechanism());
+ TestDelegate test = () => persistor.LoadModel(null, new PipingFailureMechanism());
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("entity", exception.ParamName);
}
[Test]
- public void LoadModel_ValidEntityNullModel_ThrowsArgumentNullException()
+ public void LoadModel_NullDikeAssessmentSection_ThrowsArgumentNullException()
{
// Setup
- const long storageId = 1234L;
- FailureMechanismEntity entity = new FailureMechanismEntity
- {
- FailureMechanismEntityId = storageId,
- FailureMechanismType = (int)FailureMechanismType.DikesPipingFailureMechanism,
- };
var ringtoetsEntities = mockRepository.StrictMock();
DikesPipingFailureMechanismEntityPersistor persistor = new DikesPipingFailureMechanismEntityPersistor(ringtoetsEntities);
+ FailureMechanismEntity entity = new FailureMechanismEntity();
// Call
- TestDelegate test = () => persistor.LoadModel(entity, () => null);
+ TestDelegate test = () => persistor.LoadModel(entity, null);
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("model", exception.ParamName);
+ Assert.AreEqual("pipingFailureMechanism", exception.ParamName);
}
[Test]
@@ -97,7 +93,7 @@
DikesPipingFailureMechanismEntityPersistor persistor = new DikesPipingFailureMechanismEntityPersistor(ringtoetsEntities);
// Call
- TestDelegate test = () => persistor.LoadModel(entity, () => new PipingFailureMechanism());
+ TestDelegate test = () => persistor.LoadModel(entity, new PipingFailureMechanism());
// Assert
Assert.Throws(test);
@@ -120,10 +116,13 @@
var ringtoetsEntities = mockRepository.StrictMock();
DikesPipingFailureMechanismEntityPersistor persistor = new DikesPipingFailureMechanismEntityPersistor(ringtoetsEntities);
+ var dikeAssessmentSection = new DikeAssessmentSection();
+
// Call
- PipingFailureMechanism loadedModel = persistor.LoadModel(entity, () => new PipingFailureMechanism());
+ persistor.LoadModel(entity, dikeAssessmentSection.PipingFailureMechanism);
// Assert
+ PipingFailureMechanism loadedModel = dikeAssessmentSection.PipingFailureMechanism;
Assert.IsInstanceOf(loadedModel);
Assert.AreEqual(loadedModel.StorageId, entity.FailureMechanismEntityId);
Assert.AreEqual(model.StorageId, loadedModel.StorageId);
@@ -139,7 +138,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.InsertModel(null, model, 0);
+ TestDelegate test = () => persistor.InsertModel(null, model);
// Assert
Assert.Throws(test);
@@ -157,7 +156,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.InsertModel(parentNavigationProperty, null, 0);
+ TestDelegate test = () => persistor.InsertModel(parentNavigationProperty, null);
// Assert
Assert.Throws(test);
@@ -177,7 +176,7 @@
mockRepository.ReplayAll();
// Call
- persistor.InsertModel(parentNavigationProperty, model, 0);
+ persistor.InsertModel(parentNavigationProperty, model);
// Assert
Assert.AreEqual(1, parentNavigationProperty.Count);
@@ -211,7 +210,7 @@
mockRepository.ReplayAll();
// Call
- persistor.InsertModel(parentNavigationProperty, pipingFailureMechanism, 0);
+ persistor.InsertModel(parentNavigationProperty, pipingFailureMechanism);
// Assert
Assert.AreEqual(2, parentNavigationProperty.Count);
@@ -236,7 +235,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.UpdateModel(null, model, 0);
+ TestDelegate test = () => persistor.UpdateModel(null, model);
// Assert
Assert.Throws(test);
@@ -254,7 +253,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, null, 0);
+ TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, null);
// Assert
Assert.Throws(test);
@@ -277,7 +276,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, model, 0);
+ TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, model);
// Assert
Assert.Throws(test);
@@ -312,7 +311,7 @@
mockRepository.ReplayAll();
// Call
- TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, model, 0);
+ TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, model);
// Assert
Assert.Throws(test);
@@ -342,7 +341,7 @@
mockRepository.ReplayAll();
// Call
- persistor.UpdateModel(parentNavigationProperty, model, 0);
+ persistor.UpdateModel(parentNavigationProperty, model);
// Assert
Assert.AreEqual(1, parentNavigationProperty.Count);
@@ -369,7 +368,7 @@
mocks.ReplayAll();
// Call
- persistor.UpdateModel(parentNavigationProperty, model, 0);
+ persistor.UpdateModel(parentNavigationProperty, model);
// Assert
Assert.AreEqual(1, parentNavigationProperty.Count);
@@ -403,7 +402,7 @@
mockRepository.ReplayAll();
// Call
- persistor.UpdateModel(parentNavigationProperty, pipingFailureMechanism, 0);
+ persistor.UpdateModel(parentNavigationProperty, pipingFailureMechanism);
persistor.RemoveUnModifiedEntries(parentNavigationProperty);
// Assert
@@ -449,7 +448,7 @@
};
mockRepository.ReplayAll();
- TestDelegate updateTest = () => persistor.UpdateModel(parentNavigationProperty, pipingFailureMechanism, 0);
+ TestDelegate updateTest = () => persistor.UpdateModel(parentNavigationProperty, pipingFailureMechanism);
Assert.DoesNotThrow(updateTest, "Precondition failed: Update should not throw exception.");
// Call
@@ -494,7 +493,7 @@
PipingFailureMechanism pipingFailureMechanism = new PipingFailureMechanism();
mockRepository.ReplayAll();
- TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, pipingFailureMechanism, 0);
+ TestDelegate test = () => persistor.UpdateModel(parentNavigationProperty, pipingFailureMechanism);
Assert.DoesNotThrow(test, "Precondition failed: UpdateModel");
// Call
@@ -554,7 +553,7 @@
{
try
{
- persistor.UpdateModel(parentNavigationPropertyMock, pipingFailureMechanism, 0);
+ persistor.UpdateModel(parentNavigationPropertyMock, pipingFailureMechanism);
}
catch (Exception)
{
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicLocationEntityPersistorTest.cs
===================================================================
diff -u -r4670af35a2cb3c8b78d68a25804c3b620da19ddb -rd242e89e13ef602facae6a1ef91660242bcef340
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicLocationEntityPersistorTest.cs (.../HydraulicLocationEntityPersistorTest.cs) (revision 4670af35a2cb3c8b78d68a25804c3b620da19ddb)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Persistors/HydraulicLocationEntityPersistorTest.cs (.../HydraulicLocationEntityPersistorTest.cs) (revision d242e89e13ef602facae6a1ef91660242bcef340)
@@ -83,7 +83,7 @@
mocks.ReplayAll();
// Call
- TestDelegate test = () => persistor.LoadModel(null, () => new HydraulicBoundaryLocation());
+ TestDelegate test = () => persistor.LoadModel(null);
// Assert
var exception = Assert.Throws(test);
@@ -92,25 +92,6 @@
}
[Test]
- [TestCaseSource("TestCases")]
- public void LoadModel_ValidEntityNullModel_ThrowsArgumentNullException(Func modelFunc)
- {
- // Setup
- var mocks = new MockRepository();
- var ringtoetsEntities = mocks.StrictMock();
- var persistor = new HydraulicLocationEntityPersistor(ringtoetsEntities);
- mocks.ReplayAll();
-
- // Call
- TestDelegate test = () => persistor.LoadModel(new HydraulicLocationEntity(), modelFunc);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("model", exception.ParamName);
- mocks.VerifyAll();
- }
-
- [Test]
public void LoadModel_ValidEntityValidModel_EntityAsModel()
{
// Setup
@@ -136,7 +117,7 @@
};
// Call
- HydraulicBoundaryLocation location = persistor.LoadModel(entity, () => new HydraulicBoundaryLocation());
+ HydraulicBoundaryLocation location = persistor.LoadModel(entity);
// Assert
Assert.AreEqual(locationId, location.Id);