Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/FailureMechanismSectionAssemblyCalculator.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/FailureMechanismSectionAssemblyCalculator.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/FailureMechanismSectionAssemblyCalculator.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,87 @@ +// 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 AssemblyTool.Kernel; +using AssemblyTool.Kernel.Data.AssemblyCategories; +using Ringtoets.AssemblyTool.KernelWrapper.Creators; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; +using IFailureMechanismSectionAssemblyCalculatorKernel = AssemblyTool.Kernel.Assembly.IFailureMechanismSectionAssemblyCalculator; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly +{ + /// + /// Class representing a failure mechanism section assembly calculator. + /// + public class FailureMechanismSectionAssemblyCalculator : IFailureMechanismSectionAssemblyCalculator + { + private readonly IAssemblyToolKernelFactory factory; + + /// + /// Creates a new instance of . + /// + /// The factory responsible for creating the assembly kernel. + /// Thrown when any parameter is null. + public FailureMechanismSectionAssemblyCalculator(IAssemblyToolKernelFactory factory) + { + if (factory == null) + { + throw new ArgumentNullException(nameof(factory)); + } + + this.factory = factory; + } + + public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultType input) + { + try + { + IFailureMechanismSectionAssemblyCalculatorKernel kernel = factory.CreateFailureMechanismSectionAssemblyKernel(); + CalculationOutput output = kernel.SimpleAssessmentDirectFailureMechanisms( + FailureMechanismSectionAssemblyCalculatorInputCreator.CreateSimpleCalculationResult(input)); + + return FailureMechanismSectionAssemblyCreator.Create(output.Result); + } + catch (Exception e) + { + throw new FailureMechanismSectionAssemblyCalculatorException(e.Message, e); + } + } + + public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType input) + { + try + { + IFailureMechanismSectionAssemblyCalculatorKernel kernel = factory.CreateFailureMechanismSectionAssemblyKernel(); + CalculationOutput output = kernel.SimpleAssessmentDirectFailureMechanisms( + FailureMechanismSectionAssemblyCalculatorInputCreator.CreateSimplecalclCalculationResultValidityOnly(input)); + + return FailureMechanismSectionAssemblyCreator.Create(output.Result); + } + catch (Exception e) + { + throw new FailureMechanismSectionAssemblyCalculatorException(e.Message, e); + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorException.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorException.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorException.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,68 @@ +// 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.Runtime.Serialization; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly +{ + /// + /// The exception that is thrown when an error occurs while performing a failure mechanism section assembly. + /// + [Serializable] + public class FailureMechanismSectionAssemblyCalculatorException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public FailureMechanismSectionAssemblyCalculatorException() {} + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The error message that explains the reason for the exception. + public FailureMechanismSectionAssemblyCalculatorException(string message) : base(message) {} + + /// + /// Initializes a new instance of the class + /// with a specified error message and a reference to the inner exception that is + /// the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, + /// or a null reference if no inner exception is specified. + public FailureMechanismSectionAssemblyCalculatorException(string message, Exception inner) : base(message, inner) {} + + /// + /// Initializes a new instance of with + /// serialized data. + /// The that holds the serialized + /// object data about the exception being thrown. + /// The that contains contextual + /// information about the source or destination. + /// The parameter is + /// null. + /// The class name is null or + /// is zero (0). + protected FailureMechanismSectionAssemblyCalculatorException(SerializationInfo info, StreamingContext context) : base(info, context) {} + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/IFailureMechanismSectionAssemblyCalculator.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/IFailureMechanismSectionAssemblyCalculator.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/IFailureMechanismSectionAssemblyCalculator.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,57 @@ +// 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 Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly +{ + /// + /// Interface representing a failure mechanism section assembly calculator. + /// + /// + /// This interface is introduced for being able to test the conversion of: + /// + /// Ringtoets failure mechanism section assembly input into kernel input; + /// kernel output into Ringtoets failure mechanism section assembly output. + /// + /// + public interface IFailureMechanismSectionAssemblyCalculator + { + /// + /// Assembles the simple assessment for the given . + /// + /// The to assemble for. + /// A . + /// Thrown when + /// an error occurs when performing the assembly. + FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultType input); + + /// + /// Assembles the simple assessment for the given . + /// + /// The to assemble for. + /// A . + /// Thrown when + /// an error occurs when performing the assembly. + FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType input); + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/AssemblyToolCalculatorFactory.cs =================================================================== diff -u -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/AssemblyToolCalculatorFactory.cs (.../AssemblyToolCalculatorFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/AssemblyToolCalculatorFactory.cs (.../AssemblyToolCalculatorFactory.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -19,8 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; -using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/FailureMechanismSectionAssemblyCalculator.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorException.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/IFailureMechanismSectionAssemblyCalculator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/IAssemblyToolCalculatorFactory.cs =================================================================== diff -u -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/IAssemblyToolCalculatorFactory.cs (.../IAssemblyToolCalculatorFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/IAssemblyToolCalculatorFactory.cs (.../IAssemblyToolCalculatorFactory.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -20,7 +20,7 @@ // All rights reserved. using System; -using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj =================================================================== diff -u -r748636dbdbc3a1c324f3c868ab1ce09e759845ef -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.csproj) (revision 748636dbdbc3a1c324f3c868ab1ce09e759845ef) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.csproj) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -14,9 +14,9 @@ - - - + + + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorExceptionTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorExceptionTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorExceptionTest.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -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. + +using System; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Test.Calculators.Assembly +{ + [TestFixture] + public class FailureMechanismSectionAssemblyCalculatorExceptionTest + : CustomExceptionDesignGuidelinesTestFixture {} +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorTest.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,320 @@ +// 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.ComponentModel; +using AssemblyTool.Kernel; +using AssemblyTool.Kernel.Data; +using AssemblyTool.Kernel.Data.AssemblyCategories; +using AssemblyTool.Kernel.Data.CalculationResults; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Test.Calculators.Assembly +{ + [TestFixture] + public class FailureMechanismSectionAssemblyCalculatorTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var kernelFactory = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var calculator = new FailureMechanismSectionAssemblyCalculator(kernelFactory); + + // Assert + Assert.IsInstanceOf(calculator); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_FactoryNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new FailureMechanismSectionAssemblyCalculator(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("factory", exception.ParamName); + } + + [Test] + public void AssembleSimpleAssessment_WithInvalidEnumInput_ThrowFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment((SimpleAssessmentResultType) 99); + + // Assert + const string expectedMessage = "The value of argument 'input' (99) is invalid for Enum type 'SimpleAssessmentResultType'."; + var exception = Assert.Throws(test); + StringAssert.StartsWith(expectedMessage, exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void AssembleSimpleAssessment_WithValidInput_InputCorrectlySetToKernel() + { + // Setup + const SimpleAssessmentResultType assessmentResult = SimpleAssessmentResultType.AssessFurther; + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.Iv, Probability.NaN)); + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + calculator.AssembleSimpleAssessment(assessmentResult); + + // Assert + Assert.AreEqual(SimpleCalculationResult.VB, kernel.SimpleAssessmentFailureMechanismsInput); + } + } + + [Test] + public void AssembleSimpleAssessment_KernelWithCompleteOutput_OutputCorrectlyReturnedByCalculator() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.Iv, Probability.NaN)); + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultType.AssessFurther); + + // Assert + AssertCalculatorOutput(kernel.FailureMechanismSectionAssemblyCategoryResult, assembly); + } + } + + [Test] + public void AssembleSimpleAssessment_KernelWithInvalidOutput_ThrowFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult((FailureMechanismSectionCategoryGroup) 99, Probability.NaN)); + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment(SimpleAssessmentResultType.AssessFurther); + + // Assert + const string expectedMessage = "The value of argument 'originalGroup' (99) is invalid for Enum type 'FailureMechanismSectionCategoryGroup'."; + var exception = Assert.Throws(test); + StringAssert.StartsWith(expectedMessage, exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void AssembleSimpleAssessment_KernelThrowsException_ThrowFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.ThrowExceptionOnCalculate = true; + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment(SimpleAssessmentResultType.AssessFurther); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.InnerException.Message, exception.Message); + } + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_WithInvalidEnumInput_ThrowFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory)AssemblyToolKernelFactory.Instance; + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment((SimpleAssessmentResultValidityOnlyType) 99); + + // Assert + const string expectedMessage = "The value of argument 'input' (99) is invalid for Enum type 'SimpleAssessmentResultValidityOnlyType'."; + var exception = Assert.Throws(test); + StringAssert.StartsWith(expectedMessage, exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void AssembleSimpleAssessmentvalidityOnly_WithValidInput_InputCorrectlySetToKernel() + { + // Setup + const SimpleAssessmentResultValidityOnlyType assessmentResult = SimpleAssessmentResultValidityOnlyType.Applicable; + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory)AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.Iv, Probability.NaN)); + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + calculator.AssembleSimpleAssessment(assessmentResult); + + // Assert + Assert.AreEqual(SimpleCalculationResultValidityOnly.WVT, kernel.SimpleAssessmentFailureMechanismsValidityOnlyInput); + } + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_KernelWithCompleteOutput_OutputCorrectlyReturnedByCalculator() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory)AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.Iv, Probability.NaN)); + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType.NotApplicable); + + // Assert + AssertCalculatorOutput(kernel.FailureMechanismSectionAssemblyCategoryResult, assembly); + } + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_KernelWithInvalidOutput_ThrowFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory)AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult((FailureMechanismSectionCategoryGroup)99, Probability.NaN)); + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType.Applicable); + + // Assert + const string expectedMessage = "The value of argument 'originalGroup' (99) is invalid for Enum type 'FailureMechanismSectionCategoryGroup'."; + var exception = Assert.Throws(test); + StringAssert.StartsWith(expectedMessage, exception.Message); + Assert.IsInstanceOf(exception.InnerException); + } + } + + [Test] + public void ValidityOnlyAssembleSimpleAssessment_KernelThrowsException_ThrowFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory)AssemblyToolKernelFactory.Instance; + FailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedFailureMechanismSectionAssemblyKernel; + kernel.ThrowExceptionOnCalculate = true; + + var calculator = new FailureMechanismSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType.Applicable); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.InnerException.Message, exception.Message); + } + } + + private static void AssertCalculatorOutput(CalculationOutput original, FailureMechanismSectionAssembly actual) + { + Assert.AreEqual(GetGroup(original.Result.CategoryGroup), actual.Group); + Assert.AreEqual(original.Result.EstimatedProbabilityOfFailure, actual.Probability); + } + + private static FailureMechanismSectionAssemblyCategoryGroup GetGroup(FailureMechanismSectionCategoryGroup originalGroup) + { + switch (originalGroup) + { + case FailureMechanismSectionCategoryGroup.Iv: + return FailureMechanismSectionAssemblyCategoryGroup.Iv; + case FailureMechanismSectionCategoryGroup.IIv: + return FailureMechanismSectionAssemblyCategoryGroup.IIv; + case FailureMechanismSectionCategoryGroup.IIIv: + return FailureMechanismSectionAssemblyCategoryGroup.IIIv; + case FailureMechanismSectionCategoryGroup.IVv: + return FailureMechanismSectionAssemblyCategoryGroup.IVv; + case FailureMechanismSectionCategoryGroup.Vv: + return FailureMechanismSectionAssemblyCategoryGroup.Vv; + case FailureMechanismSectionCategoryGroup.VIv: + return FailureMechanismSectionAssemblyCategoryGroup.VIv; + case FailureMechanismSectionCategoryGroup.VIIv: + return FailureMechanismSectionAssemblyCategoryGroup.VIIv; + case FailureMechanismSectionCategoryGroup.None: + return FailureMechanismSectionAssemblyCategoryGroup.None; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/AssemblyToolCalculatorFactoryTest.cs =================================================================== diff -u -r748636dbdbc3a1c324f3c868ab1ce09e759845ef -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/AssemblyToolCalculatorFactoryTest.cs (.../AssemblyToolCalculatorFactoryTest.cs) (revision 748636dbdbc3a1c324f3c868ab1ce09e759845ef) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/AssemblyToolCalculatorFactoryTest.cs (.../AssemblyToolCalculatorFactoryTest.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -21,7 +21,7 @@ using NUnit.Framework; using Ringtoets.AssemblyTool.KernelWrapper.Calculators; -using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorExceptionTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj =================================================================== diff -u -r748636dbdbc3a1c324f3c868ab1ce09e759845ef -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.Test.csproj) (revision 748636dbdbc3a1c324f3c868ab1ce09e759845ef) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.Test.csproj) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -22,8 +22,8 @@ - - + + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,168 @@ +// 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 NUnit.Framework; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.Calculators.Assembly +{ + [TestFixture] + public class FailureMechanismSectionAssemblyCalculatorStubTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Assert + Assert.IsInstanceOf(calculator); + Assert.IsNull(calculator.SimpleAssessmentAssemblyOutput); + } + + [Test] + public void AssembleSimpleAssessment_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultType.None); + + // Assert + Assert.AreEqual(0, assembly.Probability); + Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.Iv, assembly.Group); + } + + [Test] + public void AssembleSimpleAssessment_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0.4, FailureMechanismSectionAssemblyCategoryGroup.None) + }; + + // Call + FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultType.None); + + // Assert + Assert.AreSame(calculator.SimpleAssessmentAssemblyOutput, assembly); + } + + [Test] + public void AssembleSimpleAssessment_ThrowExceptionOnCalculateFalse_SetsInput() + { + // Setup + const SimpleAssessmentResultType input = SimpleAssessmentResultType.None; + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + calculator.AssembleSimpleAssessment(input); + + // Assert + Assert.AreEqual(input, calculator.SimpleAssessmentInput); + } + + [Test] + public void AssembleSimpleAssessment_ThrowExceptionOnCalculateTrue_ThrowsFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment((SimpleAssessmentResultType) 0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType.None); + + // Assert + Assert.AreEqual(1, assembly.Probability); + Assert.AreEqual(FailureMechanismSectionAssemblyCategoryGroup.VIIv, assembly.Group); + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0.4, FailureMechanismSectionAssemblyCategoryGroup.None) + }; + + // Call + FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType.None); + + // Assert + Assert.AreSame(calculator.SimpleAssessmentAssemblyOutput, assembly); + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_ThrowExceptionOnCalculateFalse_SetsInput() + { + // Setup + const SimpleAssessmentResultValidityOnlyType input = SimpleAssessmentResultValidityOnlyType.None; + var calculator = new FailureMechanismSectionAssemblyCalculatorStub(); + + // Call + calculator.AssembleSimpleAssessment(input); + + // Assert + Assert.AreEqual(input, calculator.SimpleAssessmentValidityOnlyInput); + } + + [Test] + public void AssembleSimpleAssessmentValidityOnly_ThrowExceptionOnCalculateTrue_ThrowsFailureMechanismSectionAssemblyCalculatorException() + { + // Setup + var calculator = new FailureMechanismSectionAssemblyCalculatorStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => calculator.AssembleSimpleAssessment((SimpleAssessmentResultValidityOnlyType) 0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + } + } +} \ No newline at end of file Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStubTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/TestAssemblyToolCalculatorFactoryTest.cs =================================================================== diff -u -r748636dbdbc3a1c324f3c868ab1ce09e759845ef -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/TestAssemblyToolCalculatorFactoryTest.cs (.../TestAssemblyToolCalculatorFactoryTest.cs) (revision 748636dbdbc3a1c324f3c868ab1ce09e759845ef) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/TestAssemblyToolCalculatorFactoryTest.cs (.../TestAssemblyToolCalculatorFactoryTest.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -21,10 +21,10 @@ using NUnit.Framework; using Ringtoets.AssemblyTool.KernelWrapper.Calculators; -using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators; -using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories; namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.Calculators Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,360 @@ +// 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 AssemblyTool.Kernel; +using AssemblyTool.Kernel.Assembly; +using AssemblyTool.Kernel.Assembly.CalculatorInput; +using AssemblyTool.Kernel.Data; +using AssemblyTool.Kernel.Data.AssemblyCategories; +using AssemblyTool.Kernel.Data.CalculationResults; +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 FailureMechanismSectionAssemblyKernelStubTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Assert + Assert.IsInstanceOf(kernel); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.SimpleAssessmentFailureMechanismsInput); + Assert.IsNull(kernel.SimpleAssessmentFailureMechanismsValidityOnlyInput); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernel() + { + // Setup + var random = new Random(39); + var input = random.NextEnumValue(); + + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + kernel.SimpleAssessmentDirectFailureMechanisms(input); + + // Assert + Assert.AreEqual(input, kernel.SimpleAssessmentFailureMechanismsInput); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateFalse_SetCalculatedTrue() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Precondition + Assert.IsFalse(kernel.Calculated); + + // Call + kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResult) 0); + + // Assert + Assert.IsTrue(kernel.Calculated); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyCategoryResult() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.IIIv, Probability.NaN)) + }; + + // Call + CalculationOutput result = kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResult) 0); + + // Assert + Assert.AreSame(kernel.FailureMechanismSectionAssemblyCategoryResult, result); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResult) 0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + Assert.IsNull(kernel.SimpleAssessmentFailureMechanismsInput); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.FailureMechanismSectionAssemblyCategoryResult); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanismsValidityOnly_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernel() + { + // Setup + var random = new Random(39); + var input = random.NextEnumValue(); + + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + kernel.SimpleAssessmentDirectFailureMechanisms(input); + + // Assert + Assert.AreEqual(input, kernel.SimpleAssessmentFailureMechanismsValidityOnlyInput); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanismsValidityOnly_ThrowExceptionOnCalculateFalse_SetCalculatedTrue() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Precondition + Assert.IsFalse(kernel.Calculated); + + // Call + kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResultValidityOnly) 0); + + // Assert + Assert.IsTrue(kernel.Calculated); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanismsValidityOnly_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyCategoryResult() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.IIIv, Probability.NaN)) + }; + + // Call + CalculationOutput result = kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResultValidityOnly) 0); + + // Assert + Assert.AreSame(kernel.FailureMechanismSectionAssemblyCategoryResult, result); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanismsValidityOnly_ThrowExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResultValidityOnly) 0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + Assert.IsNull(kernel.SimpleAssessmentFailureMechanismsInput); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.FailureMechanismSectionAssemblyCategoryResult); + } + + [Test] + public void SimpleAssessmentIndirectFailureMechanisms_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.SimpleAssessmentIndirectFailureMechanisms(0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void DetailedAssessmentDirectFailureMechanisms_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.DetailedAssessmentDirectFailureMechanisms(0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void DetailedAssessmentIndirectFailureMechanisms_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.DetailedAssessmentIndirectFailureMechanisms(0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void DetailedAssessmentDirectFailureMechanismsWithProbability_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.DetailedAssessmentDirectFailureMechanisms((DetailedCalculationInputFromProbability) null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void DetailedAssessmentDirectFailureMechanismsWithBoundaries_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.DetailedAssessmentDirectFailureMechanisms((DetailedCategoryBoundariesCalculationResult) null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void DetailedAssessmentDirectFailureMechanismsWithLengthEffect_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.DetailedAssessmentDirectFailureMechanisms((DetailedCalculationInputFromProbabilityWithLengthEffect) null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void TailorMadeAssessmentDirectFailureMechanisms_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.TailorMadeAssessmentDirectFailureMechanisms((TailorMadeCalculationResult) 0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void TailorMadeAssessmentIndirectFailureMechanisms_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.TailorMadeAssessmentIndirectFailureMechanisms(0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void TailorMadeAssessmentDirectFailureMechanismsWithProbability_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.TailorMadeAssessmentDirectFailureMechanisms((TailorMadeCalculationInputFromProbability) null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void TailorMadeAssessmentDirectFailureMechanismsWithCategories_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.TailorMadeAssessmentDirectFailureMechanisms((TailorMadeCategoryCalculationResult) 0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void TailorMadeAssessmentDirectFailureMechanismsWithLengthEffect_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.TailorMadeAssessmentDirectFailureMechanisms(null); + + // Assert + Assert.Throws(test); + } + + [Test] + public void CombinedAssessmentFromFailureMechanismSectionResults_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.CombinedAssessmentFromFailureMechanismSectionResults(0, 0, 0); + + // Assert + Assert.Throws(test); + } + + [Test] + public void CombinedAssessmentFromFailureMechanismSectionResultsWithCategories_Always_ThrowNotImplementedException() + { + // Setup + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + + // Call + TestDelegate test = () => kernel.CombinedAssessmentFromFailureMechanismSectionResults(null, null, null); + + // Assert + Assert.Throws(test); + } + } +} \ No newline at end of file Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStubTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj =================================================================== diff -u -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -18,10 +18,10 @@ - + - + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,80 @@ +// 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 Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly +{ + /// + /// Failure mechanism section assembly calculator stub for testing purposes. + /// + public class FailureMechanismSectionAssemblyCalculatorStub : IFailureMechanismSectionAssemblyCalculator + { + /// + /// Gets or sets the output of the calculation. + /// + public FailureMechanismSectionAssembly SimpleAssessmentAssemblyOutput { get; set; } + + /// + /// Gets the input of the calculation. + /// + public SimpleAssessmentResultType SimpleAssessmentInput { get; private set; } + + /// + /// Gets the input of the validity only calculation. + /// + public SimpleAssessmentResultValidityOnlyType SimpleAssessmentValidityOnlyInput { get; private set; } + + /// + /// Indicator whether an exception must be thrown when performing a calculation. + /// + public bool ThrowExceptionOnCalculate { private get; set; } + + public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultType input) + { + if (ThrowExceptionOnCalculate) + { + throw new FailureMechanismSectionAssemblyCalculatorException("Message", new Exception()); + } + + SimpleAssessmentInput = input; + + return SimpleAssessmentAssemblyOutput ?? + (SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0, FailureMechanismSectionAssemblyCategoryGroup.Iv)); + } + + public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType input) + { + if (ThrowExceptionOnCalculate) + { + throw new FailureMechanismSectionAssemblyCalculatorException("Message", new Exception()); + } + + SimpleAssessmentValidityOnlyInput = input; + + return SimpleAssessmentAssemblyOutput ?? + (SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(1, FailureMechanismSectionAssemblyCategoryGroup.VIIv)); + } + } +} Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStub.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/TestAssemblyToolCalculatorFactory.cs =================================================================== diff -u -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/TestAssemblyToolCalculatorFactory.cs (.../TestAssemblyToolCalculatorFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/TestAssemblyToolCalculatorFactory.cs (.../TestAssemblyToolCalculatorFactory.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -20,10 +20,10 @@ // All rights reserved. using Ringtoets.AssemblyTool.KernelWrapper.Calculators; -using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Categories; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; -using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories; namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -0,0 +1,150 @@ +// 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 AssemblyTool.Kernel; +using AssemblyTool.Kernel.Assembly; +using AssemblyTool.Kernel.Assembly.CalculatorInput; +using AssemblyTool.Kernel.Data.AssemblyCategories; +using AssemblyTool.Kernel.Data.CalculationResults; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly +{ + /// + /// Failure mechanism section assembly kernel stub for testing purposes. + /// + public class FailureMechanismSectionAssemblyKernelStub : IFailureMechanismSectionAssemblyCalculator + { + /// + /// Gets the input used in . + /// + public SimpleCalculationResult? SimpleAssessmentFailureMechanismsInput { get; private set; } + + /// + /// Gets the input used in . + /// + public SimpleCalculationResultValidityOnly? SimpleAssessmentFailureMechanismsValidityOnlyInput { get; private 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; } + + /// + /// Gets or sets the failure mechanism section assembly category result. + /// + public CalculationOutput FailureMechanismSectionAssemblyCategoryResult { get; set; } + + public CalculationOutput SimpleAssessmentDirectFailureMechanisms(SimpleCalculationResult result) + { + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + SimpleAssessmentFailureMechanismsInput = result; + Calculated = true; + return FailureMechanismSectionAssemblyCategoryResult; + } + + public CalculationOutput SimpleAssessmentIndirectFailureMechanisms(SimpleCalculationResult result) + { + throw new NotImplementedException(); + } + + public CalculationOutput SimpleAssessmentDirectFailureMechanisms(SimpleCalculationResultValidityOnly result) + { + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + SimpleAssessmentFailureMechanismsValidityOnlyInput = result; + Calculated = true; + return FailureMechanismSectionAssemblyCategoryResult; + } + + public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationResult result) + { + throw new NotImplementedException(); + } + + public CalculationOutput DetailedAssessmentIndirectFailureMechanisms(DetailedCalculationResult result) + { + throw new NotImplementedException(); + } + + public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationInputFromProbability input) + { + throw new NotImplementedException(); + } + + public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCategoryBoundariesCalculationResult calculationResults) + { + throw new NotImplementedException(); + } + + public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationInputFromProbabilityWithLengthEffect input) + { + throw new NotImplementedException(); + } + + public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationResult result) + { + throw new NotImplementedException(); + } + + public CalculationOutput TailorMadeAssessmentIndirectFailureMechanisms(TailorMadeCalculationResult result) + { + throw new NotImplementedException(); + } + + public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationInputFromProbability input) + { + throw new NotImplementedException(); + } + + public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCategoryCalculationResult result) + { + throw new NotImplementedException(); + } + + public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationInputFromProbabilityWithLengthEffectFactor input) + { + throw new NotImplementedException(); + } + + public CalculationOutput CombinedAssessmentFromFailureMechanismSectionResults(FailureMechanismSectionCategoryGroup resultSimpleAssessment, FailureMechanismSectionCategoryGroup resultDetailedAssessment, FailureMechanismSectionCategoryGroup resultTailorMadeAssessment) + { + throw new NotImplementedException(); + } + + public CalculationOutput CombinedAssessmentFromFailureMechanismSectionResults(FailureMechanismSectionAssemblyCategoryResult resultSimpleAssessment, FailureMechanismSectionAssemblyCategoryResult resultDetailedAssessment, FailureMechanismSectionAssemblyCategoryResult resultTailorMadeAssessment) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file Fisheye: Tag 39e13825618c9845e2100ae802a007c04c2e8517 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStub.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/TestAssemblyToolKernelFactory.cs =================================================================== diff -u -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/TestAssemblyToolKernelFactory.cs (.../TestAssemblyToolKernelFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/TestAssemblyToolKernelFactory.cs (.../TestAssemblyToolKernelFactory.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -22,7 +22,7 @@ using AssemblyTool.Kernel.Assembly; using AssemblyTool.Kernel.Categories; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; -using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Categories; namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 -r39e13825618c9845e2100ae802a007c04c2e8517 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 39e13825618c9845e2100ae802a007c04c2e8517) @@ -16,11 +16,11 @@ - + - +