Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/IllustrationPointNode.cs
===================================================================
diff -u -rf95a6fe33de7536ebff9698dccdb74b492cbb7e7 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/IllustrationPointNode.cs (.../IllustrationPointNode.cs) (revision f95a6fe33de7536ebff9698dccdb74b492cbb7e7)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/IllustrationPointNode.cs (.../IllustrationPointNode.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -80,7 +80,7 @@
}
else
{
- throw new ArgumentException(Resources.FaultTreeIllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes,
+ throw new ArgumentException(Resources.IllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes,
nameof(children));
}
}
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs
===================================================================
diff -u -r6d60c1b06ad01314179bc7d953765e46a41b841c -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -391,16 +391,6 @@
}
///
- /// Looks up a localized string similar to Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben..
- ///
- public static string FaultTreeIllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes {
- get {
- return ResourceManager.GetString("FaultTreeIllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes" +
- "", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Een punt in de geometrie voor het voorlandprofiel heeft geen waarde..
///
public static string ForeshoreProfile_SetGeometry_A_point_in_the_collection_is_null {
@@ -437,6 +427,15 @@
}
///
+ /// Looks up a localized string similar to Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben..
+ ///
+ public static string IllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes {
+ get {
+ return ResourceManager.GetString("IllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Gemiddelde moet groter zijn dan 0..
///
public static string LogNormalDistribution_Mean_must_be_greater_than_zero {
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx
===================================================================
diff -u -r6d60c1b06ad01314179bc7d953765e46a41b841c -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -303,7 +303,7 @@
De waarde voor de windrichting moet in het bereik {0} liggen.
-
+
Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben.
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/IllustrationPointNodeTest.cs
===================================================================
diff -u -rf95a6fe33de7536ebff9698dccdb74b492cbb7e7 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/IllustrationPointNodeTest.cs (.../IllustrationPointNodeTest.cs) (revision f95a6fe33de7536ebff9698dccdb74b492cbb7e7)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/IllustrationPointNodeTest.cs (.../IllustrationPointNodeTest.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -49,21 +49,21 @@
var data = new TestIllustrationPoint();
// Call
- var faultTreeNode = new IllustrationPointNode(data);
+ var treeNode = new IllustrationPointNode(data);
// Assert
- Assert.AreSame(data, faultTreeNode.Data);
- Assert.IsEmpty(faultTreeNode.Children);
+ Assert.AreSame(data, treeNode.Data);
+ Assert.IsEmpty(treeNode.Children);
}
[Test]
public void SetChildren_ChildrenNull_ThrowsArgumentNullException()
{
// Setup
- var faultTreeNode = new IllustrationPointNode(new TestIllustrationPoint());
+ var treeNode = new IllustrationPointNode(new TestIllustrationPoint());
// Call
- TestDelegate call = () => faultTreeNode.SetChildren(null);
+ TestDelegate call = () => treeNode.SetChildren(null);
// Assert
var exception = Assert.Throws(call);
@@ -76,7 +76,7 @@
public void SetChildren_InvalidNrOfChildren_ThrowsInvalidArgumentException(int nrOfChildren)
{
// Setup
- var faultTreeNode = new IllustrationPointNode(new TestIllustrationPoint());
+ var treeNode = new IllustrationPointNode(new TestIllustrationPoint());
var childrenToBeAttached = new List();
for (var i = 0; i < nrOfChildren; i++)
@@ -85,7 +85,7 @@
}
// Call
- TestDelegate call = () => faultTreeNode.SetChildren(childrenToBeAttached.ToArray());
+ TestDelegate call = () => treeNode.SetChildren(childrenToBeAttached.ToArray());
// Assert
const string expectedMessage = "Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben.";
@@ -97,20 +97,20 @@
public void SetChildren_NoChildren_ReturnsExpectedProperties()
{
// Setup
- var faultTreeNode = new IllustrationPointNode(new TestIllustrationPoint());
+ var treeNode = new IllustrationPointNode(new TestIllustrationPoint());
// Call
- faultTreeNode.SetChildren(new IllustrationPointNode[0]);
+ treeNode.SetChildren(new IllustrationPointNode[0]);
// Assert
- CollectionAssert.IsEmpty(faultTreeNode.Children);
+ CollectionAssert.IsEmpty(treeNode.Children);
}
[Test]
public void SetChildren_TwoChildren_ReturnsExpectedProperties()
{
// Setup
- var faultTreeNode = new IllustrationPointNode(new TestIllustrationPoint());
+ var treeNode = new IllustrationPointNode(new TestIllustrationPoint());
var childrenToBeAttached = new[]
{
@@ -119,10 +119,10 @@
};
// Call
- faultTreeNode.SetChildren(childrenToBeAttached);
+ treeNode.SetChildren(childrenToBeAttached);
// Assert
- CollectionAssert.AreEqual(childrenToBeAttached, faultTreeNode.Children);
+ CollectionAssert.AreEqual(childrenToBeAttached, treeNode.Children);
}
}
}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/IllustrationPointNodeConverterTest.cs
===================================================================
diff -u -rfc1d79e8dac002800fff0d485a63f4b400f8ab2b -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/IllustrationPointNodeConverterTest.cs (.../IllustrationPointNodeConverterTest.cs) (revision fc1d79e8dac002800fff0d485a63f4b400f8ab2b)
+++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/IllustrationPoints/IllustrationPointNodeConverterTest.cs (.../IllustrationPointNodeConverterTest.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -129,11 +129,17 @@
var nestedHydraRingSubMechanismIllustrationPointTreeNode = new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint());
var nestedHydraRingFaultTreeIllustrationPointTreeNode = new HydraRingIllustrationPointTreeNode(new TestHydraRingFaultTreeIllustrationPoint());
- nestedHydraRingFaultTreeIllustrationPointTreeNode.Children.Add(new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint()));
- nestedHydraRingFaultTreeIllustrationPointTreeNode.Children.Add(new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint()));
+ nestedHydraRingFaultTreeIllustrationPointTreeNode.SetChildren(new[]
+ {
+ new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint()),
+ new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint())
+ });
- hydraRingIllustrationPointTreeNode.Children.Add(nestedHydraRingSubMechanismIllustrationPointTreeNode);
- hydraRingIllustrationPointTreeNode.Children.Add(nestedHydraRingFaultTreeIllustrationPointTreeNode);
+ hydraRingIllustrationPointTreeNode.SetChildren(new[]
+ {
+ nestedHydraRingSubMechanismIllustrationPointTreeNode,
+ nestedHydraRingFaultTreeIllustrationPointTreeNode
+ });
// Call
IllustrationPointNode illustrationPointNode = IllustrationPointNodeConverter.Create(hydraRingIllustrationPointTreeNode);
@@ -146,24 +152,5 @@
CollectionAssert.IsEmpty(children[0].Children);
Assert.AreEqual(2, children[1].Children.Count());
}
-
- [Test]
- public void Create_TreeNodeWithInvalidNumberOfChildren_ThrowsArgumentException()
- {
- // Setup
- var hydraRingFaultTreeIllustrationPoint = new TestHydraRingFaultTreeIllustrationPoint();
- var hydraRingIllustrationPointTreeNode = new HydraRingIllustrationPointTreeNode(hydraRingFaultTreeIllustrationPoint);
-
- var nestedHydraRingSubMechanismIllustrationPointTreeNode = new HydraRingIllustrationPointTreeNode(new TestHydraRingSubMechanismIllustrationPoint());
- hydraRingIllustrationPointTreeNode.Children.Add(nestedHydraRingSubMechanismIllustrationPointTreeNode);
-
- // Call
- TestDelegate test = () => IllustrationPointNodeConverter.Create(hydraRingIllustrationPointTreeNode);
-
- // Assert
- const string expectedMessage = "Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben.";
- var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
- Assert.AreEqual("children", exception.ParamName);
- }
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Output/IllustrationPoints/IllustrationPointTreeNode.cs
===================================================================
diff -u -r0fd23ff8e68b5f0d18d344d104bc68216cb49b51 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Output/IllustrationPoints/IllustrationPointTreeNode.cs (.../IllustrationPointTreeNode.cs) (revision 0fd23ff8e68b5f0d18d344d104bc68216cb49b51)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Data/Output/IllustrationPoints/IllustrationPointTreeNode.cs (.../IllustrationPointTreeNode.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -21,6 +21,8 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+using Ringtoets.HydraRing.Calculation.Properties;
namespace Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints
{
@@ -44,7 +46,7 @@
throw new ArgumentNullException(nameof(data));
}
Data = data;
- Children = new List(2);
+ Children = Enumerable.Empty();
}
///
@@ -55,6 +57,31 @@
///
/// Gets the child nodes of this node.
///
- public IList Children { get; }
+ public IEnumerable Children { get; private set; }
+
+ ///
+ /// Sets the children to this node.
+ ///
+ /// The children that are attached to this node.
+ /// Thrown when
+ /// does not contain 0 or 2 elements.
+ public void SetChildren(IllustrationPointTreeNode[] children)
+ {
+ if (children == null)
+ {
+ throw new ArgumentNullException(nameof(children));
+ }
+
+ int nrOfChildren = children.Length;
+ if (nrOfChildren == 0 || nrOfChildren == 2)
+ {
+ Children = children;
+ }
+ else
+ {
+ throw new ArgumentException(Resources.IllustrationPointTreeNode_SetChildren_Node_must_have_zero_or_two_child_nodes,
+ nameof(children));
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs
===================================================================
diff -u -r2c00fea093af45947307620c4203188ceb872951 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs (.../IllustrationPointsParser.cs) (revision 2c00fea093af45947307620c4203188ceb872951)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Parsers/IllustrationPoints/IllustrationPointsParser.cs (.../IllustrationPointsParser.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -363,7 +363,7 @@
Tuple windDirectionClosingSituation,
int faultTreeId,
CombinationType combinationType,
- ICollection> results)
+ IEnumerable> results)
{
var dataKey = new ThreeKeyIndex(windDirectionClosingSituation.Item1, windDirectionClosingSituation.Item3, faultTreeId);
var faultTreeIllustrationPointStochasts = new List();
@@ -383,12 +383,10 @@
combinationType);
var node = new IllustrationPointTreeNode(illustrationPoint);
- foreach (Tuple child in results.Where(r => r.Item1 == faultTreeId))
- {
- node.Children.Add(child.Item3 == typeof(FaultTreeIllustrationPoint)
- ? BuildFaultTree(windDirectionClosingSituation, child.Item2, child.Item4, results)
- : BuildSubMechanism(windDirectionClosingSituation, child.Item2));
- }
+ node.SetChildren(results.Where(r => r.Item1 == faultTreeId)
+ .Select(child => child.Item3 == typeof(FaultTreeIllustrationPoint)
+ ? BuildFaultTree(windDirectionClosingSituation, child.Item2, child.Item4, results)
+ : BuildSubMechanism(windDirectionClosingSituation, child.Item2)).ToArray());
return node;
}
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.Designer.cs
===================================================================
diff -u -r2494425b0c9355fa337d49efcc0267f958ebe154 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2494425b0c9355fa337d49efcc0267f958ebe154)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -176,6 +176,15 @@
}
///
+ /// Looks up a localized string similar to Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben..
+ ///
+ internal static string IllustrationPointTreeNode_SetChildren_Node_must_have_zero_or_two_child_nodes {
+ get {
+ return ResourceManager.GetString("IllustrationPointTreeNode_SetChildren_Node_must_have_zero_or_two_child_nodes", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Er is geen resultaat voor overslag en overloop gevonden in de Hydra-Ring uitvoerdatabase..
///
internal static string OvertoppingCalculationWaveHeightParser_No_overtopping_found_in_output_file {
Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.resx
===================================================================
diff -u -r2494425b0c9355fa337d49efcc0267f958ebe154 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.resx (.../Resources.resx) (revision 2494425b0c9355fa337d49efcc0267f958ebe154)
+++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Properties/Resources.resx (.../Resources.resx) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -163,4 +163,7 @@
Er is geen maatgevende windrichting gevonden in de uitvoer database.
+
+ Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben.
+
\ No newline at end of file
Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Data/Output/IllustrationPoints/IllustrationPointTreeNodeTest.cs
===================================================================
diff -u -r0fd23ff8e68b5f0d18d344d104bc68216cb49b51 -rd71b7ff94e33c33d3d8a7b38eee416c9df03f06a
--- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Data/Output/IllustrationPoints/IllustrationPointTreeNodeTest.cs (.../IllustrationPointTreeNodeTest.cs) (revision 0fd23ff8e68b5f0d18d344d104bc68216cb49b51)
+++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/Data/Output/IllustrationPoints/IllustrationPointTreeNodeTest.cs (.../IllustrationPointTreeNodeTest.cs) (revision d71b7ff94e33c33d3d8a7b38eee416c9df03f06a)
@@ -20,6 +20,8 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.HydraRing.Calculation.Data.Output.IllustrationPoints;
@@ -56,5 +58,90 @@
Assert.IsEmpty(node.Children);
mocks.VerifyAll();
}
+
+ [Test]
+ public void SetChildren_ChildrenNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var data = mocks.Stub();
+ mocks.ReplayAll();
+
+ var treeNode = new IllustrationPointTreeNode(data);
+
+ // Call
+ TestDelegate call = () => treeNode.SetChildren(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("children", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(1)]
+ [TestCase(3)]
+ public void SetChildren_InvalidNrOfChildren_ThrowsInvalidArgumentException(int nrOfChildren)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var data = mocks.Stub();
+ mocks.ReplayAll();
+
+ var treeNode = new IllustrationPointTreeNode(data);
+
+ var childrenToBeAttached = new List();
+ for (var i = 0; i < nrOfChildren; i++)
+ {
+ childrenToBeAttached.Add(new IllustrationPointTreeNode(data));
+ }
+
+ // Call
+ TestDelegate call = () => treeNode.SetChildren(childrenToBeAttached.ToArray());
+
+ // Assert
+ const string expectedMessage = "Een illustratiepunt node in de foutenboom moet 0 of 2 kind nodes hebben.";
+ var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ Assert.AreEqual("children", exception.ParamName);
+ }
+
+ [Test]
+ public void SetChildren_NoChildren_ReturnsExpectedProperties()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var data = mocks.Stub();
+ mocks.ReplayAll();
+
+ var treeNode = new IllustrationPointTreeNode(data);
+
+ // Call
+ treeNode.SetChildren(new IllustrationPointTreeNode[0]);
+
+ // Assert
+ CollectionAssert.IsEmpty(treeNode.Children);
+ }
+
+ [Test]
+ public void SetChildren_TwoChildren_ReturnsExpectedProperties()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var data = mocks.Stub();
+ mocks.ReplayAll();
+
+ var treeNode = new IllustrationPointTreeNode(data);
+
+ var childrenToBeAttached = new[]
+ {
+ new IllustrationPointTreeNode(data),
+ new IllustrationPointTreeNode(data)
+ };
+
+ // Call
+ treeNode.SetChildren(childrenToBeAttached);
+
+ // Assert
+ CollectionAssert.AreEqual(childrenToBeAttached, treeNode.Children);
+ }
}
}
\ No newline at end of file