Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs =================================================================== diff -u -r01ff2c58c13df8f42661ae3e446dc2caaa94247e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs) (revision 01ff2c58c13df8f42661ae3e446dc2caaa94247e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismCreateExtensions.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -45,10 +45,9 @@ var entity = mechanism.Create(FailureMechanismType.GrassRevetmentTopErosionAndInwards, registry); AddEntitiesForGeneralInput(mechanism, registry, entity); AddEntitiesForDikeProfiles(mechanism, registry, entity); + entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); AddEntitiesForSectionResults(mechanism.SectionResults, registry); - entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); - registry.Register(entity, mechanism); return entity; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u -r01ff2c58c13df8f42661ae3e446dc2caaa94247e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs) (revision 01ff2c58c13df8f42661ae3e446dc2caaa94247e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensions.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -51,6 +51,10 @@ LayerOne = Convert.ToByte(result.AssessmentLayerOne), LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal() }; + if (result.Calculation != null) + { + sectionResultEntity.GrassCoverErosionInwardsCalculationEntity = registry.Get(result.Calculation); + } registry.Register(sectionResultEntity, result); return sectionResultEntity; Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs =================================================================== diff -u -r47c3d018102688c579d1450a890f2c3691bcbcf2 -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 47c3d018102688c579d1450a890f2c3691bcbcf2) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/PersistenceRegistry.cs (.../PersistenceRegistry.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -757,6 +757,18 @@ } /// + /// Checks whether a create or update operations has been registered for the given + /// . + /// + /// The to check for. + /// true if the was registered before, false otherwise. + /// Thrown when is null. + internal bool Contains(GrassCoverErosionInwardsCalculation model) + { + return ContainsValue(grassCoverErosionInwardsCalculations, model); + } + + /// /// Obtains the which was registered for /// the given . /// @@ -876,6 +888,23 @@ } /// + /// Obtains the which was + /// registered for the given . + /// + /// The for + /// which a read/update operation has been registered. + /// The constructed . + /// Thrown when is null. + /// Thrown when no create/update operation + /// has been registered for . + /// Use to find out + /// whether a create/update operation has been registered for . + internal GrassCoverErosionInwardsCalculationEntity Get(GrassCoverErosionInwardsCalculation model) + { + return Get(grassCoverErosionInwardsCalculations, model); + } + + /// /// Registers a create or update operation for and the /// that was constructed with the information. /// Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql =================================================================== diff -u -r182ee751da4cc43bd5d44e816199ded9787f619e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 182ee751da4cc43bd5d44e816199ded9787f619e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -1,6 +1,6 @@ /* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 12.0 */ -/* Created On : 21-jul-2016 11:30:42 */ +/* Created On : 22-jul-2016 14:15:50 */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ @@ -468,9 +468,11 @@ ( 'GrassCoverErosionInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'FailureMechanismSectionEntityId' INTEGER NOT NULL, + 'GrassCoverErosionInwardsCalculationEntityId' INTEGER, 'LayerOne' TINYINT (1) NOT NULL, -- true or false 'LayerThree' NUMERIC, - CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade + CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade, + CONSTRAINT 'FK_GrassCoverErosionInwardsSectionResultEntity_GrassCoverErosionInwardsCalculationEntity' FOREIGN KEY ('GrassCoverErosionInwardsCalculationEntityId') REFERENCES 'GrassCoverErosionInwardsCalculationEntity' ('GrassCoverErosionInwardsCalculationEntityId') ON DELETE Set Null ON UPDATE Cascade ) ; @@ -787,6 +789,10 @@ ON 'GrassCoverErosionInwardsSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) ; +CREATE INDEX 'IXFK_GrassCoverErosionInwardsSectionResultEntity_GrassCoverErosionInwardsCalculationEntity' + ON 'GrassCoverErosionInwardsSectionResultEntity' ('GrassCoverErosionInwardsCalculationEntityId' ASC) +; + CREATE INDEX 'IXFK_HeightStructuresSectionResultEntity_FailureMechanismSectionEntity' ON 'HeightStructuresSectionResultEntity' ('FailureMechanismSectionEntityId' ASC) ; Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionInwardsCalculationEntity.cs =================================================================== diff -u -r182ee751da4cc43bd5d44e816199ded9787f619e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionInwardsCalculationEntity.cs (.../GrassCoverErosionInwardsCalculationEntity.cs) (revision 182ee751da4cc43bd5d44e816199ded9787f619e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionInwardsCalculationEntity.cs (.../GrassCoverErosionInwardsCalculationEntity.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -35,6 +35,12 @@ public partial class GrassCoverErosionInwardsCalculationEntity { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] + public GrassCoverErosionInwardsCalculationEntity() + { + this.GrassCoverErosionInwardsSectionResultEntities = new HashSet(); + } + public long GrassCoverErosionInwardsCalculationEntityId { get; set; } public long CalculationGroupEntityId { get; set; } public Nullable HydraulicLocationEntityId { get; set; } @@ -57,5 +63,7 @@ public virtual DikeProfileEntity DikeProfileEntity { get; set; } public virtual HydraulicLocationEntity HydraulicLocationEntity { get; set; } public virtual GrassCoverErosionInwardsOutputEntity GrassCoverErosionInwardsOutputEntity { get; set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")] + public virtual ICollection GrassCoverErosionInwardsSectionResultEntities { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionInwardsSectionResultEntity.cs =================================================================== diff -u -r5ac27878c41230483441a2f860f49732369ac606 -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionInwardsSectionResultEntity.cs (.../GrassCoverErosionInwardsSectionResultEntity.cs) (revision 5ac27878c41230483441a2f860f49732369ac606) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/GrassCoverErosionInwardsSectionResultEntity.cs (.../GrassCoverErosionInwardsSectionResultEntity.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -37,9 +37,11 @@ { public long GrassCoverErosionInwardsSectionResultEntityId { get; set; } public long FailureMechanismSectionEntityId { get; set; } + public Nullable GrassCoverErosionInwardsCalculationEntityId { get; set; } public byte LayerOne { get; set; } public Nullable LayerThree { get; set; } public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } + public virtual GrassCoverErosionInwardsCalculationEntity GrassCoverErosionInwardsCalculationEntity { get; set; } } } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx =================================================================== diff -u -r182ee751da4cc43bd5d44e816199ded9787f619e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 182ee751da4cc43bd5d44e816199ded9787f619e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -149,6 +149,7 @@ + @@ -682,6 +683,18 @@ + + + + + + + + + + + + @@ -1175,6 +1188,10 @@ + + + + @@ -1428,7 +1445,7 @@ - + @@ -1500,6 +1517,10 @@ + + + + @@ -1657,7 +1678,7 @@ - + @@ -1710,6 +1731,7 @@ + @@ -1739,9 +1761,11 @@ + - + + @@ -2353,7 +2377,7 @@ - + @@ -2569,6 +2593,18 @@ + + + + + + + + + + + + @@ -2862,6 +2898,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -r182ee751da4cc43bd5d44e816199ded9787f619e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 182ee751da4cc43bd5d44e816199ded9787f619e) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -5,50 +5,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -68,7 +68,7 @@ - + @@ -86,6 +86,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs =================================================================== diff -u -rbc7cd9cbf90d04580e6b3542c56edc590867c43a -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensions.cs) (revision bc7cd9cbf90d04580e6b3542c56edc590867c43a) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensions.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensions.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -50,6 +50,10 @@ { throw new ArgumentNullException("collector"); } + if (collector.Contains(entity)) + { + return collector.Get(entity); + } var calculation = new GrassCoverErosionInwardsCalculation { @@ -78,11 +82,13 @@ } }; - if (entity.GrassCoverErosionInwardsOutputEntity != null) { calculation.Output = entity.GrassCoverErosionInwardsOutputEntity.Read(); } + + collector.Read(entity, calculation); + return calculation; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs =================================================================== diff -u -ra5714fc0488030773fff50dfc82041c6cb9edc2f -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs (.../GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs) (revision a5714fc0488030773fff50dfc82041c6cb9edc2f) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs (.../GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -58,6 +58,10 @@ sectionResult.StorageId = entity.GrassCoverErosionInwardsSectionResultEntityId; sectionResult.AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne); sectionResult.AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNanableDouble(); + if (entity.GrassCoverErosionInwardsCalculationEntity != null) + { + sectionResult.Calculation = entity.GrassCoverErosionInwardsCalculationEntity.Read(collector); + } } } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs =================================================================== diff -u -rbc7cd9cbf90d04580e6b3542c56edc590867c43a -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision bc7cd9cbf90d04580e6b3542c56edc590867c43a) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ReadConversionCollector.cs (.../ReadConversionCollector.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -39,15 +39,21 @@ /// internal class ReadConversionCollector { - private readonly Dictionary stochasticSoilModels = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary stochasticSoilProfiles = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary soilProfiles = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary surfaceLines = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary surfaceLineGeometryPoints = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary hydraulicBoundaryLocations = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary failureMechanismSections = new Dictionary(new ReferenceEqualityComparer()); - private readonly Dictionary dikeProfiles = new Dictionary(new ReferenceEqualityComparer()); + private readonly Dictionary stochasticSoilModels = CreateDictionary(); + private readonly Dictionary stochasticSoilProfiles = CreateDictionary(); + private readonly Dictionary soilProfiles = CreateDictionary(); + private readonly Dictionary surfaceLines = CreateDictionary(); + private readonly Dictionary surfaceLineGeometryPoints = CreateDictionary(); + private readonly Dictionary hydraulicBoundaryLocations = CreateDictionary(); + private readonly Dictionary failureMechanismSections = CreateDictionary(); + private readonly Dictionary dikeProfiles = CreateDictionary(); + private readonly Dictionary grassCoverErosionInwardsCalculations = CreateDictionary(); + private static Dictionary CreateDictionary() + { + return new Dictionary(new ReferenceEqualityComparer()); + } + #region StochasticSoilModelEntity: Read, Contains, Get /// @@ -550,7 +556,7 @@ #endregion - #region FailureMechanismSectionEntity: Read, Contains, Get + #region DikeProfileEntity: Read, Contains, Get /// /// Registers a read operation for and the @@ -621,5 +627,80 @@ } #endregion + + #region GrassCoverErosionInwardsCalculationEntity: Read, Contains, Get + + /// + /// Registers a read operation for + /// and the that was constructed + /// with the information. + /// + /// The + /// that was read. + /// The that + /// was constructed. + /// Thrown when either: + /// + /// is null + /// is null + /// + internal void Read(GrassCoverErosionInwardsCalculationEntity entity, GrassCoverErosionInwardsCalculation model) + { + if (entity == null) + { + throw new ArgumentNullException("entity"); + } + if (model == null) + { + throw new ArgumentNullException("model"); + } + + grassCoverErosionInwardsCalculations[entity] = model; + } + + /// + /// Checks whether a read operation has been registered for a given . + /// + /// The to check for. + /// true if the was read before, false otherwise. + /// Thrown when is null. + internal bool Contains(GrassCoverErosionInwardsCalculationEntity entity) + { + if (entity == null) + { + throw new ArgumentNullException("entity"); + } + return grassCoverErosionInwardsCalculations.ContainsKey(entity); + } + + /// + /// Obtains the which was read + /// for the given . + /// + /// The for which a read + /// operation has been registered. + /// The constructed . + /// Thrown when is null. + /// Thrown when no read operation has + /// been registered for . + /// Use + /// to find out whether a read operation has been registered for . + internal GrassCoverErosionInwardsCalculation Get(GrassCoverErosionInwardsCalculationEntity entity) + { + if (entity == null) + { + throw new ArgumentNullException("entity"); + } + try + { + return grassCoverErosionInwardsCalculations[entity]; + } + catch (KeyNotFoundException e) + { + throw new InvalidOperationException(e.Message, e); + } + } + + #endregion } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs =================================================================== diff -u -ra5714fc0488030773fff50dfc82041c6cb9edc2f -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs) (revision a5714fc0488030773fff50dfc82041c6cb9edc2f) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensions.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -66,8 +66,14 @@ entity.LayerOne = Convert.ToByte(result.AssessmentLayerOne); entity.LayerThree = result.AssessmentLayerThree.Value.ToNullableDecimal(); + entity.GrassCoverErosionInwardsCalculationEntity = GetCalculationEntity(result.Calculation, registry); registry.Register(entity, result); } + + private static GrassCoverErosionInwardsCalculationEntity GetCalculationEntity(GrassCoverErosionInwardsCalculation calculation, PersistenceRegistry registry) + { + return calculation != null ? registry.Get(calculation) : null; + } } } \ No newline at end of file Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs =================================================================== diff -u -r06e4debe3f4a9bdfb38c40b8c00ed013e8f7bb98 -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs) (revision 06e4debe3f4a9bdfb38c40b8c00ed013e8f7bb98) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs (.../GrassCoverErosionInwardsFailureMechanismUpdateExtensions.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -69,9 +69,9 @@ mechanism.GeneralInput.Update(registry, context); UpdateDikeProfiles(mechanism, registry, entity, context); mechanism.UpdateFailureMechanismSections(registry, entity, context); - UpdateSectionResults(mechanism, registry, context); mechanism.CalculationsGroup.Update(registry, context, 0); - + UpdateSectionResults(mechanism, registry, context); + registry.Register(entity, mechanism); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r01ff2c58c13df8f42661ae3e446dc2caaa94247e -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsMechanismSectionResultCreateExtensionsTest.cs (.../GrassCoverErosionInwardsMechanismSectionResultCreateExtensionsTest.cs) (revision 01ff2c58c13df8f42661ae3e446dc2caaa94247e) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsMechanismSectionResultCreateExtensionsTest.cs (.../GrassCoverErosionInwardsMechanismSectionResultCreateExtensionsTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -23,6 +23,7 @@ using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.Create.GrassCoverErosionInwards; +using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base.Data; @@ -62,12 +63,15 @@ AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult }; + var registry = new PersistenceRegistry(); + // Call - var result = sectionResult.Create(new PersistenceRegistry()); + GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create(registry); // Assert - Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); - Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), result.LayerThree); + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), entity.LayerOne); + Assert.AreEqual(Convert.ToDecimal(assessmentLayerThreeResult), entity.LayerThree); + Assert.IsNull(entity.GrassCoverErosionInwardsCalculationEntity); } [Test] @@ -79,11 +83,34 @@ AssessmentLayerThree = (RoundedDouble) double.NaN }; + var registry = new PersistenceRegistry(); + // Call - var result = sectionResult.Create(new PersistenceRegistry()); + GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create(registry); // Assert - Assert.IsNull(result.LayerThree); + Assert.IsNull(entity.LayerThree); } + + [Test] + public void Create_CalculationSet_ReturnEntityWithCalculationEntity() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + Calculation = calculation + }; + + var registry = new PersistenceRegistry(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + registry.Register(entity, calculation); + + // Call + GrassCoverErosionInwardsSectionResultEntity result = sectionResult.Create(registry); + + // Assert + Assert.AreSame(entity, result.GrassCoverErosionInwardsCalculationEntity); + } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -rbc7cd9cbf90d04580e6b3542c56edc590867c43a -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision bc7cd9cbf90d04580e6b3542c56edc590867c43a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -385,7 +385,7 @@ } [Test] - public void Contains_OtherSFailureMechanismSectionAdded_False() + public void Contains_OtherFailureMechanismSectionAdded_False() { // Setup var registry = new PersistenceRegistry(); @@ -464,6 +464,67 @@ Assert.IsFalse(result); } + [Test] + public void Contains_WithoutGrassCoverErosionInwardsCalculation_ArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate call = () => registry.Contains((GrassCoverErosionInwardsCalculation)null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Contains_GrassCoverErosionInwardsCalculationAdded_True() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + var registry = new PersistenceRegistry(); + registry.Register(new GrassCoverErosionInwardsCalculationEntity(), calculation); + + // Call + bool result = registry.Contains(calculation); + + // Assert + Assert.IsTrue(result); + } + + [Test] + public void Contains_OtherGrassCoverErosionInwardsCalculationAdded_False() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + + var otherCalculation = new GrassCoverErosionInwardsCalculation(); + var registry = new PersistenceRegistry(); + registry.Register(new GrassCoverErosionInwardsCalculationEntity(), otherCalculation); + + // Call + bool result = registry.Contains(calculation); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void Contains_NoGrassCoverErosionInwardsCalculationAdded_False() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + + var registry = new PersistenceRegistry(); + + // Call + bool result = registry.Contains(calculation); + + // Assert + Assert.IsFalse(result); + } + #endregion #region Get methods @@ -906,6 +967,68 @@ Assert.AreSame(registeredEntity, retrievedEntity); } + [Test] + public void Get_WithoutGrassCoverErosionInwardsCalculation_ArgumentNullException() + { + // Setup + var registry = new PersistenceRegistry(); + + // Call + TestDelegate call = () => registry.Get((GrassCoverErosionInwardsCalculation)null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("model", paramName); + } + + [Test] + public void Get_NoGrassCoverErosionInwardsCalculationAdded_ThrowsInvalidOperationException() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + var registry = new PersistenceRegistry(); + + // Call + TestDelegate call = () => registry.Get(calculation); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Get_OtherGrassCoverErosionInwardsCalculationAdded_ThrowsInvalidOperationException() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + var registeredCalculation = new GrassCoverErosionInwardsCalculation(); + var registeredEntity = new GrassCoverErosionInwardsCalculationEntity(); + + var registry = new PersistenceRegistry(); + registry.Register(registeredEntity, registeredCalculation); + + // Call + TestDelegate call = () => registry.Get(calculation); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Get_GrassCoverErosionInwardsCalculationAdded_ReturnsEntity() + { + // Setup + var calculation = new GrassCoverErosionInwardsCalculation(); + var registeredEntity = new GrassCoverErosionInwardsCalculationEntity(); + + var registry = new PersistenceRegistry(); + registry.Register(registeredEntity, calculation); + + // Call + GrassCoverErosionInwardsCalculationEntity retrievedEntity = registry.Get(calculation); + + // Assert + Assert.AreSame(registeredEntity, retrievedEntity); + } #endregion #region Register methods Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -rff47dc9d3989152e8793676ec3e8375fe6e06fd7 -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision ff47dc9d3989152e8793676ec3e8375fe6e06fd7) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -330,6 +330,14 @@ Assert.AreEqual(expectedSection.AssessmentLayerOne, actualSection.AssessmentLayerOne); Assert.AreEqual(expectedSection.AssessmentLayerThree, actualSection.AssessmentLayerThree); + if (expectedSection.Calculation == null) + { + Assert.IsNull(actualSection.Calculation); + } + else + { + AssertGrassCoverErosionInwardsCalculation(expectedSection.Calculation, actualSection.Calculation); + } } } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs =================================================================== diff -u -rbc7cd9cbf90d04580e6b3542c56edc590867c43a -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs) (revision bc7cd9cbf90d04580e6b3542c56edc590867c43a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -106,6 +106,28 @@ } [Test] + public void Read_EntityNotReadBefore_RegisterEntity() + { + // Setup + var entity = new GrassCoverErosionInwardsCalculationEntity + { + GrassCoverErosionInwardsCalculationEntityId = 457, + }; + + var collector = new ReadConversionCollector(); + + // Precondition + Assert.IsFalse(collector.Contains(entity)); + + // Call + GrassCoverErosionInwardsCalculation calculation = entity.Read(collector); + + // Assert + Assert.IsTrue(collector.Contains(entity)); + Assert.AreSame(calculation, collector.Get(entity)); + } + + [Test] public void Read_EntityWithNullValues_ReturnCalculationWithNaNOrNull() { // Setup @@ -144,7 +166,7 @@ } [Test] - public void Create_ValidEntityWithAlreadyReadDikeProfileEntity_ReturnCalculationWithReadDikeProfile() + public void Read_ValidEntityWithAlreadyReadDikeProfileEntity_ReturnCalculationWithReadDikeProfile() { // Setup var dikeProfile = new DikeProfile(new Point2D(0, 0), new RoughnessPoint[0], new Point2D[0], @@ -169,7 +191,7 @@ } [Test] - public void Create_ValidEntityWithUnreadDikeProfileEntity_ReturnCalculationWithNewDikeProfile() + public void Read_ValidEntityWithUnreadDikeProfileEntity_ReturnCalculationWithNewDikeProfile() { // Setup var dikeProfileEntity = new DikeProfileEntity @@ -194,7 +216,7 @@ } [Test] - public void Create_ValidEntityWithAlreadyReadHydraulicLocationEntity_ReturnCalculationWithReadHydraulicBoundaryLocation() + public void Read_ValidEntityWithAlreadyReadHydraulicLocationEntity_ReturnCalculationWithReadHydraulicBoundaryLocation() { // Setup var hydroLocation = new HydraulicBoundaryLocation(1, "A", 0, 0); @@ -215,7 +237,7 @@ } [Test] - public void Create_ValidEntityWithUnreadHydraulicLocationEntity_ReturnCalculationWithNewHydraulicBoundaryLocation() + public void Read_ValidEntityWithUnreadHydraulicLocationEntity_ReturnCalculationWithNewHydraulicBoundaryLocation() { // Setup var hydroLocationEntity = new HydraulicLocationEntity @@ -262,5 +284,34 @@ // Assert Assert.IsTrue(calculation.HasOutput); } + + [Test] + public void Read_CalculationEntityAlreadyRead_ReturnReadCalculation() + { + // Setup + var entity = new GrassCoverErosionInwardsCalculationEntity + { + GrassCoverErosionInwardsCalculationEntityId = 456, + GrassCoverErosionInwardsOutputEntity = new GrassCoverErosionInwardsOutputEntity + { + GrassCoverErosionInwardsOutputId = 9745, + ProbabilisticOutputEntity = new ProbabilisticOutputEntity + { + ProbabilisticOutputEntityId = 3245 + } + } + }; + + var calculation = new GrassCoverErosionInwardsCalculation(); + + var collector = new ReadConversionCollector(); + collector.Read(entity, calculation); + + // Call + GrassCoverErosionInwardsCalculation returnedCalculation = entity.Read(collector); + + // Assert + Assert.AreSame(calculation, returnedCalculation); + } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -ra5714fc0488030773fff50dfc82041c6cb9edc2f -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs) (revision a5714fc0488030773fff50dfc82041c6cb9edc2f) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -93,6 +93,8 @@ Assert.AreEqual(entityId, sectionResult.StorageId); Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + + Assert.IsNull(sectionResult.Calculation); } [Test] @@ -117,6 +119,37 @@ // Assert Assert.IsNaN(sectionResult.AssessmentLayerThree); - } + } + + [Test] + public void Read_CalculationEntitySet_ReturnGrassCoverErosionInwardsSectionResultWithCalculation() + { + // Setup + var random = new Random(21); + var entityId = random.Next(1, 502); + + var calculation = new GrassCoverErosionInwardsCalculation(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + var calculationEntity = new GrassCoverErosionInwardsCalculationEntity(); + + var collector = new ReadConversionCollector(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + collector.Read(calculationEntity, calculation); + + var entity = new GrassCoverErosionInwardsSectionResultEntity + { + GrassCoverErosionInwardsSectionResultEntityId = entityId, + FailureMechanismSectionEntity = failureMechanismSectionEntity, + GrassCoverErosionInwardsCalculationEntity = calculationEntity + }; + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult, collector); + + // Assert + Assert.AreSame(calculation, sectionResult.Calculation); + } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs =================================================================== diff -u -rbc7cd9cbf90d04580e6b3542c56edc590867c43a -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision bc7cd9cbf90d04580e6b3542c56edc590867c43a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -959,7 +959,7 @@ #endregion - #region FailureMechanismSectionEntity: Read, Contains, Get + #region DikeProfileEntity: Read, Contains, Get [Test] public void Contains_WithoutDikeProfileEntity_ArgumentNullException() @@ -1034,7 +1034,7 @@ } [Test] - public void Get_DikeProfileEntityAdded_ReturnsHydraulicBoundaryLocation() + public void Get_DikeProfileEntityAdded_ReturnsDikeProfile() { // Setup var collector = new ReadConversionCollector(); @@ -1043,7 +1043,7 @@ collector.Read(entity, dikeProfile); // Call - var result = collector.Get(entity); + DikeProfile result = collector.Get(entity); // Assert Assert.AreSame(dikeProfile, result); @@ -1113,5 +1113,154 @@ } #endregion + + #region GrassCoverErosionInwardsCalculationEntity: Read, Contains, Get + + [Test] + public void Contains_WithoutGrassCoverErosionInwardsCalculationEntity_ArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); + + // Call + TestDelegate test = () => collector.Contains((GrassCoverErosionInwardsCalculationEntity)null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Contains_GrassCoverErosionInwardsCalculationEntityAdded_True() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + collector.Read(entity, new GrassCoverErosionInwardsCalculation()); + + // Call + var result = collector.Contains(entity); + + // Assert + Assert.IsTrue(result); + } + + [Test] + public void Contains_NoGrassCoverErosionInwardsCalculationEntityAdded_False() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + + // Call + var result = collector.Contains(entity); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void Contains_OtherGrassCoverErosionInwardsCalculationEntityAdded_False() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + collector.Read(new GrassCoverErosionInwardsCalculationEntity(), new GrassCoverErosionInwardsCalculation()); + + // Call + var result = collector.Contains(entity); + + // Assert + Assert.IsFalse(result); + } + + [Test] + public void Get_WithoutGrassCoverErosionInwardsCalculationEntity_ThrowArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); + + // Call + TestDelegate test = () => collector.Get((GrassCoverErosionInwardsCalculationEntity)null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Get_GrassCoverErosionInwardsCalculationEntityAdded_ReturnsGrassCoverErosionInwardsCalculation() + { + // Setup + var collector = new ReadConversionCollector(); + var calculation = new GrassCoverErosionInwardsCalculation(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + collector.Read(entity, calculation); + + // Call + var result = collector.Get(entity); + + // Assert + Assert.AreSame(calculation, result); + } + + [Test] + public void Get_NoGrassCoverErosionInwardsCalculationEntityAdded_ThrowsInvalidOperationException() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + + // Call + TestDelegate test = () => collector.Get(entity); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Get_OtherGrassCoverErosionInwardsCalculationEntityAdded_ThrowsInvalidOperationException() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new GrassCoverErosionInwardsCalculationEntity(); + collector.Read(new GrassCoverErosionInwardsCalculationEntity(), new GrassCoverErosionInwardsCalculation()); + + // Call + TestDelegate test = () => collector.Get(entity); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Read_WithNullGrassCoverErosionInwardsCalculationEntity_ThrowsArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); + + // Call + TestDelegate test = () => collector.Read(null, new GrassCoverErosionInwardsCalculation()); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } + + [Test] + public void Read_WithNullGrassCoverErosionInwardsCalculation_ThrowsArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); + + // Call + TestDelegate test = () => collector.Read(new GrassCoverErosionInwardsCalculationEntity(), null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } + + #endregion } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs =================================================================== diff -u -ra5714fc0488030773fff50dfc82041c6cb9edc2f -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs) (revision a5714fc0488030773fff50dfc82041c6cb9edc2f) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Update/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultUpdateExtensionsTest.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -162,7 +162,7 @@ } [Test] - public void Create_WithNaNResult_ReturnsEntityWithNullResult() + public void Update_WithNaNResult_ReturnsEntityWithNullResult() { // Setup MockRepository mocks = new MockRepository(); @@ -192,5 +192,73 @@ // Assert Assert.IsNull(sectionResultEntity.LayerThree); } + + [Test] + public void Update_WithNewCalculation_EntityHasCalculationEntitySet() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var calculation = new GrassCoverErosionInwardsCalculation(); + var calculationEntity = new GrassCoverErosionInwardsCalculationEntity(); + + var registry = new PersistenceRegistry(); + registry.Register(calculationEntity, calculation); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 4534, + Calculation = calculation + }; + var entity = new GrassCoverErosionInwardsSectionResultEntity + { + GrassCoverErosionInwardsSectionResultEntityId = sectionResult.StorageId, + GrassCoverErosionInwardsCalculationEntity = null + }; + + ringtoetsEntities.GrassCoverErosionInwardsSectionResultEntities.Add(entity); + + // Call + sectionResult.Update(registry, ringtoetsEntities); + + // Assert + Assert.AreSame(calculationEntity, entity.GrassCoverErosionInwardsCalculationEntity); + mocks.VerifyAll(); + } + + [Test] + public void Update_WithDeletedCalculation_EntityHasCalculationEntitySetToNulll() + { + // Setup + var mocks = new MockRepository(); + var ringtoetsEntities = RingtoetsEntitiesHelper.CreateStub(mocks); + mocks.ReplayAll(); + + var calculationEntity = new GrassCoverErosionInwardsCalculationEntity(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + StorageId = 4534, + Calculation = null + }; + var entity = new GrassCoverErosionInwardsSectionResultEntity + { + GrassCoverErosionInwardsSectionResultEntityId = sectionResult.StorageId, + GrassCoverErosionInwardsCalculationEntity = calculationEntity + }; + + ringtoetsEntities.GrassCoverErosionInwardsSectionResultEntities.Add(entity); + + var registry = new PersistenceRegistry(); + + // Call + sectionResult.Update(registry, ringtoetsEntities); + + // Assert + Assert.IsNull(entity.GrassCoverErosionInwardsCalculationEntity); + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs =================================================================== diff -u -re2e6d944af7b0cea6c9c34e77bd0644149526c37 -r1e9309149f9387c4e8b10f6c5f429797220b0ef8 --- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision e2e6d944af7b0cea6c9c34e77bd0644149526c37) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectTestHelper.cs (.../RingtoetsProjectTestHelper.cs) (revision 1e9309149f9387c4e8b10f6c5f429797220b0ef8) @@ -65,7 +65,8 @@ GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwardsFailureMechanism = assessmentSection.GrassCoverErosionInwards; ConfigureGrassCoverErosionInwardsFailureMechanism(grassCoverErosionInwardsFailureMechanism, assessmentSection); AddSections(grassCoverErosionInwardsFailureMechanism); - SetSectionResults(grassCoverErosionInwardsFailureMechanism.SectionResults); + SetSectionResults(grassCoverErosionInwardsFailureMechanism.SectionResults, + grassCoverErosionInwardsFailureMechanism.Calculations.OfType()); AddSections(assessmentSection.MacrostabilityInwards); SetSectionResults(assessmentSection.MacrostabilityInwards.SectionResults); @@ -358,13 +359,19 @@ } } - private static void SetSectionResults(IEnumerable sectionResults) + private static void SetSectionResults(IEnumerable sectionResults, IEnumerable calculations) { var random = new Random(21); + bool firstSectionResultHasCalculation = false; foreach (var sectionResult in sectionResults) { sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2)); sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble(); + if (!firstSectionResultHasCalculation) + { + sectionResult.Calculation = calculations.First(); + firstSectionResultHasCalculation = true; + } } }