Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r21d94a2cc5a3a916d02a441f80414455b80d85dc -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 21d94a2cc5a3a916d02a441f80414455b80d85dc)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -57,6 +57,7 @@
+
@@ -293,6 +294,7 @@
+
@@ -361,6 +363,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GeneralGrassCoverErosionInwardsInputCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GeneralGrassCoverErosionInwardsInputCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GeneralGrassCoverErosionInwardsInputCreateExtensions.cs (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -0,0 +1,60 @@
+// 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
+{
+ ///
+ /// Extension methods for related
+ /// to creating a .
+ ///
+ internal static class GeneralGrassCoverErosionInwardsInputCreateExtensions
+ {
+ ///
+ /// Creates a based
+ /// on the information of the .
+ ///
+ /// The general calculation input for Grass Cover Erosion Inwards
+ /// to create a database entity for.
+ /// The object keeping track of create operations.
+ /// A new .
+ /// Thrown when is null.
+ internal static GrassCoverErosionInwardsFailureMechanismMetaEntity Create(this GeneralGrassCoverErosionInwardsInput input, PersistenceRegistry registry)
+ {
+ if (registry == null)
+ {
+ throw new ArgumentNullException("registry");
+ }
+
+ var entity = new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ N = input.N
+ };
+ registry.Register(entity, input);
+ return entity;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs
===================================================================
diff -u -r8a15fe6e429a0f177f25defaf1851c9963374dbe -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 8a15fe6e429a0f177f25defaf1851c9963374dbe)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -54,6 +54,7 @@
private readonly Dictionary failureMechanisms = new Dictionary(new ReferenceEqualityComparer());
private readonly Dictionary failureMechanismSections = new Dictionary();
private readonly Dictionary pipingFailureMechanismSectionResults = new Dictionary();
+ private readonly Dictionary generalGrassCoverErosionInwardsInputs = new Dictionary();
private readonly Dictionary grassCoverErosionInwardsFailureMechanismSectionResults = new Dictionary();
private readonly Dictionary heightStructuresFailureMechanismSectionResults = new Dictionary();
private readonly Dictionary strengthStabilityLengthwiseConstructionFailureMechanismSectionResults = new Dictionary();
@@ -121,6 +122,22 @@
/// 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(GrassCoverErosionInwardsFailureMechanismMetaEntity entity, GeneralGrassCoverErosionInwardsInput model)
+ {
+ Register(generalGrassCoverErosionInwardsInputs, 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:
@@ -864,6 +881,11 @@
pipingFailureMechanismSectionResults[entity].StorageId = entity.PipingSectionResultEntityId;
}
+ foreach (var entity in generalGrassCoverErosionInwardsInputs.Keys)
+ {
+ generalGrassCoverErosionInwardsInputs[entity].StorageId = entity.GrassCoverErosionInwardsFailureMechanismMetaEntityId;
+ }
+
foreach (var entity in grassCoverErosionInwardsFailureMechanismSectionResults.Keys)
{
grassCoverErosionInwardsFailureMechanismSectionResults[entity].StorageId = entity.GrassCoverErosionInwardsSectionResultEntityId;
@@ -1065,7 +1087,7 @@
var orphanedPipingSectionResultEntities = new List();
foreach (PipingSectionResultEntity pipingSectionResultEntity in dbContext.PipingSectionResultEntities
- .Where(e => e.PipingSectionResultEntityId > 0))
+ .Where(e => e.PipingSectionResultEntityId > 0))
{
if (!pipingFailureMechanismSectionResults.ContainsKey(pipingSectionResultEntity))
{
@@ -1074,9 +1096,20 @@
}
dbContext.PipingSectionResultEntities.RemoveRange(orphanedPipingSectionResultEntities);
+ var orphanedGrassCoverErosionInwardsFailureMechanismMetaEntities = new List();
+ foreach (GrassCoverErosionInwardsFailureMechanismMetaEntity inputEntity in dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities
+ .Where(e => e.GrassCoverErosionInwardsFailureMechanismMetaEntityId > 0))
+ {
+ if (!generalGrassCoverErosionInwardsInputs.ContainsKey(inputEntity))
+ {
+ orphanedGrassCoverErosionInwardsFailureMechanismMetaEntities.Add(inputEntity);
+ }
+ }
+ dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.RemoveRange(orphanedGrassCoverErosionInwardsFailureMechanismMetaEntities);
+
var orphanedGrassCoverErosionInwardsSectionResultEntities = new List();
foreach (GrassCoverErosionInwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverErosionInwardsSectionResultEntities
- .Where(e => e.GrassCoverErosionInwardsSectionResultEntityId > 0))
+ .Where(e => e.GrassCoverErosionInwardsSectionResultEntityId > 0))
{
if (!grassCoverErosionInwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1087,7 +1120,7 @@
var orphanedHeightStructuresSectionResultEntities = new List();
foreach (HeightStructuresSectionResultEntity sectionResultEntity in dbContext.HeightStructuresSectionResultEntities
- .Where(e => e.HeightStructuresSectionResultEntityId > 0))
+ .Where(e => e.HeightStructuresSectionResultEntityId > 0))
{
if (!heightStructuresFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1098,7 +1131,7 @@
var orphanedStrengthStabilityLengthwiseConstructionSectionResultEntities = new List();
foreach (StrengthStabilityLengthwiseConstructionSectionResultEntity sectionResultEntity in dbContext.StrengthStabilityLengthwiseConstructionSectionResultEntities
- .Where(e => e.StrengthStabilityLengthwiseConstructionSectionResultEntityId > 0))
+ .Where(e => e.StrengthStabilityLengthwiseConstructionSectionResultEntityId > 0))
{
if (!strengthStabilityLengthwiseConstructionFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1109,7 +1142,7 @@
var orphanedTechnicalInnovationSectionResultEntities = new List();
foreach (TechnicalInnovationSectionResultEntity sectionResultEntity in dbContext.TechnicalInnovationSectionResultEntities
- .Where(e => e.TechnicalInnovationSectionResultEntityId > 0))
+ .Where(e => e.TechnicalInnovationSectionResultEntityId > 0))
{
if (!technicalInnovationFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1120,7 +1153,7 @@
var orphanedWaterPressureAsphaltCoverSectionResultEntities = new List();
foreach (WaterPressureAsphaltCoverSectionResultEntity sectionResultEntity in dbContext.WaterPressureAsphaltCoverSectionResultEntities
- .Where(e => e.WaterPressureAsphaltCoverSectionResultEntityId > 0))
+ .Where(e => e.WaterPressureAsphaltCoverSectionResultEntityId > 0))
{
if (!waterPressureAsphaltCoverFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1131,7 +1164,7 @@
var orphanedClosingStructureSectionResultEntities = new List();
foreach (ClosingStructureSectionResultEntity sectionResultEntity in dbContext.ClosingStructureSectionResultEntities
- .Where(e => e.ClosingStructureSectionResultEntityId > 0))
+ .Where(e => e.ClosingStructureSectionResultEntityId > 0))
{
if (!closingStructureFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1142,7 +1175,7 @@
var orphanedMacrostabilityInwardsSectionResultEntities = new List();
foreach (MacrostabilityInwardsSectionResultEntity sectionResultEntity in dbContext.MacrostabilityInwardsSectionResultEntities
- .Where(e => e.MacrostabilityInwardsSectionResultEntityId > 0))
+ .Where(e => e.MacrostabilityInwardsSectionResultEntityId > 0))
{
if (!macrostabilityInwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1153,7 +1186,7 @@
var orphanedMacrostabilityOutwardsSectionResultEntities = new List();
foreach (MacrostabilityOutwardsSectionResultEntity sectionResultEntity in dbContext.MacrostabilityOutwardsSectionResultEntities
- .Where(e => e.MacrostabilityOutwardsSectionResultEntityId > 0))
+ .Where(e => e.MacrostabilityOutwardsSectionResultEntityId > 0))
{
if (!macrostabilityOutwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1164,7 +1197,7 @@
var orphanedWaveImpactAsphaltCoverSectionResultEntities = new List();
foreach (WaveImpactAsphaltCoverSectionResultEntity sectionResultEntity in dbContext.WaveImpactAsphaltCoverSectionResultEntities
- .Where(e => e.WaveImpactAsphaltCoverSectionResultEntityId > 0))
+ .Where(e => e.WaveImpactAsphaltCoverSectionResultEntityId > 0))
{
if (!waveImpactAsphaltCoverFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1175,7 +1208,7 @@
var orphanedGrassCoverErosionOutwardsSectionResultEntities = new List();
foreach (GrassCoverErosionOutwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverErosionOutwardsSectionResultEntities
- .Where(e => e.GrassCoverErosionOutwardsSectionResultEntityId > 0))
+ .Where(e => e.GrassCoverErosionOutwardsSectionResultEntityId > 0))
{
if (!grassCoverErosionOutwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1186,7 +1219,7 @@
var orphanedGrassCoverSlipOffInwardsSectionResultEntities = new List();
foreach (GrassCoverSlipOffInwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverSlipOffInwardsSectionResultEntities
- .Where(e => e.GrassCoverSlipOffInwardsSectionResultEntityId > 0))
+ .Where(e => e.GrassCoverSlipOffInwardsSectionResultEntityId > 0))
{
if (!grassCoverSlipOffInwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1197,7 +1230,7 @@
var orphanedGrassCoverSlipOffOutwardsSectionResultEntities = new List();
foreach (GrassCoverSlipOffOutwardsSectionResultEntity sectionResultEntity in dbContext.GrassCoverSlipOffOutwardsSectionResultEntities
- .Where(e => e.GrassCoverSlipOffOutwardsSectionResultEntityId > 0))
+ .Where(e => e.GrassCoverSlipOffOutwardsSectionResultEntityId > 0))
{
if (!grassCoverSlipOffOutwardsFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1208,7 +1241,7 @@
var orphanedMicrostabilitySectionResultEntities = new List();
foreach (MicrostabilitySectionResultEntity sectionResultEntity in dbContext.MicrostabilitySectionResultEntities
- .Where(e => e.MicrostabilitySectionResultEntityId > 0))
+ .Where(e => e.MicrostabilitySectionResultEntityId > 0))
{
if (!microstabilityFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1219,7 +1252,7 @@
var orphanedPipingStructureSectionResultEntities = new List();
foreach (PipingStructureSectionResultEntity sectionResultEntity in dbContext.PipingStructureSectionResultEntities
- .Where(e => e.PipingStructureSectionResultEntityId > 0))
+ .Where(e => e.PipingStructureSectionResultEntityId > 0))
{
if (!pipingStructureFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1230,7 +1263,7 @@
var orphanedDuneErosionSectionResultEntities = new List();
foreach (DuneErosionSectionResultEntity sectionResultEntity in dbContext.DuneErosionSectionResultEntities
- .Where(e => e.DuneErosionSectionResultEntityId > 0))
+ .Where(e => e.DuneErosionSectionResultEntityId > 0))
{
if (!duneErosionFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1241,7 +1274,7 @@
var orphanedStabilityStoneCoverSectionResultEntities = new List();
foreach (StabilityStoneCoverSectionResultEntity sectionResultEntity in dbContext.StabilityStoneCoverSectionResultEntities
- .Where(e => e.StabilityStoneCoverSectionResultEntityId > 0))
+ .Where(e => e.StabilityStoneCoverSectionResultEntityId > 0))
{
if (!stabilityStoneCoverFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
@@ -1252,7 +1285,7 @@
var orphanedStrengthStabilityPointConstructionSectionResultEntities = new List();
foreach (StrengthStabilityPointConstructionSectionResultEntity sectionResultEntity in dbContext.StrengthStabilityPointConstructionSectionResultEntities
- .Where(e => e.StrengthStabilityPointConstructionSectionResultEntityId > 0))
+ .Where(e => e.StrengthStabilityPointConstructionSectionResultEntityId > 0))
{
if (!strengthStabilityPointConstructionFailureMechanismSectionResults.ContainsKey(sectionResultEntity))
{
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensions.cs (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -0,0 +1,49 @@
+// 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
+{
+ ///
+ /// This class defines extension methods for read operations for a
+ /// based on the .
+ ///
+ internal static class GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensions
+ {
+ ///
+ /// Reads the
+ /// and use the information to construct a .
+ ///
+ /// The
+ /// to create for.
+ /// A new .
+ internal static GeneralGrassCoverErosionInwardsInput Read(this GrassCoverErosionInwardsFailureMechanismMetaEntity entity)
+ {
+ return new GeneralGrassCoverErosionInwardsInput
+ {
+ N = entity.N
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismSectionUpdateExtensions.cs
===================================================================
diff -u -r5b3736b5350315a520f72c90222af261ea651019 -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismSectionUpdateExtensions.cs (.../FailureMechanismSectionUpdateExtensions.cs) (revision 5b3736b5350315a520f72c90222af261ea651019)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/FailureMechanismSectionUpdateExtensions.cs (.../FailureMechanismSectionUpdateExtensions.cs) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -30,6 +30,10 @@
namespace Application.Ringtoets.Storage.Update
{
+ ///
+ /// Extension methods for related to updating a
+ /// .
+ ///
internal static class FailureMechanismSectionUpdateExtensions
{
///
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GeneralGrassCoverErosionInwardsInputUpdateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GeneralGrassCoverErosionInwardsInputUpdateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GeneralGrassCoverErosionInwardsInputUpdateExtensions.cs (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -0,0 +1,72 @@
+// 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.Common.Data.FailureMechanism;
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Update
+{
+ ///
+ /// Extension methods for related
+ /// to updating a .
+ ///
+ internal static class GeneralGrassCoverErosionInwardsInputUpdateExtensions
+ {
+ ///
+ /// Updates a in
+ /// the database based on the information of the .
+ ///
+ /// The general input for a Grass Cover Erosion Inwards failure mechanism.
+ /// The object keeping track of update operations.
+ /// The context to obtain the existing entity from.
+ /// Thrown when either:
+ ///
+ /// - is null
+ /// - is null
+ ///
+ /// When
+ /// does not have a corresponding entity in the database.
+ internal static void Update(this GeneralGrassCoverErosionInwardsInput input, PersistenceRegistry registry, IRingtoetsEntities context)
+ {
+ if (context == null)
+ {
+ throw new ArgumentNullException("context");
+ }
+ if (registry == null)
+ {
+ throw new ArgumentNullException("registry");
+ }
+
+ GrassCoverErosionInwardsFailureMechanismMetaEntity entity = input.GetCorrespondingEntity(
+ context.GrassCoverErosionInwardsFailureMechanismMetaEntities,
+ inputEntity => inputEntity.GrassCoverErosionInwardsFailureMechanismMetaEntityId);
+ entity.N = input.N;
+
+ registry.Register(entity, input);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r8ed108b83f575f6cb7dc1b89224606894a4bcb7a -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 8ed108b83f575f6cb7dc1b89224606894a4bcb7a)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -85,6 +85,7 @@
+
@@ -142,6 +143,7 @@
+
@@ -188,6 +190,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GeneralGrassCoverErosionInwardsInputCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GeneralGrassCoverErosionInwardsInputCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GeneralGrassCoverErosionInwardsInputCreateExtensionsTest.cs (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -0,0 +1,66 @@
+using System;
+
+using Application.Ringtoets.Storage.Create;
+using Application.Ringtoets.Storage.DbContext;
+
+using NUnit.Framework;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create
+{
+ [TestFixture]
+ public class GeneralGrassCoverErosionInwardsInputCreateExtensionsTest
+ {
+ [Test]
+ public void Create_PersistenceRegistryNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var input = new GeneralGrassCoverErosionInwardsInput();
+
+ // Call
+ TestDelegate call = () => input.Create(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("registry", paramName);
+ }
+
+ [Test]
+ public void Create_ValidGeneralInput_ReturnEntity(
+ [Random(0, 20, 1)]int n)
+ {
+ // Setup
+ var input = new GeneralGrassCoverErosionInwardsInput
+ {
+ N = n
+ };
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsFailureMechanismMetaEntity entity = input.Create(registry);
+
+ // Assert
+ Assert.AreEqual(n, entity.N);
+ }
+
+ [Test]
+ public void Create_ValidGeneralInput_RegisterEntityToRegistry()
+ {
+ // Setup
+ var input = new GeneralGrassCoverErosionInwardsInput
+ {
+ N = 1
+ };
+ var registry = new PersistenceRegistry();
+
+ // Call
+ GrassCoverErosionInwardsFailureMechanismMetaEntity entity = input.Create(registry);
+
+ // Assert
+ entity.GrassCoverErosionInwardsFailureMechanismMetaEntityId = 23456789;
+ registry.TransferIds();
+ Assert.AreEqual(entity.GrassCoverErosionInwardsFailureMechanismMetaEntityId, input.StorageId);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs
===================================================================
diff -u -rce94b8228bc7e51779b3754217580f13cb35e475 -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision ce94b8228bc7e51779b3754217580f13cb35e475)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -906,6 +906,34 @@
}
[Test]
+ public void Register_WithNullGeneralGrassCoverErosionInwardsInput_ThrowsArgumentNullException()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ // Call
+ TestDelegate test = () => registry.Register(new GrassCoverErosionInwardsFailureMechanismMetaEntity(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("model", paramName);
+ }
+
+ [Test]
+ public void Register_WithNullGrassCoverErosionInwardsFailureMechanismMetaEntity_ThrowsArgumentNullException()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ // Call
+ TestDelegate test = () => registry.Register(null, new GeneralGrassCoverErosionInwardsInput());
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("entity", paramName);
+ }
+
+ [Test]
public void Register_WithNullGrassCoverErosionInwardsFailureMechanismSectionResult_ThrowsArgumentNullException()
{
// Setup
@@ -1850,6 +1878,27 @@
}
[Test]
+ public void TransferIds_WithGrassCoverErosionInwardsFailureMechanismMetaEntityAddedWithGeneralGrassCoverErosionInwardsInput_EqualGrassCoverErosionInwardsFailureMechanismMetaEntityIdAndGeneralGrassCoverErosionInwardsInputStorageId()
+ {
+ // Setup
+ var registry = new PersistenceRegistry();
+
+ long storageId = new Random(21).Next(1, 4000);
+ var entity = new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ GrassCoverErosionInwardsFailureMechanismMetaEntityId = storageId
+ };
+ var model = new GeneralGrassCoverErosionInwardsInput();
+ registry.Register(entity, model);
+
+ // Call
+ registry.TransferIds();
+
+ // Assert
+ Assert.AreEqual(storageId, model.StorageId);
+ }
+
+ [Test]
public void TransferIds_WithGrassCoverErosionInwardsSectionResultEntityAddedWithGrassCoverErosionInwardsFailureMechanismSectionResult_EqualGrassCoverErosionInwardsSectionEntityIdAndGrassCoverErosionInwardsFailureMechanismSectionResultStorageId()
{
// Setup
@@ -2632,6 +2681,42 @@
}
[Test]
+ public void RemoveUntouched_GrassCoverErosionInwardsFailureMechanismMetaEntity_OrphanedEntityIsRemovedFromRingtoetsEntities()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ IRingtoetsEntities dbContext = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ var orphanedEntity = new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ GrassCoverErosionInwardsFailureMechanismMetaEntityId = 1
+ };
+ var persistentEntity = new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ GrassCoverErosionInwardsFailureMechanismMetaEntityId = 2
+ };
+ dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.Add(orphanedEntity);
+ dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.Add(persistentEntity);
+
+ var section = new GeneralGrassCoverErosionInwardsInput
+ {
+ StorageId = persistentEntity.GrassCoverErosionInwardsFailureMechanismMetaEntityId
+ };
+
+ var registry = new PersistenceRegistry();
+ registry.Register(persistentEntity, section);
+
+ // Call
+ registry.RemoveUntouched(dbContext);
+
+ // Assert
+ Assert.AreEqual(1, dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities.Count());
+ CollectionAssert.Contains(dbContext.GrassCoverErosionInwardsFailureMechanismMetaEntities, persistentEntity);
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void RemoveUntouched_GrassCoverErosionInwardsSectionResultEntity_OrphanedEntityIsRemovedFromRingtoetsEntities()
{
// Setup
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensionsTest.cs (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -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 Application.Ringtoets.Storage.Read;
+
+using NUnit.Framework;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsFailureMechanismMetaEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_ValidEntity_ReturnGeneralGrassCoverErosionInwardsInput(
+ [Random(0, 20, 1)]int n)
+ {
+ // Setup
+ var entity = new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ N = n
+ };
+
+ // Call
+ GeneralGrassCoverErosionInwardsInput generalInput = entity.Read();
+
+ // Assert
+ Assert.AreEqual(n, generalInput.N);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GeneralGrassCoverErosionInwardsInputUpdateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GeneralGrassCoverErosionInwardsInputUpdateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GeneralGrassCoverErosionInwardsInputUpdateExtensionsTest.cs (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -0,0 +1,162 @@
+// 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;
+
+using NUnit.Framework;
+
+using Rhino.Mocks;
+
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Application.Ringtoets.Storage.Test.Update
+{
+ [TestFixture]
+ public class GeneralGrassCoverErosionInwardsInputUpdateExtensionsTest
+ {
+ [Test]
+ public void Update_RingtoetsEntitiesIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var input = new GeneralGrassCoverErosionInwardsInput();
+ var registry = new PersistenceRegistry();
+
+ // Call
+ TestDelegate call = () => input.Update(registry, null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("context", paramName);
+ }
+
+ [Test]
+ public void Update_PersistenceRegistryIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var ringtoetsEntities = mocks.Stub();
+ mocks.ReplayAll();
+
+ var input = new GeneralGrassCoverErosionInwardsInput();
+
+ // Call
+ TestDelegate call = () => input.Update(null, ringtoetsEntities);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("registry", paramName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithoutGrassCoverErosionInwardsFailureMechanismMetaEntity_EntityNotFoundException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var ringtoetsEntities = mocks.Stub();
+ mocks.ReplayAll();
+
+ var registry = new PersistenceRegistry();
+
+ var input = new GeneralGrassCoverErosionInwardsInput();
+
+ // Call
+ TestDelegate call = () => input.Update(registry, ringtoetsEntities);
+
+ // Assert
+ var expectedMessage = String.Format("Het object 'GrassCoverErosionInwardsFailureMechanismMetaEntity' met id '{0}' is niet gevonden.", 0);
+ EntityNotFoundException exception = Assert.Throws(call);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ public void Update_ContextWithNoGrassCoverErosionInwardsFailureMechanismMetaEntityWithId_EntityNotFoundException()
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ var storageId = 1;
+ var input = new GeneralGrassCoverErosionInwardsInput
+ {
+ StorageId = storageId
+ };
+
+ ringtoetsEntities.GrassCoverErosionInwardsFailureMechanismMetaEntities.Add(new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ FailureMechanismEntityId = 2
+ });
+
+ // Call
+ TestDelegate test = () => input.Update(new PersistenceRegistry(), ringtoetsEntities);
+
+ // Assert
+ var expectedMessage = String.Format("Het object 'GrassCoverErosionInwardsFailureMechanismMetaEntity' met id '{0}' is niet gevonden.", storageId);
+ EntityNotFoundException exception = Assert.Throws(test);
+ Assert.AreEqual(expectedMessage, exception.Message);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Update_ContextWithGrassCoverErosionInwardsFailureMechanismMetaEntity_PropertiesUpdated(
+ [Random(1, 20, 1)]int n)
+ {
+ // Setup
+ MockRepository mocks = new MockRepository();
+ var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks);
+ mocks.ReplayAll();
+
+ const int storageId = 1;
+ var input = new GeneralGrassCoverErosionInwardsInput
+ {
+ N = n,
+ StorageId = storageId
+ };
+
+ var entity = new GrassCoverErosionInwardsFailureMechanismMetaEntity
+ {
+ GrassCoverErosionInwardsFailureMechanismMetaEntityId = input.StorageId,
+ };
+ ringtoetsEntities.GrassCoverErosionInwardsFailureMechanismMetaEntities.Add(entity);
+
+ var registry = new PersistenceRegistry();
+
+ // Call
+ input.Update(registry, ringtoetsEntities);
+
+ // Assert
+ Assert.AreEqual(n, entity.N);
+
+ registry.RemoveUntouched(ringtoetsEntities);
+ CollectionAssert.Contains(ringtoetsEntities.GrassCoverErosionInwardsFailureMechanismMetaEntities, entity);
+
+ mocks.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GeneralGrassCoverErosionInwardsInput.cs
===================================================================
diff -u -r454c559173fa5069917f2aab1a4d65ddbb019b3a -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GeneralGrassCoverErosionInwardsInput.cs (.../GeneralGrassCoverErosionInwardsInput.cs) (revision 454c559173fa5069917f2aab1a4d65ddbb019b3a)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GeneralGrassCoverErosionInwardsInput.cs (.../GeneralGrassCoverErosionInwardsInput.cs) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -20,7 +20,10 @@
// All rights reserved.
using System;
+
using Core.Common.Base.Data;
+using Core.Common.Base.Storage;
+
using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.GrassCoverErosionInwards.Data.Properties;
@@ -29,7 +32,7 @@
///
/// Class that holds all the static grass cover erosion inwards calculation input parameters.
///
- public class GeneralGrassCoverErosionInwardsInput
+ public class GeneralGrassCoverErosionInwardsInput : IStorable
{
private int n;
@@ -42,24 +45,24 @@
CriticalOvertoppingModelFactor = 1.0;
FbFactor = new NormalDistribution(2)
{
- Mean = (RoundedDouble) 4.75,
- StandardDeviation = (RoundedDouble) 0.5
+ Mean = (RoundedDouble)4.75,
+ StandardDeviation = (RoundedDouble)0.5
};
FnFactor = new NormalDistribution(2)
{
- Mean = (RoundedDouble) 2.6,
- StandardDeviation = (RoundedDouble) 0.35
+ Mean = (RoundedDouble)2.6,
+ StandardDeviation = (RoundedDouble)0.35
};
OvertoppingModelFactor = 1.0;
FrunupModelFactor = new NormalDistribution(2)
{
- Mean = (RoundedDouble) 1,
- StandardDeviation = (RoundedDouble) 0.07
+ Mean = (RoundedDouble)1,
+ StandardDeviation = (RoundedDouble)0.07
};
FshallowModelFactor = new NormalDistribution(2)
{
- Mean = (RoundedDouble) 0.92,
- StandardDeviation = (RoundedDouble) 0.24
+ Mean = (RoundedDouble)0.92,
+ StandardDeviation = (RoundedDouble)0.24
};
}
@@ -88,6 +91,8 @@
#endregion
+ public long StorageId { get; set; }
+
#region Factors
///
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GeneralGrassCoverErosionInwardsInputTest.cs
===================================================================
diff -u -r454c559173fa5069917f2aab1a4d65ddbb019b3a -r02f18ee78d2e0520b90c8bfcb13f563e7d41365a
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GeneralGrassCoverErosionInwardsInputTest.cs (.../GeneralGrassCoverErosionInwardsInputTest.cs) (revision 454c559173fa5069917f2aab1a4d65ddbb019b3a)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GeneralGrassCoverErosionInwardsInputTest.cs (.../GeneralGrassCoverErosionInwardsInputTest.cs) (revision 02f18ee78d2e0520b90c8bfcb13f563e7d41365a)
@@ -21,6 +21,7 @@
using System;
using Core.Common.Base.Data;
+using Core.Common.Base.Storage;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.Probabilistics;
@@ -38,6 +39,7 @@
var inputParameters = new GeneralGrassCoverErosionInwardsInput();
// Assert
+ Assert.IsInstanceOf(inputParameters);
Assert.AreEqual(2, inputParameters.N);
var fbFactor = new NormalDistribution(2)
@@ -70,6 +72,7 @@
Assert.AreEqual(1, inputParameters.CriticalOvertoppingModelFactor);
Assert.AreEqual(1, inputParameters.OvertoppingModelFactor);
+ Assert.AreEqual(0, inputParameters.StorageId);
}
[Test]