Index: Ringtoets/Common/src/Ringtoets.Common.Service/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverter.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Service/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverter.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverter.cs (revision a1d26cb03e95b46fe8600b53a8e91dfde417ca56)
@@ -0,0 +1,69 @@
+// 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 Ringtoets.Common.Data.IllustrationPoints;
+using HydraRingWindDirectionClosingSituation = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.WindDirectionClosingSituation;
+using HydraRingIllustrationPointTreeNode = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.IllustrationPointTreeNode;
+
+namespace Ringtoets.Common.Service.IllustrationPoints
+{
+ ///
+ /// Converter for and
+ /// related to creating a
+ /// .
+ ///
+ public static class TopLevelFaultTreeIllustrationPointConverter
+ {
+ ///
+ /// Creates a new instance of
+ /// based on the information of
+ /// and .
+ ///
+ /// The
+ /// to base the on.
+ /// The
+ /// to base the on.
+ /// A .
+ /// Thrown when any input parameter
+ /// is null.
+ /// Thrown when
+ /// has tree node elements which do not contain exactly 0 or 2 children.
+ public static TopLevelFaultTreeIllustrationPoint Create(HydraRingWindDirectionClosingSituation hydraRingWindDirectionClosingSituation,
+ HydraRingIllustrationPointTreeNode hydraRingIllustrationPointTreeNode)
+ {
+ if (hydraRingWindDirectionClosingSituation == null)
+ {
+ throw new ArgumentNullException(nameof(hydraRingWindDirectionClosingSituation));
+ }
+ if (hydraRingIllustrationPointTreeNode == null)
+ {
+ throw new ArgumentNullException(nameof(hydraRingIllustrationPointTreeNode));
+ }
+
+ WindDirection windDirection = WindDirectionConverter.Create(hydraRingWindDirectionClosingSituation.WindDirection);
+
+ return new TopLevelFaultTreeIllustrationPoint(windDirection,
+ hydraRingWindDirectionClosingSituation.ClosingSituation,
+ IllustrationPointNodeConverter.Create(hydraRingIllustrationPointTreeNode));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Service/Ringtoets.Common.Service.csproj
===================================================================
diff -u -rfc1d79e8dac002800fff0d485a63f4b400f8ab2b -ra1d26cb03e95b46fe8600b53a8e91dfde417ca56
--- Ringtoets/Common/src/Ringtoets.Common.Service/Ringtoets.Common.Service.csproj (.../Ringtoets.Common.Service.csproj) (revision fc1d79e8dac002800fff0d485a63f4b400f8ab2b)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/Ringtoets.Common.Service.csproj (.../Ringtoets.Common.Service.csproj) (revision a1d26cb03e95b46fe8600b53a8e91dfde417ca56)
@@ -55,6 +55,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverterTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverterTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointConverterTest.cs (revision a1d26cb03e95b46fe8600b53a8e91dfde417ca56)
@@ -0,0 +1,208 @@
+// 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 NUnit.Framework;
+using Ringtoets.Common.Data.IllustrationPoints;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Service.IllustrationPoints;
+using HydraRingIllustrationPointTreeNode = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.IllustrationPointTreeNode;
+using HydraRingTestWindDirection = Ringtoets.HydraRing.Calculation.TestUtil.IllustrationPoints.TestWindDirection;
+using CombinationType = Ringtoets.Common.Data.IllustrationPoints.CombinationType;
+using FaultTreeIllustrationPoint = Ringtoets.Common.Data.IllustrationPoints.FaultTreeIllustrationPoint;
+using HydraRingCombinationType = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.CombinationType;
+using HydraRingWindDirection = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.WindDirection;
+using HydraRingWindDirectionClosingSituation = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.WindDirectionClosingSituation;
+using HydraRingStochast = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.Stochast;
+using HydraRingSubMechanismIllustrationPointStochast = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.SubMechanismIllustrationPointStochast;
+using HydraRingFaultTreeIllustrationPoint = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.FaultTreeIllustrationPoint;
+using HydraRingSubMechanismIllustrationPoint = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.SubMechanismIllustrationPoint;
+using HydraRingIllustrationPointResult = Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints.IllustrationPointResult;
+using Stochast = Ringtoets.Common.Data.IllustrationPoints.Stochast;
+using WindDirection = Ringtoets.Common.Data.IllustrationPoints.WindDirection;
+
+namespace Ringtoets.Common.Service.Test.IllustrationPoints
+{
+ [TestFixture]
+ public class TopLevelFaultTreeIllustrationPointConverterTest
+ {
+ [Test]
+ public void Create_HydraRingWindDirectionClosingSituationNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var random = new Random(21);
+ var hydraRingStochast = new HydraRingStochast("random stochast",
+ random.NextDouble(),
+ random.NextDouble());
+
+ var hydraRingFaultTreeIllustrationPoint = new HydraRingFaultTreeIllustrationPoint("fault tree", random.NextDouble(),
+ new[]
+ {
+ hydraRingStochast
+ }, HydraRingCombinationType.And);
+
+ var treeNode = new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPoint);
+
+ // Call
+ TestDelegate call = () => TopLevelFaultTreeIllustrationPointConverter.Create(null, treeNode);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("hydraRingWindDirectionClosingSituation", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_HydraRingIllustrationPointTreeNodeNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(new HydraRingTestWindDirection(),
+ "random closing situation");
+
+ // Call
+ TestDelegate call = () => TopLevelFaultTreeIllustrationPointConverter.Create(hydraRingWindDirectionClosingSituation, null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("hydraRingIllustrationPointTreeNode", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_ValidHydraRingFaultTreeIllustrationPointWithoutChildren_ExpectedProperties()
+ {
+ // Setup
+ var random = new Random(21);
+ var hydraRingWindDirection = new HydraRingWindDirection("random name", random.NextDouble());
+
+ var hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(hydraRingWindDirection,
+ "random closing situation");
+
+ var hydraRingStochast = new HydraRingStochast("random stochast",
+ random.NextDouble(),
+ random.NextDouble());
+
+ var hydraRingFaultTreeIllustrationPoint = new HydraRingFaultTreeIllustrationPoint("fault tree", random.NextDouble(),
+ new[]
+ {
+ hydraRingStochast
+ }, HydraRingCombinationType.And);
+
+ var treeNode = new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPoint);
+
+ // Call
+ TopLevelFaultTreeIllustrationPoint topLevelIllustrationPoint =
+ TopLevelFaultTreeIllustrationPointConverter.Create(hydraRingWindDirectionClosingSituation, treeNode);
+
+ // Assert
+ WindDirection windDirection = topLevelIllustrationPoint.WindDirection;
+ Assert.AreEqual(hydraRingWindDirection.Angle, windDirection.Angle, windDirection.Angle.GetAccuracy());
+ Assert.AreEqual(hydraRingWindDirection.Name, windDirection.Name);
+
+ Assert.AreEqual(hydraRingWindDirectionClosingSituation.ClosingSituation, topLevelIllustrationPoint.ClosingSituation);
+ IllustrationPointNode illustrationPoint = topLevelIllustrationPoint.FaultTreeNodeRoot;
+ CollectionAssert.IsEmpty(illustrationPoint.Children);
+
+ var illustrationPointData = (FaultTreeIllustrationPoint) illustrationPoint.Data;
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPoint.Name, illustrationPointData.Name);
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPoint.Beta, illustrationPointData.Beta, illustrationPointData.Beta.GetAccuracy());
+ Assert.AreEqual(CombinationType.And, illustrationPointData.CombinationType);
+
+ Stochast stochast = illustrationPointData.Stochasts.Single();
+ Assert.AreEqual(hydraRingStochast.Alpha, stochast.Alpha, stochast.Alpha.GetAccuracy());
+ Assert.AreEqual(hydraRingStochast.Duration, stochast.Duration, stochast.Duration.GetAccuracy());
+ Assert.AreEqual(hydraRingStochast.Name, stochast.Name);
+ }
+
+ [Test]
+ public void Create_ValidHydraRingFaultTreeIllustrationPointWithChildren_ExpectedProperties()
+ {
+ // Setup
+ var random = new Random(21);
+ var hydraRingWindDirection = new HydraRingWindDirection("random name", random.NextDouble());
+
+ var hydraRingWindDirectionClosingSituation = new HydraRingWindDirectionClosingSituation(hydraRingWindDirection,
+ "random closing situation");
+
+ var hydraRingStochast = new HydraRingStochast("random stochast",
+ random.NextDouble(),
+ random.NextDouble());
+
+ var hydraRingFaultTreeIllustrationPointRoot = new HydraRingFaultTreeIllustrationPoint("fault tree root", random.NextDouble(),
+ new[]
+ {
+ hydraRingStochast
+ }, HydraRingCombinationType.And);
+
+ var hydraRingFaultTreeIllustrationPointChildOne = new HydraRingFaultTreeIllustrationPoint("fault tree child one",
+ random.NextDouble(),
+ Enumerable.Empty(),
+ HydraRingCombinationType.Or);
+
+ var hydraRingFaultTreeIllustrationPointChildTwo = new HydraRingSubMechanismIllustrationPoint("fault tree child two",
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ random.NextDouble());
+
+ var treeNodeRoot = new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPointRoot);
+ treeNodeRoot.Children.Add(new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPointChildOne));
+ treeNodeRoot.Children.Add(new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPointChildTwo));
+
+ // Call
+ TopLevelFaultTreeIllustrationPoint topLevelIllustrationPoint =
+ TopLevelFaultTreeIllustrationPointConverter.Create(hydraRingWindDirectionClosingSituation, treeNodeRoot);
+
+ // Assert
+ WindDirection windDirection = topLevelIllustrationPoint.WindDirection;
+ Assert.AreEqual(hydraRingWindDirection.Angle, windDirection.Angle, windDirection.Angle.GetAccuracy());
+ Assert.AreEqual(hydraRingWindDirection.Name, windDirection.Name);
+
+ Assert.AreEqual(hydraRingWindDirectionClosingSituation.ClosingSituation, topLevelIllustrationPoint.ClosingSituation);
+ IllustrationPointNode illustrationPoint = topLevelIllustrationPoint.FaultTreeNodeRoot;
+
+ var illustrationPointData = (FaultTreeIllustrationPoint) illustrationPoint.Data;
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPointRoot.Name, illustrationPointData.Name);
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPointRoot.Beta, illustrationPointData.Beta, illustrationPointData.Beta.GetAccuracy());
+ Assert.AreEqual(CombinationType.And, illustrationPointData.CombinationType);
+
+ Stochast stochast = illustrationPointData.Stochasts.Single();
+ Assert.AreEqual(hydraRingStochast.Alpha, stochast.Alpha, stochast.Alpha.GetAccuracy());
+ Assert.AreEqual(hydraRingStochast.Duration, stochast.Duration, stochast.Duration.GetAccuracy());
+ Assert.AreEqual(hydraRingStochast.Name, stochast.Name);
+
+ Assert.AreEqual(treeNodeRoot.Children.Count, illustrationPoint.Children.Count());
+ IllustrationPointNode[] children = illustrationPoint.Children.ToArray();
+ CollectionAssert.IsEmpty(children[0].Children);
+ CollectionAssert.IsEmpty(children[1].Children);
+
+ var childOne = (FaultTreeIllustrationPoint)children[0].Data;
+ CollectionAssert.IsEmpty(childOne.Stochasts);
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPointChildOne.Name, childOne.Name);
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPointChildOne.Beta, childOne.Beta, childOne.Beta.GetAccuracy());
+ Assert.AreEqual(CombinationType.Or, childOne.CombinationType);
+
+ var childTwo = (SubMechanismIllustrationPoint)children[1].Data;
+ CollectionAssert.IsEmpty(childTwo.Stochasts);
+ CollectionAssert.IsEmpty(childTwo.IllustrationPointResults);
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPointChildTwo.Name, childTwo.Name);
+ Assert.AreEqual(hydraRingFaultTreeIllustrationPointChildTwo.Beta, childTwo.Beta, childTwo.Beta.GetAccuracy());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointConverterTest.cs
===================================================================
diff -u -r6eabea7a72771b62ff8b173b9b37f5b89ed403f3 -ra1d26cb03e95b46fe8600b53a8e91dfde417ca56
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointConverterTest.cs (.../TopLevelSubMechanismIllustrationPointConverterTest.cs) (revision 6eabea7a72771b62ff8b173b9b37f5b89ed403f3)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointConverterTest.cs (.../TopLevelSubMechanismIllustrationPointConverterTest.cs) (revision a1d26cb03e95b46fe8600b53a8e91dfde417ca56)
@@ -78,7 +78,6 @@
public void Create_ValidArguments_ExpectedProperties()
{
// Setup
-
var random = new Random(21);
var hydraRingWindDirection = new HydraRingWindDirection("Name", random.NextDouble());
@@ -94,14 +93,13 @@
random.NextDouble(),
random.NextDouble());
- double beta = random.NextDouble();
var hydraRingSubMechanismIllustrationPoint = new HydraRingSubMechanismIllustrationPoint("name", new[]
{
hydraRingSubMechanismIllustrationPointStochast
}, new[]
{
hydraRingIllustrationPointResult
- }, beta);
+ }, random.NextDouble());
// Call
TopLevelSubMechanismIllustrationPoint combination =
@@ -113,7 +111,7 @@
Assert.AreEqual(hydraRingWindDirection.Angle, windDirection.Angle, windDirection.Angle.GetAccuracy());
Assert.AreEqual(hydraRingWindDirection.Name, windDirection.Name);
- Assert.AreEqual("closing scenario", combination.ClosingSituation);
+ Assert.AreEqual(hydraRingWindDirectionClosingSituation.ClosingSituation, combination.ClosingSituation);
SubMechanismIllustrationPoint subMechanismIllustrationPoint = combination.SubMechanismIllustrationPoint;
Assert.AreEqual(hydraRingSubMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta, subMechanismIllustrationPoint.Beta.GetAccuracy());
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj
===================================================================
diff -u -rfc1d79e8dac002800fff0d485a63f4b400f8ab2b -ra1d26cb03e95b46fe8600b53a8e91dfde417ca56
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision fc1d79e8dac002800fff0d485a63f4b400f8ab2b)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/Ringtoets.Common.Service.Test.csproj (.../Ringtoets.Common.Service.Test.csproj) (revision a1d26cb03e95b46fe8600b53a8e91dfde417ca56)
@@ -72,6 +72,7 @@
+