Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPointNode.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPointNode.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPointNode.cs (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
@@ -0,0 +1,88 @@
+// 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 Ringtoets.Common.Data.Properties;
+
+namespace Ringtoets.Common.Data.IllustrationPoints
+{
+ ///
+ /// A node with attached illustration point data that is part of a tree. Multiple
+ /// nodes form the tree structure describing how the illustration points are related.
+ ///
+ public class FaultTreeIllustrationPointNode
+ {
+ ///
+ /// Creates a new node with associated data.
+ ///
+ /// The illustration point data that is attached
+ /// to this node.
+ /// Thrown when
+ /// is null.
+ public FaultTreeIllustrationPointNode(IllustrationPointBase data)
+ {
+ if (data == null)
+ {
+ throw new ArgumentNullException(nameof(data));
+ }
+
+ Data = data;
+ }
+
+ ///
+ /// Gets the attached illustration point data to this node.
+ ///
+ public IllustrationPointBase Data { get; }
+
+ ///
+ /// Gets the attached child nodes of this node.
+ ///
+ public IEnumerable Children { get; private set; }
+ = Enumerable.Empty();
+
+ ///
+ /// 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(FaultTreeIllustrationPointNode[] 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.FaultTreeIllustrationPointNode_SetChildren_Node_must_have_zero_or_two_child_nodes,
+ nameof(children));
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs
===================================================================
diff -u -r7f4eb38b0c9023e8a66cbce632cd10a16ef9e4bb -r6d60c1b06ad01314179bc7d953765e46a41b841c
--- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7f4eb38b0c9023e8a66cbce632cd10a16ef9e4bb)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
@@ -391,6 +391,16 @@
}
///
+ /// 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 {
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx
===================================================================
diff -u -r7f4eb38b0c9023e8a66cbce632cd10a16ef9e4bb -r6d60c1b06ad01314179bc7d953765e46a41b841c
--- Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 7f4eb38b0c9023e8a66cbce632cd10a16ef9e4bb)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Properties/Resources.resx (.../Resources.resx) (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
@@ -303,4 +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/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -ra82f053cd598d56bb1b7b8df663d104d7b9c1214 -r6d60c1b06ad01314179bc7d953765e46a41b841c
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision a82f053cd598d56bb1b7b8df663d104d7b9c1214)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
@@ -69,6 +69,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointNodeTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointNodeTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointNodeTest.cs (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
@@ -0,0 +1,132 @@
+// 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 Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.IllustrationPoints;
+
+namespace Ringtoets.Common.Data.Test.IllustrationPoints
+{
+ [TestFixture]
+ public class FaultTreeIllustrationPointNodeTest
+ {
+ [Test]
+ public void Constructor_DataNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new FaultTreeIllustrationPointNode(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("data", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ValidArguments_ReturnExpectedValues()
+ {
+ // Setup
+ var data = new TestIllustrationPoint();
+
+ // Call
+ var faultTreeNode = new FaultTreeIllustrationPointNode(data);
+
+ // Assert
+ Assert.AreSame(data, faultTreeNode.Data);
+ Assert.IsEmpty(faultTreeNode.Children);
+ }
+
+ [Test]
+ public void SetChildren_ChildrenNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var faultTreeNode = new FaultTreeIllustrationPointNode(new TestIllustrationPoint());
+
+ // Call
+ TestDelegate call = () => faultTreeNode.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 faultTreeNode = new FaultTreeIllustrationPointNode(new TestIllustrationPoint());
+
+ var childrenToBeAttached = new List();
+ for (var i = 0; i < nrOfChildren; i++)
+ {
+ childrenToBeAttached.Add(new FaultTreeIllustrationPointNode(new TestIllustrationPoint()));
+ }
+
+ // Call
+ TestDelegate call = () => faultTreeNode.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 faultTreeNode = new FaultTreeIllustrationPointNode(new TestIllustrationPoint());
+
+ // Call
+ faultTreeNode.SetChildren(new FaultTreeIllustrationPointNode[0]);
+
+ // Assert
+ CollectionAssert.IsEmpty(faultTreeNode.Children);
+ }
+
+ [Test]
+ public void SetChildren_TwoChildren_ReturnsExpectedProperties()
+ {
+ // Setup
+ var faultTreeNode = new FaultTreeIllustrationPointNode(new TestIllustrationPoint());
+
+ var childrenToBeAttached = new[]
+ {
+ new FaultTreeIllustrationPointNode(new TestIllustrationPoint()),
+ new FaultTreeIllustrationPointNode(new TestIllustrationPoint())
+ };
+
+ // Call
+ faultTreeNode.SetChildren(childrenToBeAttached);
+
+ // Assert
+ CollectionAssert.AreEqual(childrenToBeAttached, faultTreeNode.Children);
+ }
+
+ private class TestIllustrationPoint : IllustrationPointBase
+ {
+ public TestIllustrationPoint() : base("illustration point element", 3.14) {}
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj
===================================================================
diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -r6d60c1b06ad01314179bc7d953765e46a41b841c
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 6d60c1b06ad01314179bc7d953765e46a41b841c)
@@ -79,6 +79,7 @@
+