Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r69586fc2b854c415c0472d56da2f7f6e0888c184 -r2c08730c6c2269937fa4f117aed1557876c567ea
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 69586fc2b854c415c0472d56da2f7f6e0888c184)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -72,6 +72,7 @@
+
@@ -350,6 +351,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/GeneralResultSubMechanismIllustrationPointCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/GeneralResultSubMechanismIllustrationPointCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/GeneralResultSubMechanismIllustrationPointCreateExtensions.cs (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -0,0 +1,90 @@
+// Copyright (C) Stichting Deltares 2017. 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 System.Collections.Generic;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.Utils.Extensions;
+using Ringtoets.Common.Data.Hydraulics.IllustrationPoints;
+
+namespace Application.Ringtoets.Storage.Create.IllustrationPoints
+{
+ ///
+ /// Extension methods for
+ /// related to creating an instance of .
+ ///
+ internal static class GeneralResultSubMechanismIllustrationPointCreateExtensions
+ {
+ ///
+ /// Creates a based on the
+ /// information of .
+ ///
+ /// The general result submechanism
+ /// to create a database entity for.
+ /// A new .
+ /// Thrown when
+ /// is null.
+ public static GeneralResultSubMechanismIllustrationPointEntity CreateGeneralResultSubMechanismIllustrationPointEntity(
+ this GeneralResultSubMechanismIllustrationPoint generalResultSubMechanismIllustrationPoint)
+ {
+ if (generalResultSubMechanismIllustrationPoint == null)
+ {
+ throw new ArgumentNullException(nameof(generalResultSubMechanismIllustrationPoint));
+ }
+
+ WindDirection governingWindDirection = generalResultSubMechanismIllustrationPoint.GoverningWindDirection;
+ var entity = new GeneralResultSubMechanismIllustrationPointEntity
+ {
+ GoverningWindDirectionName = governingWindDirection.Name.DeepClone(),
+ GoverningWindDirectionAngle = governingWindDirection.Angle
+ };
+
+ AddEntitiesForStochasts(entity, generalResultSubMechanismIllustrationPoint.Stochasts);
+ AddEntitiesForTopLevelSubMechanismIllustrationPoints(
+ entity,
+ generalResultSubMechanismIllustrationPoint.TopLevelSubMechanismIllustrationPoints);
+
+ return entity;
+ }
+
+ private static void AddEntitiesForStochasts(GeneralResultSubMechanismIllustrationPointEntity entity,
+ IEnumerable stochasts)
+ {
+ var order = 0;
+ foreach (Stochast stochast in stochasts)
+ {
+ entity.StochastEntities.Add(stochast.CreateStochastEntity(order++));
+ }
+ }
+
+ private static void AddEntitiesForTopLevelSubMechanismIllustrationPoints(
+ GeneralResultSubMechanismIllustrationPointEntity entity,
+ IEnumerable illustrationPoints)
+ {
+ var order = 0;
+ foreach (TopLevelSubMechanismIllustrationPoint illustrationPoint in illustrationPoints)
+ {
+ entity.TopLevelSubMechanismIllustrationPointEntities.Add(
+ illustrationPoint.CreateTopLevelSubMechanismIllustrationPointEntity(order++));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/SubMechanismIllustrationPointCreateExtensions.cs
===================================================================
diff -u -r560910bfaf8e8288710e0f91a0688f9e736b3edc -r2c08730c6c2269937fa4f117aed1557876c567ea
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/SubMechanismIllustrationPointCreateExtensions.cs (.../SubMechanismIllustrationPointCreateExtensions.cs) (revision 560910bfaf8e8288710e0f91a0688f9e736b3edc)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/IllustrationPoints/SubMechanismIllustrationPointCreateExtensions.cs (.../SubMechanismIllustrationPointCreateExtensions.cs) (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -56,14 +56,14 @@
Name = subMechanismIllustrationPoint.Name.DeepClone()
};
- AddEntitiesForSubMechanismIllustrationPoints(subMechanismIllustrationPoint.Stochasts, entity);
- AddEntitiesForIllustrationPointResults(subMechanismIllustrationPoint.IllustrationPointResults, entity);
+ AddEntitiesForSubMechanismIllustrationPoints(entity, subMechanismIllustrationPoint.Stochasts);
+ AddEntitiesForIllustrationPointResults(entity, subMechanismIllustrationPoint.IllustrationPointResults);
return entity;
}
- private static void AddEntitiesForIllustrationPointResults(IEnumerable illustrationPointResults,
- SubMechanismIllustrationPointEntity entity)
+ private static void AddEntitiesForIllustrationPointResults(SubMechanismIllustrationPointEntity entity,
+ IEnumerable illustrationPointResults)
{
var order = 0;
foreach (IllustrationPointResult illustrationPointResult in illustrationPointResults)
@@ -73,8 +73,8 @@
}
}
- private static void AddEntitiesForSubMechanismIllustrationPoints(IEnumerable stochasts,
- SubMechanismIllustrationPointEntity entity)
+ private static void AddEntitiesForSubMechanismIllustrationPoints(SubMechanismIllustrationPointEntity entity,
+ IEnumerable stochasts)
{
var order = 0;
foreach (SubMechanismIllustrationPointStochast subMechanismIllustrationPointStochast in stochasts)
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensions.cs (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -0,0 +1,82 @@
+// Copyright (C) Stichting Deltares 2017. 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 System.Collections.Generic;
+using System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Ringtoets.Common.Data.Hydraulics.IllustrationPoints;
+
+namespace Application.Ringtoets.Storage.Read.IllustrationPoints
+{
+ ///
+ /// Extension methods for
+ /// related to creating a .
+ ///
+ internal static class GeneralResultSubMechanismIllustrationPointEntityReadExtensions
+ {
+ ///
+ /// Reads the and uses
+ /// the information to construct a .
+ ///
+ /// The
+ /// to create a for.
+ /// A new .
+ /// Thrown when
+ /// is null.
+ public static GeneralResultSubMechanismIllustrationPoint Read(
+ this GeneralResultSubMechanismIllustrationPointEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
+ var governingWindDirection = new WindDirection(entity.GoverningWindDirectionName,
+ entity.GoverningWindDirectionAngle);
+
+ IEnumerable stochasts = GetReadStochasts(entity.StochastEntities);
+ IEnumerable illustrationPoints =
+ GetReadTopLevelSubMechanismIllustrationPoint(entity.TopLevelSubMechanismIllustrationPointEntities);
+
+ return new GeneralResultSubMechanismIllustrationPoint(governingWindDirection,
+ stochasts,
+ illustrationPoints);
+ }
+
+ private static IEnumerable GetReadStochasts(IEnumerable stochastEntities)
+ {
+ var stochasts = new List();
+ stochasts.AddRange(stochastEntities.OrderBy(st => st.Order)
+ .Select(st => st.Read()));
+ return stochasts;
+ }
+
+ private static IEnumerable GetReadTopLevelSubMechanismIllustrationPoint(
+ IEnumerable illustrationPointEntities)
+ {
+ var stochasts = new List();
+ stochasts.AddRange(illustrationPointEntities.OrderBy(st => st.Order)
+ .Select(st => st.Read()));
+ return stochasts;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r69586fc2b854c415c0472d56da2f7f6e0888c184 -r2c08730c6c2269937fa4f117aed1557876c567ea
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 69586fc2b854c415c0472d56da2f7f6e0888c184)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -90,6 +90,7 @@
+
@@ -126,8 +127,9 @@
+
-
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/GeneralResultSubMechanismIllustrationPointCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/GeneralResultSubMechanismIllustrationPointCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/GeneralResultSubMechanismIllustrationPointCreateExtensionsTest.cs (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -0,0 +1,201 @@
+// Copyright (C) Stichting Deltares 2017. 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 System.Linq;
+using Application.Ringtoets.Storage.Create.IllustrationPoints;
+using Application.Ringtoets.Storage.DbContext;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Data.TestUtil.IllustrationPoints;
+
+namespace Application.Ringtoets.Storage.Test.Create.IllustrationPoints
+{
+ [TestFixture]
+ public class GeneralResultSubMechanismIllustrationPointCreateExtensionsTest
+ {
+ [Test]
+ public void CreateGeneralResultSubMechanismIllustrationPointEntity_GeneralResultSubMechanismIllustraionPointNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((GeneralResultSubMechanismIllustrationPoint) null).CreateGeneralResultSubMechanismIllustrationPointEntity();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("generalResultSubMechanismIllustrationPoint", exception.ParamName);
+ }
+
+ [Test]
+ public void CreateGeneralResultSubMechanismIllustrationPointEntity_ValidGeneralResultSubMechanismIllustrationPoint_ReturnsEntity()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string windDirectionName = "SSE";
+ double windDirectionAngle = random.NextDouble();
+ var governingWindDirection = new WindDirection(windDirectionName, windDirectionAngle);
+
+ var generalResult =
+ new GeneralResultSubMechanismIllustrationPoint(governingWindDirection,
+ Enumerable.Empty(),
+ Enumerable.Empty());
+
+ // Call
+ GeneralResultSubMechanismIllustrationPointEntity entity =
+ generalResult.CreateGeneralResultSubMechanismIllustrationPointEntity();
+
+ // Assert
+ TestHelper.AssertAreEqualButNotSame(governingWindDirection.Name, entity.GoverningWindDirectionName);
+ Assert.AreEqual(governingWindDirection.Angle, entity.GoverningWindDirectionAngle,
+ governingWindDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(entity.StochastEntities);
+ CollectionAssert.IsEmpty(entity.TopLevelSubMechanismIllustrationPointEntities);
+ }
+
+ [Test]
+ public void CreateGeneralResultSubMechanismIllustrationPointEntity_ValidGeneralResultSubMechanismIllustrationPointWithStochasts_ReturnsEntity()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string windDirectionName = "SSE";
+ double windDirectionAngle = random.NextDouble();
+ var governingWindDirection = new WindDirection(windDirectionName, windDirectionAngle);
+
+ const string stochastName = "stochast";
+ double duration = random.NextDouble();
+ double alpha = random.NextDouble();
+ var stochastOne = new Stochast(stochastName, duration, alpha);
+ var stochastTwo = new Stochast($"{stochastName}_Two", duration + 1, alpha + 1);
+ var stochasts = new[]
+ {
+ stochastOne,
+ stochastTwo
+ };
+
+ var generalResult =
+ new GeneralResultSubMechanismIllustrationPoint(governingWindDirection,
+ stochasts,
+ Enumerable.Empty());
+
+ // Call
+ GeneralResultSubMechanismIllustrationPointEntity entity =
+ generalResult.CreateGeneralResultSubMechanismIllustrationPointEntity();
+
+ // Assert
+ TestHelper.AssertAreEqualButNotSame(governingWindDirection.Name, entity.GoverningWindDirectionName);
+ Assert.AreEqual(governingWindDirection.Angle, entity.GoverningWindDirectionAngle,
+ governingWindDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(entity.TopLevelSubMechanismIllustrationPointEntities);
+
+ StochastEntity[] stochastEntities = entity.StochastEntities.ToArray();
+ Assert.AreEqual(stochasts.Length, stochastEntities.Length);
+ for (var i = 0; i < stochasts.Length; i++)
+ {
+ Stochast stochast = stochasts[i];
+ StochastEntity stochastEntity = stochastEntities[i];
+
+ AssertCreatedStochastEntity(stochast, i, stochastEntity);
+ }
+ }
+
+ [Test]
+ public void CreateGeneralResultSubMechanismIllustrationPointEntity_ValidGeneralResultSubMechanismIllustrationPointWithIllustrationPoints_ReturnsEntity()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string windDirectionName = "SSE";
+ double windDirectionAngle = random.NextDouble();
+ var governingWindDirection = new WindDirection(windDirectionName, windDirectionAngle);
+
+ const string illustrationPointName = "illustrationPoint";
+ var illustrationPointOne = new TopLevelSubMechanismIllustrationPoint(new TestWindDirection(),
+ illustrationPointName,
+ new TestSubMechanismIllustrationPoint());
+ var illustrationPointTwo = new TopLevelSubMechanismIllustrationPoint(new TestWindDirection(),
+ $"{illustrationPointName}_Two",
+ new TestSubMechanismIllustrationPoint());
+ var illustrationPoints = new[]
+ {
+ illustrationPointOne,
+ illustrationPointTwo
+ };
+
+ var generalResult =
+ new GeneralResultSubMechanismIllustrationPoint(governingWindDirection,
+ Enumerable.Empty(),
+ illustrationPoints);
+
+ // Call
+ GeneralResultSubMechanismIllustrationPointEntity entity =
+ generalResult.CreateGeneralResultSubMechanismIllustrationPointEntity();
+
+ // Assert
+ TestHelper.AssertAreEqualButNotSame(governingWindDirection.Name, entity.GoverningWindDirectionName);
+ Assert.AreEqual(governingWindDirection.Angle, entity.GoverningWindDirectionAngle,
+ governingWindDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(entity.StochastEntities);
+
+ TopLevelSubMechanismIllustrationPointEntity[] illustrationPointEntities =
+ entity.TopLevelSubMechanismIllustrationPointEntities.ToArray();
+ Assert.AreEqual(illustrationPoints.Length, illustrationPointEntities.Length);
+ for (var i = 0; i < illustrationPoints.Length; i++)
+ {
+ TopLevelSubMechanismIllustrationPoint illustrationPoint = illustrationPoints[i];
+ TopLevelSubMechanismIllustrationPointEntity illustrationPointEntity = illustrationPointEntities[i];
+
+ AssertCreatedTopLevelSubMechanismIllustrationPointEntity(illustrationPoint, i, illustrationPointEntity);
+ }
+ }
+
+ private static void AssertCreatedStochastEntity(Stochast stochast,
+ int expectedOrder,
+ StochastEntity createdStochastEntity)
+ {
+ TestHelper.AssertAreEqualButNotSame(stochast.Name, createdStochastEntity.Name);
+ Assert.AreEqual(stochast.Duration, createdStochastEntity.Duration,
+ stochast.Duration.GetAccuracy());
+ Assert.AreEqual(stochast.Alpha, createdStochastEntity.Alpha,
+ stochast.Alpha.GetAccuracy());
+ Assert.AreEqual(expectedOrder, createdStochastEntity.Order);
+ }
+
+ private static void AssertCreatedTopLevelSubMechanismIllustrationPointEntity(TopLevelSubMechanismIllustrationPoint illustrationPoint,
+ int expectedOrder,
+ TopLevelSubMechanismIllustrationPointEntity illustrationPointEntity)
+ {
+ TestHelper.AssertAreEqualButNotSame(illustrationPoint.ClosingSituation,
+ illustrationPointEntity.ClosingSituation);
+
+ WindDirection expectedWindDirection = illustrationPoint.WindDirection;
+ TestHelper.AssertAreEqualButNotSame(expectedWindDirection.Name, illustrationPointEntity.WindDirectionName);
+ Assert.AreEqual(expectedWindDirection.Angle, illustrationPointEntity.WindDirectionAngle,
+ expectedWindDirection.Angle.GetAccuracy());
+
+ Assert.IsNotNull(illustrationPointEntity.SubMechanismIllustrationPointEntity);
+
+ Assert.AreEqual(expectedOrder, illustrationPointEntity.Order);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/SubMechanismIllustrationPointCreateExtensionsTest.cs
===================================================================
diff -u -r560910bfaf8e8288710e0f91a0688f9e736b3edc -r2c08730c6c2269937fa4f117aed1557876c567ea
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/SubMechanismIllustrationPointCreateExtensionsTest.cs (.../SubMechanismIllustrationPointCreateExtensionsTest.cs) (revision 560910bfaf8e8288710e0f91a0688f9e736b3edc)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/IllustrationPoints/SubMechanismIllustrationPointCreateExtensionsTest.cs (.../SubMechanismIllustrationPointCreateExtensionsTest.cs) (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -119,6 +119,7 @@
Assert.AreEqual(stochast.Duration, stochastEntity.Duration, stochast.Duration.GetAccuracy());
Assert.AreEqual(stochast.Alpha, stochastEntity.Alpha, stochast.Alpha.GetAccuracy());
Assert.AreEqual(stochast.Realization, stochastEntity.Realization, stochast.Realization.GetAccuracy());
+ Assert.AreEqual(i, stochastEntity.Order);
}
}
@@ -165,6 +166,7 @@
TestHelper.AssertAreEqualButNotSame(illustrationPointResult.Description, illustrationPointResultEntity.Description);
Assert.AreEqual(illustrationPointResult.Value, illustrationPointResultEntity.Value,
illustrationPointResult.Value.GetAccuracy());
+ Assert.AreEqual(i, illustrationPointResultEntity.Order);
}
}
}
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/GeneralResultSubMechanismIllustrationPointEntityReadExtensionsTest.cs (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -0,0 +1,210 @@
+// Copyright (C) Stichting Deltares 2017. 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 System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read.IllustrationPoints;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Data.TestUtil.IllustrationPoints;
+
+namespace Application.Ringtoets.Storage.Test.Read.IllustrationPoints
+{
+ [TestFixture]
+ public class GeneralResultSubMechanismIllustrationPointEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((GeneralResultSubMechanismIllustrationPointEntity) null).Read();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_ValidEntityWithoutStochastsAndIllustrationPoints_ReturnsGeneralResultSubMechanismIllustrationPoint()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string windDirectionName = "SSE";
+ double windDirectionAngle = random.NextDouble();
+ var entity = new GeneralResultSubMechanismIllustrationPointEntity
+ {
+ GoverningWindDirectionName = windDirectionName,
+ GoverningWindDirectionAngle = windDirectionAngle
+ };
+
+ // Call
+ GeneralResultSubMechanismIllustrationPoint generalResult = entity.Read();
+
+ // Assert
+ WindDirection actualGoverningWindDirection = generalResult.GoverningWindDirection;
+ Assert.AreEqual(entity.GoverningWindDirectionName, actualGoverningWindDirection.Name);
+ Assert.AreEqual(entity.GoverningWindDirectionAngle, actualGoverningWindDirection.Angle,
+ actualGoverningWindDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(generalResult.Stochasts);
+ CollectionAssert.IsEmpty(generalResult.TopLevelSubMechanismIllustrationPoints);
+ }
+
+ [Test]
+ public void Read_ValidEntityWithStochasts_ReturnsGeneralResultSubMechanismIllustrationPoint()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string stochastName = "Stochast Name";
+ double alpha = random.NextDouble();
+ double duration = random.NextDouble();
+ var stochastEntityOne = new StochastEntity
+ {
+ Name = stochastName,
+ Duration = duration,
+ Alpha = alpha,
+ Order = 0
+ };
+ var stochastEntityTwo = new StochastEntity
+ {
+ Name = $"{stochastName}_Two",
+ Duration = duration + 1,
+ Alpha = alpha + 1,
+ Order = 1
+ };
+
+ const string windDirectionName = "SSE";
+ double windDirectionAngle = random.NextDouble();
+ var entity = new GeneralResultSubMechanismIllustrationPointEntity
+ {
+ GoverningWindDirectionName = windDirectionName,
+ GoverningWindDirectionAngle = windDirectionAngle,
+ StochastEntities = new[]
+ {
+ stochastEntityTwo,
+ stochastEntityOne
+ }
+ };
+
+ // Call
+ GeneralResultSubMechanismIllustrationPoint generalResult = entity.Read();
+
+ // Assert
+ WindDirection actualGoverningWindDirection = generalResult.GoverningWindDirection;
+ Assert.AreEqual(entity.GoverningWindDirectionName, actualGoverningWindDirection.Name);
+ Assert.AreEqual(entity.GoverningWindDirectionAngle, actualGoverningWindDirection.Angle,
+ actualGoverningWindDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(generalResult.TopLevelSubMechanismIllustrationPoints);
+
+ Stochast[] stochasts = generalResult.Stochasts.ToArray();
+ Assert.AreEqual(2, stochasts.Length);
+ AssertReadStochast(stochastEntityOne, stochasts[0]);
+ AssertReadStochast(stochastEntityTwo, stochasts[1]);
+ }
+
+ [Test]
+ public void Read_ValidEntityWithIllustrationPoints_ReturnsGeneralResultSubMechanismIllustrationPoint()
+ {
+ // Setup
+ const string stochastName = "Stochast Name";
+ WindDirection windDirection = new TestWindDirection();
+ SubMechanismIllustrationPoint illustrationPoint = new TestSubMechanismIllustrationPoint();
+ var illustrationPointEntityOne = new TopLevelSubMechanismIllustrationPointEntity
+ {
+ WindDirectionName = windDirection.Name,
+ WindDirectionAngle = windDirection.Angle,
+ ClosingSituation = stochastName,
+ SubMechanismIllustrationPointEntity = new SubMechanismIllustrationPointEntity
+ {
+ Beta = illustrationPoint.Beta,
+ Name = illustrationPoint.Name
+ },
+ Order = 0
+ };
+ var illustrationPointEntityTwo = new TopLevelSubMechanismIllustrationPointEntity
+ {
+ WindDirectionName = windDirection.Name,
+ WindDirectionAngle = windDirection.Angle,
+ ClosingSituation = stochastName,
+ SubMechanismIllustrationPointEntity = new SubMechanismIllustrationPointEntity
+ {
+ Beta = illustrationPoint.Beta,
+ Name = illustrationPoint.Name
+ },
+ Order = 1
+ };
+
+ var random = new Random(21);
+ double windDirectionAngle = random.NextDouble();
+ const string windDirectionName = "SSE";
+ var entity = new GeneralResultSubMechanismIllustrationPointEntity
+ {
+ GoverningWindDirectionName = windDirectionName,
+ GoverningWindDirectionAngle = windDirectionAngle,
+ TopLevelSubMechanismIllustrationPointEntities = new[]
+ {
+ illustrationPointEntityTwo,
+ illustrationPointEntityOne
+ }
+ };
+
+ // Call
+ GeneralResultSubMechanismIllustrationPoint generalResult = entity.Read();
+
+ // Assert
+ WindDirection actualGoverningWindDirection = generalResult.GoverningWindDirection;
+ Assert.AreEqual(entity.GoverningWindDirectionName, actualGoverningWindDirection.Name);
+ Assert.AreEqual(entity.GoverningWindDirectionAngle, actualGoverningWindDirection.Angle,
+ actualGoverningWindDirection.Angle.GetAccuracy());
+ CollectionAssert.IsEmpty(generalResult.Stochasts);
+
+ TopLevelSubMechanismIllustrationPoint[] illustrationPoints =
+ generalResult.TopLevelSubMechanismIllustrationPoints.ToArray();
+ Assert.AreEqual(2, illustrationPoints.Length);
+ AssertReadTopLevelSubMechanismIllustrationPoint(illustrationPointEntityOne, illustrationPoints[0]);
+ AssertReadTopLevelSubMechanismIllustrationPoint(illustrationPointEntityOne, illustrationPoints[1]);
+ }
+
+ private static void AssertReadTopLevelSubMechanismIllustrationPoint(
+ TopLevelSubMechanismIllustrationPointEntity illustrationPointEntity,
+ TopLevelSubMechanismIllustrationPoint readTopLevelSubMechanismIllustrationPoint)
+ {
+ Assert.AreEqual(illustrationPointEntity.ClosingSituation, readTopLevelSubMechanismIllustrationPoint.ClosingSituation);
+
+ WindDirection actualWindDirection = readTopLevelSubMechanismIllustrationPoint.WindDirection;
+ Assert.AreEqual(illustrationPointEntity.WindDirectionName, actualWindDirection.Name);
+ Assert.AreEqual(illustrationPointEntity.WindDirectionAngle, actualWindDirection.Angle, actualWindDirection.Angle);
+
+ Assert.IsNotNull(readTopLevelSubMechanismIllustrationPoint.SubMechanismIllustrationPoint);
+ }
+
+ private static void AssertReadStochast(StochastEntity stochastEntity,
+ Stochast readStochast)
+ {
+ Assert.AreEqual(stochastEntity.Name, readStochast.Name);
+ Assert.AreEqual(stochastEntity.Alpha, readStochast.Alpha, readStochast.Alpha.GetAccuracy());
+ Assert.AreEqual(stochastEntity.Duration, readStochast.Duration, readStochast.Duration.GetAccuracy());
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/SubMechanismIllustrationPointEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/SubMechanismIllustrationPointEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/SubMechanismIllustrationPointEntityReadExtensionsTest.cs (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -0,0 +1,190 @@
+// Copyright (C) Stichting Deltares 2017. 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 System.Linq;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Read.IllustrationPoints;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil;
+
+namespace Application.Ringtoets.Storage.Test.Read.IllustrationPoints
+{
+ [TestFixture]
+ public class SubMechanismIllustrationPointEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((SubMechanismIllustrationPointEntity) null).Read();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_ValidEntityWithoutStochastsAndIllustrationPointResults_ReturnsSubMechanismIllustrationPoint()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string illustrationPointName = "Name";
+ double beta = random.NextDouble();
+ var entity = new SubMechanismIllustrationPointEntity
+ {
+ Name = illustrationPointName,
+ Beta = beta
+ };
+
+ // Call
+ SubMechanismIllustrationPoint illustrationPoint = entity.Read();
+
+ // Assert
+ Assert.AreEqual(entity.Name, illustrationPoint.Name);
+ Assert.AreEqual(entity.Beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy());
+
+ CollectionAssert.IsEmpty(illustrationPoint.IllustrationPointResults);
+ CollectionAssert.IsEmpty(illustrationPoint.Stochasts);
+ }
+
+ [Test]
+ public void Read_ValidEntityWithIllustrationPointResults_ReturnsSubMechanismIllustrationPoint()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string illustrationPointResultDescription = "Description";
+ double value = random.NextDouble();
+ var illustrationPointResultEntityOne = new IllustrationPointResultEntity
+ {
+ Description = illustrationPointResultDescription,
+ Value = value,
+ Order = 0
+ };
+ var illustrationPointResultEntityTwo = new IllustrationPointResultEntity
+ {
+ Description = $"{illustrationPointResultDescription}_Two",
+ Value = value + 1,
+ Order = 1
+ };
+
+ const string illustrationPointName = "Name";
+ double beta = random.NextDouble();
+ var entity = new SubMechanismIllustrationPointEntity
+ {
+ Name = illustrationPointName,
+ Beta = beta,
+ IllustrationPointResultEntities = new[]
+ {
+ illustrationPointResultEntityTwo,
+ illustrationPointResultEntityOne
+ }
+ };
+
+ // Call
+ SubMechanismIllustrationPoint illustrationPoint = entity.Read();
+
+ // Assert
+ Assert.AreEqual(entity.Name, illustrationPoint.Name);
+ Assert.AreEqual(entity.Beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy());
+ CollectionAssert.IsEmpty(illustrationPoint.Stochasts);
+
+ IllustrationPointResult[] illustrationPointResults = illustrationPoint.IllustrationPointResults.ToArray();
+ Assert.AreEqual(2, illustrationPointResults.Length);
+ AssertReadIllustrationPointResult(illustrationPointResultEntityOne, illustrationPointResults[0]);
+ AssertReadIllustrationPointResult(illustrationPointResultEntityTwo, illustrationPointResults[1]);
+ }
+
+ [Test]
+ public void Read_ValidEntityWithStochasts_ReturnsSubMechanismIllustrationPoint()
+ {
+ // Setup
+ var random = new Random(21);
+
+ const string stochastName = "Stochast";
+ double alpha = random.NextDouble();
+ double realization = random.NextDouble();
+ double duration = random.NextDouble();
+ var stochastEntityOne = new SubMechanismIllustrationPointStochastEntity
+ {
+ Name = stochastName,
+ Alpha = alpha,
+ Duration = duration,
+ Realization = realization,
+ Order = 0
+ };
+ var stochastEntityTwo = new SubMechanismIllustrationPointStochastEntity
+ {
+ Name = $"{stochastName}_Two",
+ Alpha = alpha + 1,
+ Duration = duration + 1,
+ Realization = realization + 1,
+ Order = 1
+ };
+
+ const string illustrationPointName = "Name";
+ double beta = random.NextDouble();
+ var entity = new SubMechanismIllustrationPointEntity
+ {
+ Name = illustrationPointName,
+ Beta = beta,
+ SubMechanismIllustrationPointStochastEntities = new[]
+ {
+ stochastEntityTwo,
+ stochastEntityOne
+ }
+ };
+
+ // Call
+ SubMechanismIllustrationPoint illustrationPoint = entity.Read();
+
+ // Assert
+ Assert.AreEqual(entity.Name, illustrationPoint.Name);
+ Assert.AreEqual(entity.Beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy());
+ CollectionAssert.IsEmpty(illustrationPoint.IllustrationPointResults);
+
+ SubMechanismIllustrationPointStochast[] stochasts = illustrationPoint.Stochasts.ToArray();
+ Assert.AreEqual(2, stochasts.Length);
+ AssertReadStochast(stochastEntityOne, stochasts[0]);
+ AssertReadStochast(stochastEntityTwo, stochasts[1]);
+ }
+
+ private static void AssertReadIllustrationPointResult(IllustrationPointResultEntity illustrationPointResultEntity,
+ IllustrationPointResult readIllustrationPointResult)
+ {
+ Assert.AreEqual(illustrationPointResultEntity.Description, readIllustrationPointResult.Description);
+ Assert.AreEqual(illustrationPointResultEntity.Value, readIllustrationPointResult.Value,
+ readIllustrationPointResult.Value.GetAccuracy());
+ }
+
+ private static void AssertReadStochast(SubMechanismIllustrationPointStochastEntity stochastEntity,
+ SubMechanismIllustrationPointStochast readStochast)
+ {
+ Assert.AreEqual(stochastEntity.Name, readStochast.Name);
+ Assert.AreEqual(stochastEntity.Alpha, readStochast.Alpha, readStochast.Alpha.GetAccuracy());
+ Assert.AreEqual(stochastEntity.Duration, readStochast.Duration, readStochast.Duration.GetAccuracy());
+ Assert.AreEqual(stochastEntity.Realization, readStochast.Realization, readStochast.Realization.GetAccuracy());
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 2c08730c6c2269937fa4f117aed1557876c567ea refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/IllustrationPoints/SubMechanismIllustrationPointReadExtensionsTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultSubMechanismIllustrationPointTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultSubMechanismIllustrationPointTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultSubMechanismIllustrationPointTest.cs (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -0,0 +1,55 @@
+// Copyright (C) Stichting Deltares 2017. 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 NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil.IllustrationPoints;
+
+namespace Ringtoets.Common.Data.TestUtil.Test.IllustrationPoints
+{
+ [TestFixture]
+ public class TestGeneralResultSubMechanismIllustrationPointTest
+ {
+ [Test]
+ public void Constructor_ExpectedProperties()
+ {
+ // Call
+ var generalResult = new TestGeneralResultSubMechanismIllustrationPoint();
+
+ // Assert
+ Assert.IsInstanceOf(generalResult);
+ AssertWindDirection(new TestWindDirection(), generalResult.GoverningWindDirection);
+ CollectionAssert.IsEmpty(generalResult.Stochasts);
+ CollectionAssert.IsEmpty(generalResult.TopLevelSubMechanismIllustrationPoints);
+ }
+
+ private static void AssertWindDirection(WindDirection expected, WindDirection actual)
+ {
+ if (expected == null)
+ {
+ Assert.IsNull(actual);
+ return;
+ }
+ Assert.AreEqual(expected.Name, actual.Name);
+ Assert.AreEqual(expected.Angle, actual.Angle);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 2c08730c6c2269937fa4f117aed1557876c567ea refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/TestGeneralResultTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj
===================================================================
diff -u -r6a60e0e3f676c71e253ad41839519c18dd641e9e -r2c08730c6c2269937fa4f117aed1557876c567ea
--- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision 6a60e0e3f676c71e253ad41839519c18dd641e9e)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision 2c08730c6c2269937fa4f117aed1557876c567ea)
@@ -55,7 +55,7 @@
-
+