Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -rbb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f -rc5499aa0c2af6b5b54c329cbed1a39706bf49cd3
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision bb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -147,6 +147,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs
===================================================================
diff -u -rc6ca64554901be3f9f5f6dc9f21b72de90833971 -rc5499aa0c2af6b5b54c329cbed1a39706bf49cd3
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision c6ca64554901be3f9f5f6dc9f21b72de90833971)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -113,8 +113,22 @@
failureMechanism.Comments = entity.Comments;
entity.ReadFailureMechanismSections(failureMechanism, collector);
+ entity.ReadGrassCoverErosionInwardsMechanismSectionResults(failureMechanism, collector);
}
+ private static void ReadGrassCoverErosionInwardsMechanismSectionResults(this FailureMechanismEntity entity, GrassCoverErosionInwardsFailureMechanism failureMechanism, ReadConversionCollector collector)
+ {
+ foreach (var grassCoverErosionInwardsSectionResultEntity in entity.FailureMechanismSectionEntities.SelectMany(fms => fms.GrassCoverErosionInwardsSectionResultEntities))
+ {
+ var readSectionResult = grassCoverErosionInwardsSectionResultEntity.Read(collector);
+ var failureMechanismSection = collector.Get(grassCoverErosionInwardsSectionResultEntity.FailureMechanismSectionEntity);
+ var result = failureMechanism.SectionResults.Single(sr => ReferenceEquals(sr.Section, failureMechanismSection));
+ result.StorageId = readSectionResult.StorageId;
+ result.AssessmentLayerOne = readSectionResult.AssessmentLayerOne;
+ result.AssessmentLayerThree = readSectionResult.AssessmentLayerThree;
+ }
+ }
+
///
/// Read the and use the information to construct a .
///
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/GrassCoverErosionInwardsSectionResultEntityReadExtensions.cs (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -0,0 +1,58 @@
+// 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 Core.Common.Base.Data;
+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 GrassCoverErosionInwardsSectionResultEntityReadExtensions
+ {
+ ///
+ /// Reads the and use the information to construct a
+ /// .
+ ///
+ /// The to create for.
+ /// The object keeping track of read operations.
+ /// A new .
+ /// Thrown when is null.
+ internal static GrassCoverErosionInwardsFailureMechanismSectionResult Read(this GrassCoverErosionInwardsSectionResultEntity entity, ReadConversionCollector collector)
+ {
+ if (collector == null)
+ {
+ throw new ArgumentNullException("collector");
+ }
+ var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(collector.Get(entity.FailureMechanismSectionEntity))
+ {
+ StorageId = entity.GrassCoverErosionInwardsSectionResultEntityId,
+ AssessmentLayerOne = Convert.ToBoolean(entity.LayerOne),
+ AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNanableDouble()
+ };
+ return sectionResult;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/PipingSectionResultEntityReadExtensions.cs
===================================================================
diff -u -r0046acb203ae12c74743abc12f57e557d96f9c5a -rc5499aa0c2af6b5b54c329cbed1a39706bf49cd3
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/PipingSectionResultEntityReadExtensions.cs (.../PipingSectionResultEntityReadExtensions.cs) (revision 0046acb203ae12c74743abc12f57e557d96f9c5a)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/PipingSectionResultEntityReadExtensions.cs (.../PipingSectionResultEntityReadExtensions.cs) (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -23,7 +23,6 @@
using Application.Ringtoets.Storage.DbContext;
using Core.Common.Base.Data;
using Ringtoets.Piping.Data;
-using Ringtoets.Piping.Primitives;
namespace Application.Ringtoets.Storage.Read
{
@@ -37,9 +36,9 @@
/// Reads the and use the information to construct a
/// .
///
- /// The to create for.
+ /// The to create for.
/// The object keeping track of read operations.
- /// A new .
+ /// A new .
/// Thrown when is null.
internal static PipingFailureMechanismSectionResult Read(this PipingSectionResultEntity entity, ReadConversionCollector collector)
{
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -rbb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f -rc5499aa0c2af6b5b54c329cbed1a39706bf49cd3
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision bb92ba4d7297c7bf0d1c81ff3d9d6bcab640d55f)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -107,6 +107,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs
===================================================================
diff -u -rc6ca64554901be3f9f5f6dc9f21b72de90833971 -rc5499aa0c2af6b5b54c329cbed1a39706bf49cd3
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision c6ca64554901be3f9f5f6dc9f21b72de90833971)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -287,19 +287,26 @@
{
// Setup
var entityId = new Random(21).Next(1, 502);
+ var failureMechanismSectionEntity = new FailureMechanismSectionEntity
+ {
+ Name = "section",
+ FailureMechanismSectionPointEntities =
+ {
+ new FailureMechanismSectionPointEntity()
+ }
+ };
+ var grassCoverErosionInwardsSectionResultEntity = new GrassCoverErosionInwardsSectionResultEntity
+ {
+ GrassCoverErosionInwardsSectionResultEntityId = entityId,
+ FailureMechanismSectionEntity = failureMechanismSectionEntity
+ };
+ failureMechanismSectionEntity.GrassCoverErosionInwardsSectionResultEntities.Add(grassCoverErosionInwardsSectionResultEntity);
var entity = new FailureMechanismEntity
{
- FailureMechanismEntityId = entityId,
+ FailureMechanismEntityId = 1,
FailureMechanismSectionEntities =
{
- new FailureMechanismSectionEntity
- {
- Name = "section",
- FailureMechanismSectionPointEntities =
- {
- new FailureMechanismSectionPointEntity()
- }
- }
+ failureMechanismSectionEntity
}
};
var collector = new ReadConversionCollector();
@@ -310,6 +317,7 @@
// Assert
Assert.AreEqual(1, failureMechanism.Sections.Count());
+ Assert.AreEqual(entityId, failureMechanism.SectionResults.First().StorageId);
}
[Test]
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest.cs (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -0,0 +1,101 @@
+// 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 Application.Ringtoets.Storage.Read;
+using Application.Ringtoets.Storage.Test.Update;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Storage.Test.Read
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsSectionResultEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_CollectorIsNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var entity = new GrassCoverErosionInwardsSectionResultEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("collector", paramName);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_WithDecimalParameterValues_ReturnGrassCoverErosionInwardsSoilLayerWithDoubleParameterValues(bool layerOne)
+ {
+ // Setup
+ var random = new Random(21);
+ var entityId = random.Next(1, 502);
+ double layerThree = random.NextDouble();
+ var collector = new ReadConversionCollector();
+
+ var failureMechanismSectionEntity = new FailureMechanismSectionEntity();
+ collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection());
+ var entity = new GrassCoverErosionInwardsSectionResultEntity
+ {
+ GrassCoverErosionInwardsSectionResultEntityId = entityId,
+ LayerThree = Convert.ToDecimal(layerThree),
+ LayerOne = Convert.ToByte(layerOne),
+ FailureMechanismSectionEntity = failureMechanismSectionEntity
+ };
+
+ // Call
+ var result = entity.Read(collector);
+
+ // Assert
+ Assert.IsNotNull(result);
+ Assert.AreEqual(entityId, result.StorageId);
+ Assert.AreEqual(layerOne, result.AssessmentLayerOne);
+ Assert.AreEqual(layerThree, result.AssessmentLayerThree, 1e-6);
+ }
+
+ [Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Read_WithNullParameterValues_ReturnGrassCoverErosionInwardsSoilLayerWithNullParameters(bool layerOne)
+ {
+ // Setup
+ var collector = new ReadConversionCollector();
+ var failureMechanismSectionEntity = new FailureMechanismSectionEntity();
+ collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection());
+ var entity = new GrassCoverErosionInwardsSectionResultEntity
+ {
+ LayerOne = Convert.ToByte(layerOne),
+ LayerThree = null,
+ FailureMechanismSectionEntity = failureMechanismSectionEntity
+ };
+
+ // Call
+ var layer = entity.Read(collector);
+
+ // Assert
+ Assert.IsNaN(layer.AssessmentLayerThree);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs
===================================================================
diff -u -r696df91ebc373335894ac95c90ad88d32683870e -rc5499aa0c2af6b5b54c329cbed1a39706bf49cd3
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs (.../RingtoetsProjectHelper.cs) (revision 696df91ebc373335894ac95c90ad88d32683870e)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/RingtoetsProjectHelper.cs (.../RingtoetsProjectHelper.cs) (revision c5499aa0c2af6b5b54c329cbed1a39706bf49cd3)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Collections.Generic;
using System.Linq;
@@ -27,6 +28,7 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.GrassCoverErosionInwards.Data;
using Ringtoets.HydraRing.Data;
using Ringtoets.Integration.Data;
using Ringtoets.Piping.Data;
@@ -209,7 +211,9 @@
};
AddSections(pipingFailureMechanism);
+ SetSectionResults(pipingFailureMechanism.SectionResults);
AddSections(assessmentSection.GrassCoverErosionInwards);
+ SetSectionResults(assessmentSection.GrassCoverErosionInwards.SectionResults);
AddSections(assessmentSection.MacrostabilityInwards);
AddSections(assessmentSection.MacrostabilityOutwards);
AddSections(assessmentSection.Microstability);
@@ -230,6 +234,26 @@
return fullTestProject;
}
+ private static void SetSectionResults(IEnumerable sectionResults)
+ {
+ var random = new Random(21);
+ foreach (var sectionResult in sectionResults)
+ {
+ sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2));
+ sectionResult.AssessmentLayerThree = (RoundedDouble) random.NextDouble();
+ }
+ }
+
+ private static void SetSectionResults(IEnumerable sectionResults)
+ {
+ var random = new Random(21);
+ foreach (var sectionResult in sectionResults)
+ {
+ sectionResult.AssessmentLayerOne = Convert.ToBoolean(random.Next(0, 2));
+ sectionResult.AssessmentLayerThree = (RoundedDouble)random.NextDouble();
+ }
+ }
+
private static void AddSections(IFailureMechanism failureMechanism)
{
failureMechanism.AddSection(new FailureMechanismSection("section 1", new[]