Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStubTest.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStubTest.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStubTest.cs (revision 8ffedce6423c90651a76ae74c34c75a298c10194)
@@ -0,0 +1,191 @@
+// 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 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 AssessmentSectionAssemblyCalculatorStubTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var calculator = new AssessmentSectionAssemblyCalculatorStub();
+
+ // Assert
+ Assert.IsInstanceOf(calculator);
+ Assert.IsNull(calculator.FailureMechanismAssemblyInput);
+ Assert.IsNull(calculator.FailureMechanismAssemblyCategoryGroupInput);
+ Assert.IsNull(calculator.AssemblyCategoriesInput);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput()
+ {
+ // Setup
+ var calculator = new AssessmentSectionAssemblyCalculatorStub();
+
+ // Call
+ AssessmentSectionAssembly output = calculator.AssembleFailureMechanisms(Enumerable.Empty(),
+ CreateAssemblyCategoriesInput());
+
+ // Assert
+ Assert.AreEqual(0.75, output.Probability);
+ Assert.AreEqual(AssessmentSectionAssemblyCategoryGroup.D, output.Group);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput()
+ {
+ // Setup
+ var random = new Random(21);
+ var calculator = new AssessmentSectionAssemblyCalculatorStub
+ {
+ AssessmentSectionAssemblyOutput = new AssessmentSectionAssembly(random.NextDouble(),
+ random.NextEnumValue())
+ };
+
+ // Call
+ AssessmentSectionAssembly output = calculator.AssembleFailureMechanisms(Enumerable.Empty(),
+ CreateAssemblyCategoriesInput());
+
+ // Assert
+ Assert.AreSame(calculator.AssessmentSectionAssemblyOutput, output);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalse_SetsInput()
+ {
+ // Setup
+ IEnumerable failureMechanisms = Enumerable.Empty();
+ AssemblyCategoriesInput assemblyCategoriesInput = CreateAssemblyCategoriesInput();
+
+ var calculator = new AssessmentSectionAssemblyCalculatorStub();
+
+ // Call
+ calculator.AssembleFailureMechanisms(failureMechanisms, assemblyCategoriesInput);
+
+ // Assert
+ Assert.AreSame(failureMechanisms, calculator.FailureMechanismAssemblyInput);
+ Assert.AreSame(assemblyCategoriesInput, calculator.AssemblyCategoriesInput);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithProbability_ThrowExceptionOnCalculateTrue_ThrowsAssessmentSectionAssemblyException()
+ {
+ // Setup
+ var calculator = new AssessmentSectionAssemblyCalculatorStub
+ {
+ ThrowExceptionOnCalculate = true
+ };
+
+ // Call
+ TestDelegate call = () => calculator.AssembleFailureMechanisms(Enumerable.Empty(),
+ CreateAssemblyCategoriesInput());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("Message", exception.Message);
+ Assert.IsNotNull(exception.InnerException);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithoutProbability_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput()
+ {
+ // Setup
+ var calculator = new AssessmentSectionAssemblyCalculatorStub();
+
+ // Call
+ AssessmentSectionAssemblyCategoryGroup output = calculator.AssembleFailureMechanisms(Enumerable.Empty());
+
+ // Assert
+ Assert.AreEqual(AssessmentSectionAssemblyCategoryGroup.D, output);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithoutProbability_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput()
+ {
+ // Setup
+ var random = new Random(21);
+ var calculator = new AssessmentSectionAssemblyCalculatorStub
+ {
+ AssessmentSectionAssemblyCategoryGroupOutput = random.NextEnumValue()
+ };
+
+ // Call
+ AssessmentSectionAssemblyCategoryGroup output = calculator.AssembleFailureMechanisms(Enumerable.Empty());
+
+ // Assert
+ Assert.AreEqual(calculator.AssessmentSectionAssemblyCategoryGroupOutput, output);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithoutProbability_ThrowExceptionOnCalculateFalse_SetsInput()
+ {
+ // Setup
+ IEnumerable failureMechanisms = Enumerable.Empty();
+
+ var calculator = new AssessmentSectionAssemblyCalculatorStub();
+
+ // Call
+ calculator.AssembleFailureMechanisms(failureMechanisms);
+
+ // Assert
+ Assert.AreSame(failureMechanisms, calculator.FailureMechanismAssemblyCategoryGroupInput);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismsWithoutProbability_ThrowExceptionOnCalculateTrue_ThrowsAssessmentSectionAssemblyException()
+ {
+ // Setup
+ var calculator = new AssessmentSectionAssemblyCalculatorStub
+ {
+ ThrowExceptionOnCalculate = true
+ };
+
+ // Call
+ TestDelegate call = () => calculator.AssembleFailureMechanisms(Enumerable.Empty());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("Message", exception.Message);
+ Assert.IsNotNull(exception.InnerException);
+ }
+
+ private static AssemblyCategoriesInput CreateAssemblyCategoriesInput()
+ {
+ var random = new Random(21);
+ 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 -r51dba74a6fb3ec349596c01f64d767074aef0bc1 -r8ffedce6423c90651a76ae74c34c75a298c10194
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 51dba74a6fb3ec349596c01f64d767074aef0bc1)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 8ffedce6423c90651a76ae74c34c75a298c10194)
@@ -18,6 +18,7 @@
+
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStub.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStub.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStub.cs (revision 8ffedce6423c90651a76ae74c34c75a298c10194)
@@ -0,0 +1,102 @@
+// 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
+{
+ ///
+ /// Assessment section assembly calculator stub for testing purposes.
+ ///
+ public class AssessmentSectionAssemblyCalculatorStub : IAssessmentSectionAssemblyCalculator
+ {
+ ///
+ /// Gets the assembly categories input when assembling the assessment section with
+ /// failure mechanisms with probability.
+ ///
+ public AssemblyCategoriesInput AssemblyCategoriesInput { get; private set; }
+
+ ///
+ /// Gets the collection of failure mechanism assembly input when assembling the
+ /// assessment section with failure mechanisms with probability.
+ ///
+ public IEnumerable FailureMechanismAssemblyInput { get; private set; }
+
+ ///
+ /// Gets the collection of failure mechanism assembly input when assembling the
+ /// assessment section with failure mechanisms without probability
+ ///
+ public IEnumerable FailureMechanismAssemblyCategoryGroupInput { get; private set; }
+
+ ///
+ /// Gets or sets the output of the assessment section assembly for failure
+ /// mechanisms with probability.
+ ///
+ public AssessmentSectionAssembly AssessmentSectionAssemblyOutput { get; set; }
+
+ ///
+ /// Gets or sets the output of the assessment section assembly for failure
+ /// mechanisms without probability.
+ ///
+ public AssessmentSectionAssemblyCategoryGroup? AssessmentSectionAssemblyCategoryGroupOutput { get; set; }
+
+ ///
+ /// Sets an indicator whether an exception must be thrown when performing a calculation.
+ ///
+ public bool ThrowExceptionOnCalculate { private get; set; }
+
+ public AssessmentSectionAssembly AssembleFailureMechanisms(IEnumerable input,
+ AssemblyCategoriesInput assemblyCategoriesInput)
+ {
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception());
+ }
+
+ FailureMechanismAssemblyInput = input;
+ AssemblyCategoriesInput = assemblyCategoriesInput;
+
+ return AssessmentSectionAssemblyOutput ??
+ new AssessmentSectionAssembly(0.75, AssessmentSectionAssemblyCategoryGroup.D);
+ }
+
+ public AssessmentSectionAssemblyCategoryGroup AssembleFailureMechanisms(IEnumerable input)
+ {
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception());
+ }
+
+ FailureMechanismAssemblyCategoryGroupInput = input;
+
+ return AssessmentSectionAssemblyCategoryGroupOutput ?? AssessmentSectionAssemblyCategoryGroup.D;
+ }
+
+ public AssessmentSectionAssemblyCategoryGroup AssembleAssessmentSection(AssessmentSectionAssemblyCategoryGroup failureMechanismsWithoutProbability,
+ AssessmentSectionAssembly failureMechanismsWithProbability)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj
===================================================================
diff -u -r51dba74a6fb3ec349596c01f64d767074aef0bc1 -r8ffedce6423c90651a76ae74c34c75a298c10194
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 51dba74a6fb3ec349596c01f64d767074aef0bc1)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 8ffedce6423c90651a76ae74c34c75a298c10194)
@@ -19,6 +19,7 @@
+