Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/CombinationType.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/CombinationType.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/CombinationType.cs (revision a82f053cd598d56bb1b7b8df663d104d7b9c1214)
@@ -0,0 +1,32 @@
+// 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.
+
+namespace Ringtoets.Common.Data.IllustrationPoints
+{
+ ///
+ /// The ways two illustration points can be combined in a single fault tree node.
+ ///
+ public enum CombinationType
+ {
+ Or,
+ And
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPoint.cs
===================================================================
diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -ra82f053cd598d56bb1b7b8df663d104d7b9c1214
--- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPoint.cs (.../FaultTreeIllustrationPoint.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/FaultTreeIllustrationPoint.cs (.../FaultTreeIllustrationPoint.cs) (revision a82f053cd598d56bb1b7b8df663d104d7b9c1214)
@@ -21,7 +21,7 @@
using System;
using System.Collections.Generic;
-using Core.Common.Base.Data;
+using System.ComponentModel;
namespace Ringtoets.Common.Data.IllustrationPoints
{
@@ -30,29 +30,66 @@
///
public class FaultTreeIllustrationPoint : IllustrationPointBase
{
+ private CombinationType combinationType;
+
///
/// Creates a new instance of .
///
/// The name of the illustration point node.
/// The beta value of this illustration point.
/// A collection of
/// that are associated with this illustration point node.
+ /// The way to combine two nodes into a single
+ /// tree node element in the fault tree.
/// Thrown when or
/// is null.
- public FaultTreeIllustrationPoint(string name, double beta, IEnumerable stochasts)
+ /// Thrown when attempting
+ /// to set invalid enum value of type .
+ public FaultTreeIllustrationPoint(string name,
+ double beta,
+ IEnumerable stochasts,
+ CombinationType combinationType)
: base(name, beta)
{
if (stochasts == null)
{
throw new ArgumentNullException(nameof(stochasts));
}
+ CombinationType = combinationType;
Stochasts = stochasts;
}
///
/// Gets the stochasts that belong to this illustration point.
///
public IEnumerable Stochasts { get; }
+
+ ///
+ /// Gets the combination type corresponding to this illustration point.
+ ///
+ /// Thrown when attempting
+ /// to set invalid enum value of type .
+ public CombinationType CombinationType
+ {
+ get
+ {
+ return combinationType;
+ }
+ private set
+ {
+ switch (value)
+ {
+ case CombinationType.And:
+ combinationType = value;
+ break;
+ case CombinationType.Or:
+ combinationType = value;
+ break;
+ default:
+ throw new InvalidEnumArgumentException("value", (int) value, typeof(CombinationType));
+ }
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -ra82f053cd598d56bb1b7b8df663d104d7b9c1214
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision a82f053cd598d56bb1b7b8df663d104d7b9c1214)
@@ -67,6 +67,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointTest.cs
===================================================================
diff -u -r1f8455066f5be4241f587c34283f1d7f8a85f78e -ra82f053cd598d56bb1b7b8df663d104d7b9c1214
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointTest.cs (.../FaultTreeIllustrationPointTest.cs) (revision 1f8455066f5be4241f587c34283f1d7f8a85f78e)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/FaultTreeIllustrationPointTest.cs (.../FaultTreeIllustrationPointTest.cs) (revision a82f053cd598d56bb1b7b8df663d104d7b9c1214)
@@ -21,7 +21,9 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.Common.Data.IllustrationPoints;
using Ringtoets.Common.Data.TestUtil;
@@ -36,8 +38,10 @@
{
// Call
TestDelegate call = () => new FaultTreeIllustrationPoint(null,
- 12.3,
- Enumerable.Empty());
+ 12.3,
+ Enumerable.Empty(),
+ CombinationType.And);
+ ;
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("name", exception.ParamName);
@@ -48,18 +52,39 @@
{
// Call
TestDelegate call = () => new FaultTreeIllustrationPoint("Test",
- 12.3,
- null);
+ 12.3,
+ null,
+ CombinationType.And);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("stochasts", exception.ParamName);
}
[Test]
- public void Constructor_ValidArguments_ReturnsExpectedValues()
+ public void Constructor_InvalidCombinationType_ThrowsInvalidEnumArgumentException()
{
// Setup
+ var invalidEnum = (CombinationType) 9001;
+
+ // Call
+ TestDelegate call = () => new FaultTreeIllustrationPoint("Test", 12.3,
+ Enumerable.Empty(),
+ invalidEnum);
+
+ // Assert
+ const string expectedMessage = "The value of argument 'value' (9001) is invalid for Enum type 'CombinationType'.";
+ var exception =
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ Assert.AreEqual("value", exception.ParamName);
+ }
+
+ [Test]
+ [TestCase(CombinationType.And)]
+ [TestCase(CombinationType.Or)]
+ public void Constructor_ValidArguments_ReturnsExpectedValues(CombinationType combinationType)
+ {
+ // Setup
const string name = "Fault tree illustration point name";
var random = new Random(21);
@@ -68,14 +93,15 @@
IEnumerable stochasts = Enumerable.Empty();
// Call
- var illustrationPoint = new FaultTreeIllustrationPoint(name, beta, stochasts);
+ var illustrationPoint = new FaultTreeIllustrationPoint(name, beta, stochasts, combinationType);
// Assert
Assert.IsInstanceOf(illustrationPoint);
Assert.AreEqual(name, illustrationPoint.Name);
Assert.AreSame(stochasts, illustrationPoint.Stochasts);
Assert.AreEqual(beta, illustrationPoint.Beta, illustrationPoint.Beta.GetAccuracy());
+ Assert.AreEqual(combinationType, illustrationPoint.CombinationType);
}
}
}
\ No newline at end of file