Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -ra5714fc0488030773fff50dfc82041c6cb9edc2f -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision a5714fc0488030773fff50dfc82041c6cb9edc2f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -63,6 +63,7 @@
+
@@ -244,6 +245,9 @@
+
+ Code
+
@@ -317,6 +321,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensions.cs (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -0,0 +1,61 @@
+// 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.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Create.GrassCoverErosionInwards
+{
+ ///
+ /// Extension methods for related
+ /// to creating a .
+ ///
+ internal static class GrassCoverErosionInwardsCalculationCreateExtensions
+ {
+ ///
+ /// Creates a based
+ /// on the information of the .
+ ///
+ /// The calculation to create a database entity for.
+ /// The object keeping track of create operations.
+ /// A new .
+ /// Thrown when is null.
+ internal static GrassCoverErosionInwardsCalculationEntity Create(this GrassCoverErosionInwardsCalculation calculation, PersistenceRegistry registry, int order)
+ {
+ if (registry == null)
+ {
+ throw new ArgumentNullException("registry");
+ }
+
+ var entity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ Name = calculation.Name,
+ Comments = calculation.Comments,
+ Order = order
+ };
+ registry.Register(entity, calculation);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs
===================================================================
diff -u -r53aef346fd0ee3cc79d1f5df9171c476453f2935 -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 53aef346fd0ee3cc79d1f5df9171c476453f2935)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -56,6 +56,7 @@
private readonly Dictionary pipingFailureMechanismSectionResults = new Dictionary();
private readonly Dictionary generalGrassCoverErosionInwardsInputs = new Dictionary();
private readonly Dictionary dikeProfiles = new Dictionary();
+ private readonly Dictionary grassCoverErosionInwardsCalculations = new Dictionary();
private readonly Dictionary grassCoverErosionInwardsFailureMechanismSectionResults = new Dictionary();
private readonly Dictionary heightStructuresFailureMechanismSectionResults = new Dictionary();
private readonly Dictionary strengthStabilityLengthwiseConstructionFailureMechanismSectionResults = new Dictionary();
@@ -155,6 +156,24 @@
/// Registers a create or update operation for and the
/// that was constructed with the information.
///
+ /// The
+ /// to be registered.
+ /// The to
+ /// be registered.
+ /// Thrown when either:
+ ///
+ /// - is null
+ /// - is null
+ ///
+ public void Register(GrassCoverErosionInwardsCalculationEntity entity, GrassCoverErosionInwardsCalculation model)
+ {
+ Register(grassCoverErosionInwardsCalculations, entity, model);
+ }
+
+ ///
+ /// Registers a create or update operation for and the
+ /// that was constructed with the information.
+ ///
/// The to be registered.
/// The to be registered.
/// Thrown when either:
@@ -908,6 +927,11 @@
dikeProfiles[entity].StorageId = entity.DikeProfileEntityId;
}
+ foreach (var entity in grassCoverErosionInwardsCalculations.Keys)
+ {
+ grassCoverErosionInwardsCalculations[entity].StorageId = entity.GrassCoverErosionInwardsCalculationEntityId;
+ }
+
foreach (var entity in grassCoverErosionInwardsFailureMechanismSectionResults.Keys)
{
grassCoverErosionInwardsFailureMechanismSectionResults[entity].StorageId = entity.GrassCoverErosionInwardsSectionResultEntityId;
@@ -1140,6 +1164,17 @@
}
dbContext.DikeProfileEntities.RemoveRange(orphanedDikeProfileEntities);
+ var orphanedGrassCoverErosionInwardsCalculationEntities = new List();
+ foreach (GrassCoverErosionInwardsCalculationEntity calculationEntity in dbContext.GrassCoverErosionInwardsCalculationEntities
+ .Where(e => e.GrassCoverErosionInwardsCalculationEntityId > 0))
+ {
+ if (!grassCoverErosionInwardsCalculations.ContainsKey(calculationEntity))
+ {
+ orphanedGrassCoverErosionInwardsCalculationEntities.Add(calculationEntity);
+ }
+ }
+ dbContext.GrassCoverErosionInwardsCalculationEntities.RemoveRange(orphanedGrassCoverErosionInwardsCalculationEntities);
+
var orphanedGrassCoverErosionInwardsSectionResultEntities = new List();
foreach (GrassCoverErosionInwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverErosionInwardsSectionResultEntities
.Where(e => e.GrassCoverErosionInwardsSectionResultEntityId > 0))
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -0,0 +1,51 @@
+// 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 Application.Ringtoets.Storage.DbContext;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Read.GrassCoverErosionInwards
+{
+ ///
+ /// This class defines extension methods for read operations for a
+ /// based on the .
+ ///
+ internal static class GrassCoverErosionInwardsCalculationEntityReadExtensions
+ {
+ ///
+ /// Reads the and use the
+ /// information to update a .
+ ///
+ /// The
+ /// to create for.
+ /// A new .
+ internal static GrassCoverErosionInwardsCalculation Read(this GrassCoverErosionInwardsCalculationEntity entity)
+ {
+ return new GrassCoverErosionInwardsCalculation
+ {
+ Name = entity.Name,
+ Comments = entity.Comments,
+ StorageId = entity.GrassCoverErosionInwardsCalculationEntityId
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationUpdateExtensions.cs (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -0,0 +1,75 @@
+// 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 Application.Ringtoets.Storage.Exceptions;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Update.GrassCoverErosionInwards
+{
+ ///
+ /// Extension methods for related
+ /// to updating a .
+ ///
+ internal static class GrassCoverErosionInwardsCalculationUpdateExtensions
+ {
+ ///
+ /// Updates a in
+ /// the database based on the information of the .
+ ///
+ /// The Grass Cover Erosion Inwards calculation.
+ /// The object keeping track of update operations.
+ /// The context to obtain the existing entity from.
+ /// The index in the parent collection where
+ /// resides.
+ /// Thrown when either:
+ ///
+ /// - is null
+ /// - is null
+ ///
+ /// When
+ /// does not have a corresponding entity in the database.
+ internal static void Update(this GrassCoverErosionInwardsCalculation calculation, PersistenceRegistry registry, IRingtoetsEntities context, int order)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (registry == null)
+ {
+ throw new ArgumentNullException("registry");
+ }
+
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.GetCorrespondingEntity(
+ context.GrassCoverErosionInwardsCalculationEntities,
+ inputEntity => inputEntity.GrassCoverErosionInwardsCalculationEntityId);
+ entity.Name = calculation.Name;
+ entity.Comments = calculation.Comments;
+ entity.Order = order;
+
+ registry.Register(entity, calculation);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -ra5714fc0488030773fff50dfc82041c6cb9edc2f -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision a5714fc0488030773fff50dfc82041c6cb9edc2f)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -91,6 +91,7 @@
+
@@ -147,6 +148,7 @@
+
@@ -198,6 +200,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationCreateExtensionsTest.cs (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -0,0 +1,91 @@
+// 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.Create.GrassCoverErosionInwards;
+using Application.Ringtoets.Storage.DbContext;
+
+using NUnit.Framework;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create.GrassCoverErosionInwards
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsCalculationCreateExtensionsTest
+ {
+ [Test]
+ public void Create_PersistenceRegistryNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var calculation = new GrassCoverErosionInwardsCalculation();
+
+ // Call
+ TestDelegate call = () => calculation.Create(null, 0);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("registry", paramName);
+ }
+
+ [Test]
+ [TestCase("I have no comments", null, 0)]
+ [TestCase("I do have a comment", "I am comment", 98)]
+ public void Create_ValidCalculation_ReturnEntity(string name, string comment, int order)
+ {
+ // Setup
+ var calculation = new GrassCoverErosionInwardsCalculation
+ {
+ Name = name,
+ Comments = comment
+ };
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, order);
+
+ // Assert
+ Assert.AreEqual(name, entity.Name);
+ Assert.AreEqual(comment, entity.Comments);
+ Assert.AreEqual(order, entity.Order);
+ }
+
+ [Test]
+ public void Create_ValidCalculation_EntityIsRegisteredInPersistenceRegistry()
+ {
+ // Setup
+ var calculation = new GrassCoverErosionInwardsCalculation();
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsCalculationEntity entity = calculation.Create(registry, 0);
+
+ // Assert
+ entity.GrassCoverErosionInwardsCalculationEntityId = 8734;
+ registry.TransferIds();
+ Assert.AreEqual(entity.GrassCoverErosionInwardsCalculationEntityId, calculation.StorageId);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs
===================================================================
diff -u -r53aef346fd0ee3cc79d1f5df9171c476453f2935 -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 53aef346fd0ee3cc79d1f5df9171c476453f2935)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -21,13 +21,18 @@
using System;
using System.Linq;
+
using Application.Ringtoets.Storage.Create;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.TestUtil;
+
using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
+
using NUnit.Framework;
+
using Rhino.Mocks;
+
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
@@ -756,7 +761,6 @@
// Assert
Assert.AreSame(initializedEntity, retrievedEntity);
-
}
#endregion
@@ -796,7 +800,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new AssessmentSection(AssessmentSectionComposition.Dike));
@@ -810,7 +814,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new AssessmentSectionEntity(), null);
@@ -826,7 +830,7 @@
var mocks = new MockRepository();
var model = mocks.StrictMock();
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, model);
@@ -840,7 +844,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new FailureMechanismEntity(), null);
@@ -854,7 +858,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new FailureMechanismSectionEntity(), null);
@@ -868,7 +872,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new TestFailureMechanismSection());
@@ -882,7 +886,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new PipingSectionResultEntity(), null);
@@ -896,7 +900,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new PipingFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -962,28 +966,40 @@
Assert.AreEqual("entity", paramName);
}
- private static DikeProfile CreateDikeProfile()
+ [Test]
+ public void Register_WithNullGrassCoverErosionInwardsCalculation_ThrowsArgumentNullException()
{
- return new DikeProfile(new Point2D(0, 0),
- new[]
- {
- new RoughnessPoint(new Point2D(1, 2), 0.75),
- new RoughnessPoint(new Point2D(3, 4), 0.75)
- },
- new[]
- {
- new Point2D(5, 6),
- new Point2D(7, 8)
- },
- null, new DikeProfile.ConstructionProperties());
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ // Call
+ TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsCalculationEntity(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("model", paramName);
}
[Test]
+ public void Register_WithNullGrassCoverErosionInwardsCalculationEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ // Call
+ TestDelegate test = () => registry.Register(null, new GrassCoverErosionInwardsCalculation());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
public void Register_WithNullGrassCoverErosionInwardsFailureMechanismSectionResult_ThrowsArgumentNullException()
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsSectionResultEntity(), null);
@@ -997,7 +1013,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1011,7 +1027,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new HeightStructuresSectionResultEntity(), null);
@@ -1025,7 +1041,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1039,7 +1055,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new StrengthStabilityLengthwiseConstructionSectionResultEntity(), null);
@@ -1053,7 +1069,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1067,7 +1083,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new TechnicalInnovationSectionResultEntity(), null);
@@ -1081,7 +1097,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new TechnicalInnovationFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1095,7 +1111,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new WaterPressureAsphaltCoverSectionResultEntity(), null);
@@ -1109,7 +1125,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new WaterPressureAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1123,7 +1139,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new ClosingStructureSectionResultEntity(), null);
@@ -1137,7 +1153,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new ClosingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1151,7 +1167,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new MacrostabilityInwardsSectionResultEntity(), null);
@@ -1165,7 +1181,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new MacrostabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1179,7 +1195,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new MacrostabilityOutwardsSectionResultEntity(), null);
@@ -1193,7 +1209,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new MacrostabilityOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1207,7 +1223,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new WaveImpactAsphaltCoverSectionResultEntity(), null);
@@ -1221,7 +1237,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new WaveImpactAsphaltCoverFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1235,7 +1251,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new GrassCoverErosionOutwardsSectionResultEntity(), null);
@@ -1249,7 +1265,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new GrassCoverErosionOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1263,7 +1279,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new GrassCoverSlipOffInwardsSectionResultEntity(), null);
@@ -1277,7 +1293,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new GrassCoverSlipOffInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1291,7 +1307,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new GrassCoverSlipOffOutwardsSectionResultEntity(), null);
@@ -1305,7 +1321,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new GrassCoverSlipOffOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1319,7 +1335,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new MicrostabilitySectionResultEntity(), null);
@@ -1333,7 +1349,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new MicrostabilityFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1347,7 +1363,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new PipingStructureSectionResultEntity(), null);
@@ -1361,7 +1377,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new PipingStructureFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1375,7 +1391,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new DuneErosionSectionResultEntity(), null);
@@ -1389,7 +1405,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new DuneErosionFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1403,7 +1419,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new StabilityStoneCoverSectionResultEntity(), null);
@@ -1417,7 +1433,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new StabilityStoneCoverFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1431,7 +1447,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(new StrengthStabilityPointConstructionSectionResultEntity(), null);
@@ -1445,7 +1461,7 @@
{
// Setup
var registry = new PersistenceRegistry();
-
+
// Call
TestDelegate test = () => registry.Register(null, new StrengthStabilityPointConstructionFailureMechanismSectionResult(new TestFailureMechanismSection()));
@@ -1545,7 +1561,7 @@
var registry = new PersistenceRegistry();
// Call
- TestDelegate test = () => registry.Register(null, new PipingOutput(1,1,1,1,1,1));
+ TestDelegate test = () => registry.Register(null, new PipingOutput(1, 1, 1, 1, 1, 1));
// Assert
var paramName = Assert.Throws(test).ParamName;
@@ -1659,7 +1675,10 @@
var registry = new PersistenceRegistry();
// Call
- TestDelegate test = () => registry.Register(null, new PipingSoilProfile("name", 0, new [] { new PipingSoilLayer(1) }, SoilProfileType.SoilProfile1D, -1));
+ TestDelegate test = () => registry.Register(null, new PipingSoilProfile("name", 0, new[]
+ {
+ new PipingSoilLayer(1)
+ }, SoilProfileType.SoilProfile1D, -1));
// Assert
var paramName = Assert.Throws(test).ParamName;
@@ -1802,7 +1821,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new ProjectEntity
{
ProjectEntityId = storageId
@@ -1823,7 +1842,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new AssessmentSectionEntity
{
AssessmentSectionEntityId = storageId
@@ -1844,7 +1863,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new FailureMechanismEntity
{
FailureMechanismEntityId = storageId
@@ -1865,7 +1884,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new FailureMechanismEntity
{
FailureMechanismEntityId = storageId
@@ -1886,7 +1905,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new FailureMechanismSectionEntity
{
FailureMechanismSectionEntityId = storageId
@@ -1907,7 +1926,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new PipingSectionResultEntity
{
PipingSectionResultEntityId = storageId
@@ -1965,12 +1984,33 @@
}
[Test]
+ public void TransferIds_WithGrassCoverErosionInwardsEntityAddedWithGrassCoverErosionInwardsCalculation_EqualGrassCoverErosionInwardsCalculationEntityIdAndGrassCoverErosionInwardsCalculationStorageId()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ long storageId = new Random(21).Next(1, 4000);
+ var entity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = storageId
+ };
+ var model = new GrassCoverErosionInwardsCalculation();
+ registry.Register(entity, model);
+
+ // Call
+ registry.TransferIds();
+
+ // Assert
+ Assert.AreEqual(storageId, model.StorageId);
+ }
+
+ [Test]
public void TransferIds_WithGrassCoverErosionInwardsSectionResultEntityAddedWithGrassCoverErosionInwardsFailureMechanismSectionResult_EqualGrassCoverErosionInwardsSectionEntityIdAndGrassCoverErosionInwardsFailureMechanismSectionResultStorageId()
{
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new GrassCoverErosionInwardsSectionResultEntity
{
GrassCoverErosionInwardsSectionResultEntityId = storageId
@@ -1991,7 +2031,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new HeightStructuresSectionResultEntity
{
HeightStructuresSectionResultEntityId = storageId
@@ -2012,7 +2052,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new StrengthStabilityLengthwiseConstructionSectionResultEntity
{
StrengthStabilityLengthwiseConstructionSectionResultEntityId = storageId
@@ -2033,7 +2073,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new TechnicalInnovationSectionResultEntity
{
TechnicalInnovationSectionResultEntityId = storageId
@@ -2054,7 +2094,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new WaterPressureAsphaltCoverSectionResultEntity
{
WaterPressureAsphaltCoverSectionResultEntityId = storageId
@@ -2075,7 +2115,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new ClosingStructureSectionResultEntity
{
ClosingStructureSectionResultEntityId = storageId
@@ -2096,7 +2136,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new MacrostabilityInwardsSectionResultEntity
{
MacrostabilityInwardsSectionResultEntityId = storageId
@@ -2117,7 +2157,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new MacrostabilityOutwardsSectionResultEntity
{
MacrostabilityOutwardsSectionResultEntityId = storageId
@@ -2138,7 +2178,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new WaveImpactAsphaltCoverSectionResultEntity
{
WaveImpactAsphaltCoverSectionResultEntityId = storageId
@@ -2159,7 +2199,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new GrassCoverErosionOutwardsSectionResultEntity
{
GrassCoverErosionOutwardsSectionResultEntityId = storageId
@@ -2180,7 +2220,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new GrassCoverSlipOffInwardsSectionResultEntity
{
GrassCoverSlipOffInwardsSectionResultEntityId = storageId
@@ -2201,7 +2241,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new GrassCoverSlipOffOutwardsSectionResultEntity
{
GrassCoverSlipOffOutwardsSectionResultEntityId = storageId
@@ -2222,7 +2262,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new MicrostabilitySectionResultEntity
{
MicrostabilitySectionResultEntityId = storageId
@@ -2243,7 +2283,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new PipingStructureSectionResultEntity
{
PipingStructureSectionResultEntityId = storageId
@@ -2264,7 +2304,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new DuneErosionSectionResultEntity
{
DuneErosionSectionResultEntityId = storageId
@@ -2285,7 +2325,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new StabilityStoneCoverSectionResultEntity
{
StabilityStoneCoverSectionResultEntityId = storageId
@@ -2306,7 +2346,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new StrengthStabilityPointConstructionSectionResultEntity
{
StrengthStabilityPointConstructionSectionResultEntityId = storageId
@@ -2327,7 +2367,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new HydraulicLocationEntity
{
HydraulicLocationEntityId = storageId
@@ -2395,7 +2435,7 @@
{
PipingCalculationOutputEntityId = storageId
};
- var model = new PipingOutput(1,2,3,4,5,6);
+ var model = new PipingOutput(1, 2, 3, 4, 5, 6);
registry.Register(entity, model);
// Call
@@ -2432,7 +2472,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new StochasticSoilModelEntity
{
StochasticSoilModelEntityId = storageId
@@ -2453,7 +2493,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new StochasticSoilProfileEntity
{
StochasticSoilProfileEntityId = storageId
@@ -2474,12 +2514,15 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new SoilProfileEntity
{
SoilProfileEntityId = storageId
};
- var model = new PipingSoilProfile("name", 0, new [] { new PipingSoilLayer(1) }, SoilProfileType.SoilProfile1D, -1);
+ var model = new PipingSoilProfile("name", 0, new[]
+ {
+ new PipingSoilLayer(1)
+ }, SoilProfileType.SoilProfile1D, -1);
registry.Register(entity, model);
// Call
@@ -2495,7 +2538,7 @@
// Setup
var registry = new PersistenceRegistry();
- long storageId = new Random(21).Next(1,4000);
+ long storageId = new Random(21).Next(1, 4000);
var entity = new SoilLayerEntity
{
SoilLayerEntityId = storageId
@@ -2596,7 +2639,10 @@
dbContext.ProjectEntities.Add(orphanedEntity);
dbContext.ProjectEntities.Add(persistentEntity);
- var project = new Project { StorageId = persistentEntity.ProjectEntityId };
+ var project = new Project
+ {
+ StorageId = persistentEntity.ProjectEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, project);
@@ -2629,7 +2675,10 @@
dbContext.AssessmentSectionEntities.Add(orphanedEntity);
dbContext.AssessmentSectionEntities.Add(persistentEntity);
- var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike){ StorageId = persistentEntity.AssessmentSectionEntityId };
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StorageId = persistentEntity.AssessmentSectionEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, assessmentSection);
@@ -2696,7 +2745,10 @@
dbContext.FailureMechanismSectionEntities.Add(orphanedEntity);
dbContext.FailureMechanismSectionEntities.Add(persistentEntity);
- var section = new TestFailureMechanismSection{ StorageId = persistentEntity.FailureMechanismSectionEntityId };
+ var section = new TestFailureMechanismSection
+ {
+ StorageId = persistentEntity.FailureMechanismSectionEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, section);
@@ -2801,7 +2853,7 @@
dbContext.DikeProfileEntities.Add(orphanedEntity);
dbContext.DikeProfileEntities.Add(persistentEntity);
- var section = CreateDikeProfile();
+ DikeProfile section = CreateDikeProfile();
section.StorageId = persistentEntity.DikeProfileEntityId;
var registry = new PersistenceRegistry();
@@ -2817,6 +2869,42 @@
}
[Test]
+ public void RemoveUntouched_GrassCoverErosionInwardsCalculationEntity_OrphanedEntityIsRemovedFromRingtoetsEntities()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ var orphanedEntity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = 1
+ };
+ var persistentEntity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = 2
+ };
+ dbContext.GrassCoverErosionInwardsCalculationEntities.Add(orphanedEntity);
+ dbContext.GrassCoverErosionInwardsCalculationEntities.Add(persistentEntity);
+
+ var calculation = new GrassCoverErosionInwardsCalculation
+ {
+ StorageId = persistentEntity.GrassCoverErosionInwardsCalculationEntityId
+ };
+
+ var registry = new PersistenceRegistry();
+ registry.Register(persistentEntity, calculation);
+
+ // Call
+ registry.RemoveUntouched(dbContext);
+
+ // Assert
+ Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsCalculationEntities.Count());
+ CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsCalculationEntities, persistentEntity);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void RemoveUntouched_GrassCoverErosionInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities()
{
// Setup
@@ -3447,7 +3535,10 @@
dbContext.HydraulicLocationEntities.Add(orphanedEntity);
dbContext.HydraulicLocationEntities.Add(persistentEntity);
- var boundaryLocation = new HydraulicBoundaryLocation(123, "A", 1, 2){ StorageId = persistentEntity.HydraulicLocationEntityId };
+ var boundaryLocation = new HydraulicBoundaryLocation(123, "A", 1, 2)
+ {
+ StorageId = persistentEntity.HydraulicLocationEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, boundaryLocation);
@@ -3480,7 +3571,10 @@
dbContext.CalculationGroupEntities.Add(orphanedEntity);
dbContext.CalculationGroupEntities.Add(persistentEntity);
- var calculationGroup = new CalculationGroup{ StorageId = persistentEntity.CalculationGroupEntityId };
+ var calculationGroup = new CalculationGroup
+ {
+ StorageId = persistentEntity.CalculationGroupEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, calculationGroup);
@@ -3549,7 +3643,7 @@
dbContext.PipingCalculationOutputEntities.Add(orphanedEntity);
dbContext.PipingCalculationOutputEntities.Add(persistentEntity);
- var pipingOutput = new PipingOutput(1,2,3,4,5,6)
+ var pipingOutput = new PipingOutput(1, 2, 3, 4, 5, 6)
{
StorageId = persistentEntity.PipingCalculationOutputEntityId
};
@@ -3586,7 +3680,7 @@
dbContext.PipingSemiProbabilisticOutputEntities.Add(persistentEntity);
var pipingSemiProbabilisticOutput = new PipingSemiProbabilisticOutput(1, 2, 0.3, 4, 5, 0.6, 7,
- 8, 0.9, 1.0, 11, 0.3, 13, 14)
+ 8, 0.9, 1.0, 11, 0.3, 13, 14)
{
StorageId = persistentEntity.PipingSemiProbabilisticOutputEntityId
};
@@ -3622,7 +3716,10 @@
dbContext.StochasticSoilModelEntities.Add(orphanedEntity);
dbContext.StochasticSoilModelEntities.Add(persistentEntity);
- var soilModel = new StochasticSoilModel(123, "A", "B"){ StorageId = persistentEntity.StochasticSoilModelEntityId };
+ var soilModel = new StochasticSoilModel(123, "A", "B")
+ {
+ StorageId = persistentEntity.StochasticSoilModelEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, soilModel);
@@ -3655,7 +3752,10 @@
dbContext.StochasticSoilProfileEntities.Add(orphanedEntity);
dbContext.StochasticSoilProfileEntities.Add(persistentEntity);
- var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 123){ StorageId = persistentEntity.StochasticSoilProfileEntityId };
+ var stochasticSoilProfile = new StochasticSoilProfile(1.0, SoilProfileType.SoilProfile1D, 123)
+ {
+ StorageId = persistentEntity.StochasticSoilProfileEntityId
+ };
var registry = new PersistenceRegistry();
registry.Register(persistentEntity, stochasticSoilProfile);
@@ -3886,5 +3986,21 @@
}
#endregion
+
+ private static DikeProfile CreateDikeProfile()
+ {
+ return new DikeProfile(new Point2D(0, 0),
+ new[]
+ {
+ new RoughnessPoint(new Point2D(1, 2), 0.75),
+ new RoughnessPoint(new Point2D(3, 4), 0.75)
+ },
+ new[]
+ {
+ new Point2D(5, 6),
+ new Point2D(7, 8)
+ },
+ null, new DikeProfile.ConstructionProperties());
+ }
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -0,0 +1,55 @@
+// 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 Application.Ringtoets.Storage.DbContext;
+
+using NUnit.Framework;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+using Application.Ringtoets.Storage.Read.GrassCoverErosionInwards;
+
+namespace Application.Ringtoets.Storage.Test.Read.GrassCoverErosionInwards
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsCalculationEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_ValidEntity_ReturnCalculation()
+ {
+ // Setup
+ var entity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = 457,
+ Name = "sodhfksn",
+ Comments = "s;ohfgwjo5p09u"
+ };
+
+ // Call
+ GrassCoverErosionInwardsCalculation calculation = entity.Read();
+
+ // Assert
+ Assert.AreEqual(entity.GrassCoverErosionInwardsCalculationEntityId, calculation.StorageId);
+ Assert.AreEqual(entity.Name, calculation.Name);
+ Assert.AreEqual(entity.Comments, calculation.Comments);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationUpdateExtensionsTest.cs (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -0,0 +1,168 @@
+// 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 Application.Ringtoets.Storage.Exceptions;
+using Application.Ringtoets.Storage.TestUtil;
+using Application.Ringtoets.Storage.Update.GrassCoverErosionInwards;
+
+using NUnit.Framework;
+
+using Rhino.Mocks;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Test.Update.GrassCoverErosionInwards
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsCalculationUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_PersistenceRegistryNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var ringtoetsEntities = mocks.Stub();
+ mocks.ReplayAll();
+
+ var calculation = new GrassCoverErosionInwardsCalculation();
+
+ // Call
+ TestDelegate call = () => calculation.Update(null, ringtoetsEntities, 0);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("registry", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_RingtoetsEntitiesNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ var calculation = new GrassCoverErosionInwardsCalculation();
+
+ // Call
+ TestDelegate call = () => calculation.Update(registry, null, 0);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_RingtoetsEntitiesHasNoCalculations_ThrowsEntityNotFoundException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ var registry = new PersistenceRegistry();
+ var calculation = new GrassCoverErosionInwardsCalculation();
+
+ // Call
+ TestDelegate call = () => calculation.Update(registry, ringtoetsEntities, 0);
+
+ // Assert
+ Assert.Throws(call);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_RingtoetsEntitiesHasNoMatchingCalculation_ThrowsEntityNotFoundException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ ringtoetsEntities.GrassCoverErosionInwardsCalculationEntities.Add(new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = 1
+ });
+
+ var registry = new PersistenceRegistry();
+ var calculation = new GrassCoverErosionInwardsCalculation
+ {
+ StorageId = 2
+ };
+
+ // Call
+ TestDelegate call = () => calculation.Update(registry, ringtoetsEntities, 0);
+
+ // Assert
+ Assert.Throws(call);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_RingtoetsEntitiesWithMatchingCalculation_UpdateAndRegisterEntity()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ var calculation = new GrassCoverErosionInwardsCalculation
+ {
+ StorageId = 2,
+ Name = "Calculation yeah!",
+ Comments = "Comments whoo!"
+ };
+
+ var entity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = calculation.StorageId,
+ Name = "A",
+ Comments = "B",
+ Order = 3
+ };
+ var orphanedEntity = new GrassCoverErosionInwardsCalculationEntity
+ {
+ GrassCoverErosionInwardsCalculationEntityId = 564
+ };
+ ringtoetsEntities.GrassCoverErosionInwardsCalculationEntities.Add(entity);
+ ringtoetsEntities.GrassCoverErosionInwardsCalculationEntities.Add(orphanedEntity);
+
+ var registry = new PersistenceRegistry();
+
+ const int order = 86;
+ // Call
+ calculation.Update(registry, ringtoetsEntities, order);
+
+ // Assert
+ Assert.AreEqual(calculation.Name, entity.Name);
+ Assert.AreEqual(calculation.Comments, entity.Comments);
+ Assert.AreEqual(order, entity.Order);
+
+ registry.RemoveUntouched(ringtoetsEntities);
+ CollectionAssert.Contains(ringtoetsEntities.GrassCoverErosionInwardsCalculationEntities, entity);
+ CollectionAssert.DoesNotContain(ringtoetsEntities.GrassCoverErosionInwardsCalculationEntities, orphanedEntity);
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs
===================================================================
diff -u -rdf02e9274a94d8763da204833a4d93f984e242c6 -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision df02e9274a94d8763da204833a4d93f984e242c6)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -20,6 +20,8 @@
// All rights reserved.
using Core.Common.Base;
+using Core.Common.Base.Storage;
+
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.Probability;
using Ringtoets.GrassCoverErosionInwards.Data.Properties;
@@ -29,7 +31,7 @@
///
/// This class holds information about a calculation for the .
///
- public class GrassCoverErosionInwardsCalculation : Observable, ICalculation
+ public class GrassCoverErosionInwardsCalculation : Observable, ICalculation, IStorable
{
///
/// Creates a new instance of .
@@ -62,6 +64,17 @@
}
}
+ public long StorageId { get; set; }
+
+ ///
+ /// Returns a string that represents the current object.
+ ///
+ /// The name of this calculation.
+ public override string ToString()
+ {
+ return Name;
+ }
+
public void ClearOutput()
{
Output = null;
@@ -81,14 +94,5 @@
{
return Output;
}
-
- ///
- /// Returns a string that represents the current object.
- ///
- /// The name of this calculation.
- public override string ToString()
- {
- return Name;
- }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs
===================================================================
diff -u -ra761c195a25ca9f764909e8064e933b9b5c57e01 -r5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision a761c195a25ca9f764909e8064e933b9b5c57e01)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision 5da102ed42420b0272dfd2ecdd5aaa3a9ebd251c)
@@ -20,6 +20,8 @@
// All rights reserved.
using Core.Common.Base;
+using Core.Common.Base.Storage;
+
using NUnit.Framework;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.Probability;
@@ -39,12 +41,15 @@
// Assert
Assert.IsInstanceOf(calculation);
Assert.IsInstanceOf(calculation);
+ Assert.IsInstanceOf(calculation);
+
Assert.AreEqual("Nieuwe berekening", calculation.Name);
Assert.IsNotNull(calculation.InputParameters);
Assert.IsFalse(calculation.HasOutput);
Assert.IsNull(calculation.Comments);
Assert.IsNull(calculation.Output);
Assert.IsNull(calculation.InputParameters.DikeProfile);
+ Assert.AreEqual(0, calculation.StorageId);
}
[Test]