Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStubTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStubTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStubTest.cs (revision 70196989bbf45e88c19faa7300c59f0b43714beb) @@ -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 System.Linq; +using Assembly.Kernel.Interfaces; +using Assembly.Kernel.Model; +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 CombinedFailureMechanismSectionAssemblyKernelStubTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var kernel = new CombinedFailureMechanismSectionAssemblyKernelStub(); + + // Assert + Assert.IsInstanceOf(kernel); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.PartialAssembly); + Assert.IsNull(kernel.AssessmentSectionLengthInput); + Assert.IsNull(kernel.FailureMechanismSectionListsInput); + Assert.IsNull(kernel.AssemblyResult); + } + + [Test] + public void AssembleCommonFailureMechanismSections_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() + { + // Setup + var random = new Random(21); + bool partialAssembly = random.NextBoolean(); + double assessmentSectionLength = random.NextDouble(); + IEnumerable failureMechanismSectionLists = Enumerable.Empty(); + + var kernel = new CombinedFailureMechanismSectionAssemblyKernelStub(); + + // Call + kernel.AssembleCommonFailureMechanismSections(failureMechanismSectionLists, assessmentSectionLength, partialAssembly); + + // Assert + Assert.IsTrue(kernel.Calculated); + Assert.AreSame(failureMechanismSectionLists, kernel.FailureMechanismSectionListsInput); + Assert.AreEqual(assessmentSectionLength, kernel.AssessmentSectionLengthInput); + Assert.AreEqual(partialAssembly, kernel.PartialAssembly); + } + + [Test] + public void AssembleCommonFailureMechanismSections_ThrowExceptionOnCalculateFalse_ReturnAssessmentGrade() + { + // Setup + var random = new Random(21); + var kernel = new CombinedFailureMechanismSectionAssemblyKernelStub + { + AssemblyResult = new AssemblyResult(Enumerable.Empty(), Enumerable.Empty()) + }; + + // Call + AssemblyResult result = kernel.AssembleCommonFailureMechanismSections(Enumerable.Empty(), + random.NextDouble(), random.NextBoolean()); + + // Assert + Assert.AreEqual(kernel.AssemblyResult, result); + } + + [Test] + public void AssembleCommonFailureMechanismSections_ThrowExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var random = new Random(21); + var kernel = new CombinedFailureMechanismSectionAssemblyKernelStub + { + ThrowException = true + }; + + // Call + TestDelegate test = () => kernel.AssembleCommonFailureMechanismSections(Enumerable.Empty(), + random.NextDouble(), random.NextBoolean()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + Assert.IsNull(kernel.AssessmentSectionLengthInput); + Assert.IsNull(kernel.FailureMechanismSectionListsInput); + Assert.IsNull(kernel.PartialAssembly); + Assert.IsNull(kernel.AssemblyResult); + Assert.IsFalse(kernel.Calculated); + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj =================================================================== diff -u -r4b5d80639ec5b56ed227ef2b467e42edc191ca91 -r70196989bbf45e88c19faa7300c59f0b43714beb --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 4b5d80639ec5b56ed227ef2b467e42edc191ca91) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 70196989bbf45e88c19faa7300c59f0b43714beb) @@ -25,6 +25,7 @@ + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/AssessmentSectionAssemblyKernelStub.cs =================================================================== diff -u -raff42da8fcf168a408902881180d6ceedbc58b08 -r70196989bbf45e88c19faa7300c59f0b43714beb --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/AssessmentSectionAssemblyKernelStub.cs (.../AssessmentSectionAssemblyKernelStub.cs) (revision aff42da8fcf168a408902881180d6ceedbc58b08) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/AssessmentSectionAssemblyKernelStub.cs (.../AssessmentSectionAssemblyKernelStub.cs) (revision 70196989bbf45e88c19faa7300c59f0b43714beb) @@ -27,12 +27,12 @@ namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly { /// - /// Assessment section assembly kernel stub for testing purposes + /// Assessment section assembly kernel stub for testing purposes. /// public class AssessmentSectionAssemblyKernelStub : IAssessmentGradeAssembler { /// - /// Gets the used as an input parameter for assembly methods. + /// Gets the used as an input parameter for assembly methods. /// public AssessmentSection AssessmentSectionInput { get; private set; } Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStub.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStub.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStub.cs (revision 70196989bbf45e88c19faa7300c59f0b43714beb) @@ -0,0 +1,81 @@ +// 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; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly +{ + /// + /// Combined failure mechanism section assembly kernel stub for testing purposes. + /// + public class CombinedFailureMechanismSectionAssemblyKernelStub : ICommonFailureMechanismSectionAssembler + { + /// + /// Indicator whether an exception must be thrown when performing a calculation. + /// + public bool ThrowException { private get; set; } + + /// + /// Gets a value indicating whether a calculation was called or not. + /// + public bool Calculated { get; private set; } + + /// + /// Gets a value indicating whether an assembly is partial. + /// + public bool? PartialAssembly { get; private set; } + + /// + /// Gets the assessment section length used as an input parameter for assembly method. + /// + public double? AssessmentSectionLengthInput { get; private set; } + + /// + /// Gets the collection of used as an input parameter for assembly method. + /// + public IEnumerable FailureMechanismSectionListsInput { get; private set; } + + /// + /// Gets or sets the assembly result. + /// + public AssemblyResult AssemblyResult { get; set; } + + public AssemblyResult AssembleCommonFailureMechanismSections(IEnumerable failureMechanismSectionLists, + double assessmentSectionLength, bool partialAssembly) + { + if (ThrowException) + { + throw new Exception("Message", new Exception()); + } + + FailureMechanismSectionListsInput = failureMechanismSectionLists; + AssessmentSectionLengthInput = assessmentSectionLength; + PartialAssembly = partialAssembly; + + Calculated = true; + + return AssemblyResult; + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r4b5d80639ec5b56ed227ef2b467e42edc191ca91 -r70196989bbf45e88c19faa7300c59f0b43714beb --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 4b5d80639ec5b56ed227ef2b467e42edc191ca91) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 70196989bbf45e88c19faa7300c59f0b43714beb) @@ -27,6 +27,7 @@ +