Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismAssemblyKernelStubTest.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismAssemblyKernelStubTest.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismAssemblyKernelStubTest.cs (revision d89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d)
@@ -0,0 +1,209 @@
+// 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 Assembly.Kernel.Interfaces;
+using Assembly.Kernel.Model;
+using Assembly.Kernel.Model.FmSectionTypes;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly;
+
+namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.Kernels.Assembly
+{
+ [TestFixture]
+ public class FailureMechanismAssemblyKernelStubTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var kernel = new FailureMechanismAssemblyKernelStub();
+
+ // Assert
+ Assert.IsInstanceOf(kernel);
+ Assert.IsFalse(kernel.Calculated);
+ Assert.IsNull(kernel.AssessmentSectionInput);
+ Assert.IsNull(kernel.FailureMechanismInput);
+ Assert.IsNull(kernel.FailureMechanismAssemblyResult);
+ Assert.AreEqual(EFailureMechanismCategory.It, kernel.FailureMechanismCategoryResult);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1A1_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue()
+ {
+ // Setup
+ var random = new Random(39);
+ bool partialAssembly = random.NextBoolean();
+ var sectionAssemblyResults = new List();
+ var kernel = new FailureMechanismAssemblyKernelStub();
+
+ // Precondition
+ Assert.IsFalse(kernel.Calculated);
+
+ // Call
+ kernel.AssembleFailureMechanismWbi1A1(sectionAssemblyResults, partialAssembly);
+
+ // Assert
+ Assert.AreEqual(sectionAssemblyResults, kernel.FmSectionAssemblyResultsInput);
+ Assert.AreEqual(partialAssembly, kernel.PartialAssembly);
+ Assert.IsTrue(kernel.Calculated);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1A1_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyResult()
+ {
+ // Setup
+ var random = new Random(39);
+ var kernel = new FailureMechanismAssemblyKernelStub
+ {
+ FailureMechanismCategoryResult = random.NextEnumValue()
+ };
+
+ // Call
+ EFailureMechanismCategory result = kernel.AssembleFailureMechanismWbi1A1(new List(), random.NextBoolean());
+
+ // Assert
+ Assert.AreEqual(kernel.FailureMechanismCategoryResult, result);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1A1_ThrowExceptionOnCalculateTrue_ThrowsException()
+ {
+ // Setup
+ var kernel = new FailureMechanismAssemblyKernelStub
+ {
+ ThrowExceptionOnCalculate = true
+ };
+
+ // Call
+ TestDelegate test = () => kernel.AssembleFailureMechanismWbi1A1(new List(), true);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("Message", exception.Message);
+ Assert.IsNotNull(exception.InnerException);
+ Assert.IsNull(kernel.FmSectionAssemblyResultsInput);
+ Assert.IsFalse(kernel.PartialAssembly);
+ Assert.IsFalse(kernel.Calculated);
+ Assert.AreEqual(EFailureMechanismCategory.It, kernel.FailureMechanismCategoryResult);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1A2_Always_ThrowNotImplementedException()
+ {
+ // Setup
+ var kernel = new FailureMechanismAssemblyKernelStub();
+
+ // Call
+ TestDelegate test = () => kernel.AssembleFailureMechanismWbi1A2(null, false);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1B1_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue()
+ {
+ // Setup
+ var random = new Random(39);
+ AssessmentSection assessmentSection = CreateRandomAssessmentSection(random);
+ FailureMechanism failureMechanism = CreateRandomFailureMechanism(random);
+ var sectionAssemblyResults = new List();
+ bool partialAssembly = random.NextBoolean();
+ var kernel = new FailureMechanismAssemblyKernelStub();
+
+ // Precondition
+ Assert.IsFalse(kernel.Calculated);
+
+ // Call
+ kernel.AssembleFailureMechanismWbi1B1(assessmentSection, failureMechanism, sectionAssemblyResults, partialAssembly);
+
+ // Assert
+ Assert.AreEqual(assessmentSection, kernel.AssessmentSectionInput);
+ Assert.AreEqual(failureMechanism, kernel.FailureMechanismInput);
+ Assert.AreEqual(sectionAssemblyResults, kernel.FmSectionAssemblyResultsInput);
+ Assert.AreEqual(partialAssembly, kernel.PartialAssembly);
+ Assert.IsTrue(kernel.Calculated);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1B1_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyResult()
+ {
+ // Setup
+ var random = new Random(39);
+ var kernel = new FailureMechanismAssemblyKernelStub
+ {
+ FailureMechanismCategoryResult = random.NextEnumValue()
+ };
+
+ // Call
+ FailureMechanismAssemblyResult result = kernel.AssembleFailureMechanismWbi1B1(CreateRandomAssessmentSection(random),
+ CreateRandomFailureMechanism(random),
+ new List(),
+ random.NextBoolean());
+
+ // Assert
+ Assert.AreEqual(kernel.FailureMechanismCategoryResult, result);
+ }
+
+ [Test]
+ public void AssembleFailureMechanismWbi1B1_ThrowExceptionOnCalculateTrue_ThrowsException()
+ {
+ // Setup
+ var random = new Random(39);
+ var kernel = new FailureMechanismAssemblyKernelStub
+ {
+ ThrowExceptionOnCalculate = true
+ };
+
+ // Call
+ TestDelegate test = () => kernel.AssembleFailureMechanismWbi1B1(CreateRandomAssessmentSection(random),
+ CreateRandomFailureMechanism(random),
+ new List(),
+ true);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("Message", exception.Message);
+ Assert.IsNotNull(exception.InnerException);
+ Assert.IsNull(kernel.AssessmentSectionInput);
+ Assert.IsNull(kernel.FailureMechanismInput);
+ Assert.IsNull(kernel.FmSectionAssemblyResultsInput);
+ Assert.IsFalse(kernel.PartialAssembly);
+ Assert.IsFalse(kernel.Calculated);
+ Assert.AreEqual(EFailureMechanismCategory.It, kernel.FailureMechanismCategoryResult);
+ }
+
+ private static FailureMechanism CreateRandomFailureMechanism(Random random)
+ {
+ var failureMechanism = new FailureMechanism(random.NextDouble(1, 5), random.NextDouble());
+ return failureMechanism;
+ }
+
+ private static AssessmentSection CreateRandomAssessmentSection(Random random)
+ {
+ var assessmentSection = new AssessmentSection(random.NextDouble(), random.NextDouble(0.0, 0.5), random.NextDouble(0.5, 1.0));
+ return assessmentSection;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj
===================================================================
diff -u -r2bb11b820074a046d6a009974cc62d80923b67cb -rd89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 2bb11b820074a046d6a009974cc62d80923b67cb)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision d89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d)
@@ -21,6 +21,7 @@
+
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismAssemblyKernelStub.cs
===================================================================
diff -u
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismAssemblyKernelStub.cs (revision 0)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismAssemblyKernelStub.cs (revision d89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d)
@@ -0,0 +1,115 @@
+// 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 Assembly.Kernel.Interfaces;
+using Assembly.Kernel.Model;
+using Assembly.Kernel.Model.FmSectionTypes;
+
+namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly
+{
+ ///
+ /// Failure mechanism assembly kernel stub for testing purposes.
+ ///
+ public class FailureMechanismAssemblyKernelStub : IFailureMechanismResultAssembler
+ {
+ ///
+ /// Gets the collection of used as input parameter for assembly methods.
+ ///
+ public IEnumerable FmSectionAssemblyResultsInput { get; private set; }
+
+ ///
+ /// Gets a value indicating whether an assembly is partial.
+ ///
+ public bool PartialAssembly { get; private set; }
+
+ ///
+ /// Gets the used as input parameter for assembly methods.
+ ///
+ public AssessmentSection AssessmentSectionInput { get; private set; }
+
+ ///
+ /// Gets the used as input parameter for assembly methods.
+ ///
+ public FailureMechanism FailureMechanismInput { get; private set; }
+
+ ///
+ /// Gets or sets the failure mechanism category result.
+ ///
+ public EFailureMechanismCategory FailureMechanismCategoryResult { get; set; }
+
+ ///
+ /// Gets or sets the failure mechanism assembly result.
+ ///
+ public FailureMechanismAssemblyResult FailureMechanismAssemblyResult { get; set; }
+
+ ///
+ /// Gets a value indicating whether a calculation was called or not.
+ ///
+ public bool Calculated { get; private set; }
+
+ ///
+ /// Indicator whether an exception must be thrown when performing a calculation.
+ ///
+ public bool ThrowExceptionOnCalculate { private get; set; }
+
+ public EFailureMechanismCategory AssembleFailureMechanismWbi1A1(IEnumerable fmSectionAssemblyResults,
+ bool partialAssembly)
+ {
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new Exception("Message", new Exception());
+ }
+
+ FmSectionAssemblyResultsInput = fmSectionAssemblyResults;
+ PartialAssembly = partialAssembly;
+
+ Calculated = true;
+ return FailureMechanismCategoryResult;
+ }
+
+ public EIndirectAssessmentResult AssembleFailureMechanismWbi1A2(IEnumerable fmSectionAssemblyResults,
+ bool partialAssembly)
+ {
+ throw new NotImplementedException();
+ }
+
+ public FailureMechanismAssemblyResult AssembleFailureMechanismWbi1B1(AssessmentSection section,
+ FailureMechanism failureMechanism,
+ IEnumerable fmSectionAssemblyResults,
+ bool partialAssembly)
+ {
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new Exception("Message", new Exception());
+ }
+
+ AssessmentSectionInput = section;
+ FailureMechanismInput = failureMechanism;
+ FmSectionAssemblyResultsInput = fmSectionAssemblyResults;
+ PartialAssembly = partialAssembly;
+
+ Calculated = true;
+ return FailureMechanismAssemblyResult;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj
===================================================================
diff -u -rc0296592b24df3847fbdfc1e267dfe8662ccdb84 -rd89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d
--- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision c0296592b24df3847fbdfc1e267dfe8662ccdb84)
+++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision d89cc4a956ba2c77c8b54c58da0b4e58a90c8d5d)
@@ -23,6 +23,7 @@
+