Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs =================================================================== diff -u -rfaeb56f2d76b07f370127de2beb66edad2dea6af -r08bb51221d82157423573733a9bf43e0191c9b68 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs (.../HeightStructuresCalculationCreateExtensions.cs) (revision faeb56f2d76b07f370127de2beb66edad2dea6af) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresCalculationCreateExtensions.cs (.../HeightStructuresCalculationCreateExtensions.cs) (revision 08bb51221d82157423573733a9bf43e0191c9b68) @@ -63,6 +63,8 @@ entity.HeightStructuresOutputEntities.Add(calculation.Output.Create(registry)); } + registry.Register(entity, calculation); + return entity; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismCreateExtensions.cs =================================================================== diff -u -r9c2ae58765574fa6fb31136c0361871f7f135c7a -r08bb51221d82157423573733a9bf43e0191c9b68 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismCreateExtensions.cs (.../HeightStructuresFailureMechanismCreateExtensions.cs) (revision 9c2ae58765574fa6fb31136c0361871f7f135c7a) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismCreateExtensions.cs (.../HeightStructuresFailureMechanismCreateExtensions.cs) (revision 08bb51221d82157423573733a9bf43e0191c9b68) @@ -42,11 +42,11 @@ internal static FailureMechanismEntity Create(this HeightStructuresFailureMechanism mechanism, PersistenceRegistry registry) { FailureMechanismEntity entity = mechanism.Create(FailureMechanismType.StructureHeight, registry); - AddEntitiesForSectionResults(mechanism.SectionResults, registry); AddEntitiesForForeshoreProfiles(mechanism.ForeshoreProfiles, entity, registry); AddEntitiesForHeightStructures(mechanism.HeightStructures, entity, registry); AddEntitiesForFailureMechanismMeta(mechanism.GeneralInput, entity); entity.CalculationGroupEntity = mechanism.CalculationsGroup.Create(registry, 0); + AddEntitiesForSectionResults(mechanism.SectionResults, registry); return entity; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u -r11f0867b39150ae5fac83dc178a89fee46d27611 -r08bb51221d82157423573733a9bf43e0191c9b68 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensions.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensions.cs) (revision 11f0867b39150ae5fac83dc178a89fee46d27611) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensions.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensions.cs) (revision 08bb51221d82157423573733a9bf43e0191c9b68) @@ -44,13 +44,17 @@ { throw new ArgumentNullException("registry"); } - var heightStructuresSectionResultEntity = new HeightStructuresSectionResultEntity + var sectionResultEntity = new HeightStructuresSectionResultEntity { LayerOne = Convert.ToByte(result.AssessmentLayerOne), LayerThree = result.AssessmentLayerThree.Value.ToNaNAsNull() }; + if (result.Calculation != null) + { + sectionResultEntity.HeightStructuresCalculationEntity = registry.Get(result.Calculation); + } - return heightStructuresSectionResultEntity; + return sectionResultEntity; } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r9e54793f4e953bf1a1b9c9f9d731de4831dd9ff6 -r08bb51221d82157423573733a9bf43e0191c9b68 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 9e54793f4e953bf1a1b9c9f9d731de4831dd9ff6) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 08bb51221d82157423573733a9bf43e0191c9b68) @@ -122,7 +122,7 @@ - + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest.cs (revision 08bb51221d82157423573733a9bf43e0191c9b68) @@ -0,0 +1,111 @@ +// 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 Application.Ringtoets.Storage.TestUtil; +using Core.Common.Base.Data; +using NUnit.Framework; +using Ringtoets.GrassCoverErosionInwards.Data; + +namespace Application.Ringtoets.Storage.Test.Create.GrassCoverErosionInwards +{ + [TestFixture] + public class GrassCoverErosionInwardsFailureMechanismSectionResultCreateExtensionsTest + { + [Test] + public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => sectionResult.Create(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_WithDifferentResults_ReturnsEntityWithExpectedResults( + [Values(true, false)] bool assessmentLayerOneResult, + [Values(3.2, 4.5)] double assessmentLayerThreeResult) + { + // Setup + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + AssessmentLayerOne = assessmentLayerOneResult, + AssessmentLayerThree = (RoundedDouble) assessmentLayerThreeResult + }; + + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create(registry); + + // Assert + Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), entity.LayerOne); + Assert.AreEqual(assessmentLayerThreeResult, entity.LayerThree); + Assert.IsNull(entity.GrassCoverErosionInwardsCalculationEntity); + } + + [Test] + public void Create_WithNaNLevel3Result_ReturnsEntityWithExpectedResults() + { + // Setup + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + AssessmentLayerThree = RoundedDouble.NaN + }; + + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionInwardsSectionResultEntity entity = sectionResult.Create(registry); + + // Assert + 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 Fisheye: Tag 08bb51221d82157423573733a9bf43e0191c9b68 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/GrassCoverErosionInwards/GrassCoverErosionInwardsMechanismSectionResultCreateExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r41a37c93cb0b3e36ff7023c9f42b4e6225598b55 -r08bb51221d82157423573733a9bf43e0191c9b68 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 41a37c93cb0b3e36ff7023c9f42b4e6225598b55) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 08bb51221d82157423573733a9bf43e0191c9b68) @@ -22,9 +22,11 @@ using System; using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.Create.HeightStructures; +using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.TestUtil; using Core.Common.Base.Data; using NUnit.Framework; +using Ringtoets.Common.Data.Structures; using Ringtoets.HeightStructures.Data; namespace Application.Ringtoets.Storage.Test.Create.HeightStructures @@ -80,5 +82,26 @@ // Assert Assert.IsNull(result.LayerThree); } + + [Test] + public void Create_CalculationSet_ReturnEntityWithCalculationEntity() + { + // Setup + var calculation = new StructuresCalculation(); + var sectionResult = new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) + { + Calculation = calculation + }; + + var registry = new PersistenceRegistry(); + var entity = new HeightStructuresCalculationEntity(); + registry.Register(entity, calculation); + + // Call + HeightStructuresSectionResultEntity result = sectionResult.Create(registry); + + // Assert + Assert.AreSame(entity, result.HeightStructuresCalculationEntity); + } } } \ No newline at end of file