Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismAssemblyCalculatorStubTest.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismAssemblyCalculatorStubTest.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismAssemblyCalculatorStubTest.cs (revision e61166fd0f1b281e21acb457c7ec3b59904c219a)
@@ -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.Collections.Generic;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+
+namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.Calculators.Assembly
+{
+ [TestFixture]
+ public class FailureMechanismAssemblyCalculatorStubTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var calculator = new FailureMechanismAssemblyCalculatorStub();
+
+ // Assert
+ Assert.IsInstanceOf(calculator);
+ Assert.AreEqual(null, calculator.FailureMechanismAssemblyCategoryGroupOutput);
+
+ Assert.IsNull(calculator.AssemblyCategoriesInput);
+ Assert.IsNull(calculator.FailureMechanismSectionAssemblies);
+ Assert.IsNull(calculator.FailureMechanismAssemblyOutput);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput()
+ {
+ // Setup
+ var calculator = new FailureMechanismAssemblyCalculatorStub();
+
+ // Call
+ FailureMechanismAssemblyCategoryGroup category = calculator.AssembleFailureMechanism(new List());
+
+ // Assert
+ Assert.AreEqual(FailureMechanismAssemblyCategoryGroup.IIt, category);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput()
+ {
+ // Setup
+ var random = new Random(39);
+ var calculator = new FailureMechanismAssemblyCalculatorStub
+ {
+ FailureMechanismAssemblyCategoryGroupOutput = random.NextEnumValue()
+ };
+
+ // Call
+ FailureMechanismAssemblyCategoryGroup category = calculator.AssembleFailureMechanism(new List());
+
+ // Assert
+ Assert.AreEqual(calculator.FailureMechanismAssemblyCategoryGroupOutput, category);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_ThrowExceptionOnCalculateFalse_SetsInput()
+ {
+ // Setup
+ var calculator = new FailureMechanismAssemblyCalculatorStub();
+ var sectionResults = new List();
+
+ // Call
+ calculator.AssembleFailureMechanism(sectionResults);
+
+ // Assert
+ Assert.AreEqual(sectionResults, calculator.FailureMechanismSectionAssemblies);
+ }
+
+ [Test]
+ public void AssembleFailureMechanism_ThrowExceptionOnCalculateTrue_ThrowsFailureMechanismSectionAssemblyCalculatorException()
+ {
+ // Setup
+ var calculator = new FailureMechanismAssemblyCalculatorStub
+ {
+ ThrowExceptionOnCalculate = true
+ };
+
+ // Call
+ TestDelegate test = () => calculator.AssembleFailureMechanism(new List());
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("Message", exception.Message);
+ Assert.IsNotNull(exception.InnerException);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWithProbabilities_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput()
+ {
+ // Setup
+ var calculator = new FailureMechanismAssemblyCalculatorStub();
+
+ // Call
+ FailureMechanismAssembly assembly = calculator.AssembleFailureMechanism(new List(),
+ CreateAssemblyCategoriesInput());
+
+ // Assert
+ Assert.AreEqual(FailureMechanismAssemblyCategoryGroup.IIIt, assembly.Group);
+ Assert.AreEqual(1.0, assembly.Probability);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWithProbabilities_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput()
+ {
+ // Setup
+ var random = new Random(39);
+ var calculator = new FailureMechanismAssemblyCalculatorStub
+ {
+ FailureMechanismAssemblyOutput = new FailureMechanismAssembly(random.NextDouble(),
+ random.NextEnumValue())
+ };
+
+ // Call
+ FailureMechanismAssembly assembly = calculator.AssembleFailureMechanism(new List(),
+ CreateAssemblyCategoriesInput());
+
+ // Assert
+ Assert.AreSame(calculator.FailureMechanismAssemblyOutput, assembly);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWithProbabilities_ThrowExceptionOnCalculateFalse_SetsInput()
+ {
+ // Setup
+ var calculator = new FailureMechanismAssemblyCalculatorStub();
+ var sectionResults = new List();
+ AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput();
+
+ // Call
+ calculator.AssembleFailureMechanism(sectionResults, assemblyCategoriesInput);
+
+ // Assert
+ Assert.AreEqual(sectionResults, calculator.FailureMechanismSectionAssemblies);
+ Assert.AreEqual(assemblyCategoriesInput, calculator.AssemblyCategoriesInput);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWithProbabilities_ThrowExceptionOnCalculateTrue_ThrowsFailureMechanismSectionAssemblyCalculatorException()
+ {
+ // Setup
+ var calculator = new FailureMechanismAssemblyCalculatorStub
+ {
+ ThrowExceptionOnCalculate = true
+ };
+
+ // Call
+ TestDelegate test = () => calculator.AssembleFailureMechanism(new List(),
+ CreateAssemblyCategoriesInput());
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("Message", exception.Message);
+ Assert.IsNotNull(exception.InnerException);
+ }
+
+ private AssemblyCategoriesInput CreateAssemblyCategoriesInput()
+ {
+ var random = new Random(39);
+ return new AssemblyCategoriesInput(random.NextDouble(),
+ random.NextDouble(),
+ random.NextDouble(),
+ random.NextDouble());
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj
===================================================================
diff -u -rd89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d -re61166fd0f1b281e21acb457c7ec3b59904c219a
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision d89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision e61166fd0f1b281e21acb457c7ec3b59904c219a)
@@ -18,6 +18,7 @@
+
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismAssemblyCalculatorStub.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismAssemblyCalculatorStub.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismAssemblyCalculatorStub.cs (revision e61166fd0f1b281e21acb457c7ec3b59904c219a)
@@ -0,0 +1,91 @@
+// 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 Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly;
+
+namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly
+{
+ ///
+ /// Failure mechanism assembly calculator stub for testing purposes.
+ ///
+ public class FailureMechanismAssemblyCalculatorStub : IFailureMechanismAssemblyCalculator
+ {
+ ///
+ /// Gets the collection of .
+ ///
+ public IEnumerable FailureMechanismSectionAssemblies { get; private set; }
+
+ ///
+ /// Gets or sets the output of the failure mechanism assembly without probabilities.
+ ///
+ public FailureMechanismAssemblyCategoryGroup? FailureMechanismAssemblyCategoryGroupOutput { get; set; }
+
+ ///
+ /// Gets or sets the output of the failure mechanism assembly with probabilities.
+ ///
+ public FailureMechanismAssembly FailureMechanismAssemblyOutput { get; set; }
+
+ ///
+ /// Gets the assembly categories input used in the assembly calculation methods.
+ ///
+ public AssemblyCategoriesInput AssemblyCategoriesInput { get; private set; }
+
+ ///
+ /// Sets an indicator whether an exception must be thrown when performing a calculation.
+ ///
+ public bool ThrowExceptionOnCalculate { private get; set; }
+
+ public FailureMechanismAssemblyCategoryGroup AssembleFailureMechanism(IEnumerable sectionAssemblies)
+ {
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new FailureMechanismAssemblyCalculatorException("Message", new Exception());
+ }
+
+ FailureMechanismSectionAssemblies = sectionAssemblies;
+
+ if (FailureMechanismAssemblyCategoryGroupOutput == null)
+ {
+ FailureMechanismAssemblyCategoryGroupOutput = FailureMechanismAssemblyCategoryGroup.IIt;
+ }
+
+ return FailureMechanismAssemblyCategoryGroupOutput.Value;
+ }
+
+ public FailureMechanismAssembly AssembleFailureMechanism(IEnumerable sectionAssemblies,
+ AssemblyCategoriesInput assemblyCategoriesInput)
+ {
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new FailureMechanismAssemblyCalculatorException("Message", new Exception());
+ }
+
+ FailureMechanismSectionAssemblies = sectionAssemblies;
+ AssemblyCategoriesInput = assemblyCategoriesInput;
+
+ return FailureMechanismAssemblyOutput ??
+ (FailureMechanismAssemblyOutput = new FailureMechanismAssembly(1.0, FailureMechanismAssemblyCategoryGroup.IIIt));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj
===================================================================
diff -u -rd89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d -re61166fd0f1b281e21acb457c7ec3b59904c219a
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision d89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision e61166fd0f1b281e21acb457c7ec3b59904c219a)
@@ -19,6 +19,7 @@
+