Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/AssemblyToolCalculatorFactory.cs =================================================================== diff -u -r9c274457523062aad7b755fa88b20277c5d86bcb -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/AssemblyToolCalculatorFactory.cs (.../AssemblyToolCalculatorFactory.cs) (revision 9c274457523062aad7b755fa88b20277c5d86bcb) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/AssemblyToolCalculatorFactory.cs (.../AssemblyToolCalculatorFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -55,9 +55,9 @@ return new AssemblyCategoriesCalculator(factory); } - public IFailureMechanismSectionAssessmentAssemblyCalculator CreateFailureMechanismSectionAssessmentAssemblyCalculator(IAssemblyToolKernelFactory factory) + public IFailureMechanismSectionAssemblyCalculator CreateFailureMechanismSectionAssemblyCalculator(IAssemblyToolKernelFactory factory) { - return new FailureMechanismSectionAssessmentAssemblyCalculator(factory); + return new FailureMechanismSectionAssemblyCalculator(factory); } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/FailureMechanismSectionAssemblyCalculator.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/FailureMechanismSectionAssemblyCalculator.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/FailureMechanismSectionAssemblyCalculator.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assembly; +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; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assessments +{ + /// + /// 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 + { + global::AssemblyTool.Kernel.Assembly.IFailureMechanismSectionAssemblyCalculator kernel = factory.CreateFailureMechanismSectionAssemblyKernel(); + CalculationOutput output = kernel.SimpleAssessmentDirectFailureMechanisms( + FailureMechanismSectionAssemblyCalculatorInputCreator.CreateSimpleCalculationResult(input)); + + return FailureMechanismSectionAssemblyCreator.Create(output.Result); + } + catch (Exception e) + { + throw new FailureMechanismSectionAssessmentAssemblyCalculatorException(e.Message, e); + } + } + + public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType input) + { + try + { + global::AssemblyTool.Kernel.Assembly.IFailureMechanismSectionAssemblyCalculator kernel = factory.CreateFailureMechanismSectionAssemblyKernel(); + CalculationOutput output = kernel.SimpleAssessmentDirectFailureMechanisms( + FailureMechanismSectionAssemblyCalculatorInputCreator.CreateSimplecalclCalculationResultValidityOnly(input)); + + return FailureMechanismSectionAssemblyCreator.Create(output.Result); + } + catch (Exception e) + { + throw new FailureMechanismSectionAssessmentAssemblyCalculatorException(e.Message, e); + } + } + } +} \ No newline at end of file Fisheye: Tag 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/FailureMechanismSectionAssessmentAssemblyCalculator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/IFailureMechanismSectionAssemblyCalculator.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/IFailureMechanismSectionAssemblyCalculator.cs (revision 0) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/IFailureMechanismSectionAssemblyCalculator.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assessments +{ + /// + /// 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 Fisheye: Tag 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assessments/IFailureMechanismSectionAssessmentAssemblyCalculator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/IAssemblyToolCalculatorFactory.cs =================================================================== diff -u -r9c274457523062aad7b755fa88b20277c5d86bcb -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/IAssemblyToolCalculatorFactory.cs (.../IAssemblyToolCalculatorFactory.cs) (revision 9c274457523062aad7b755fa88b20277c5d86bcb) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/IAssemblyToolCalculatorFactory.cs (.../IAssemblyToolCalculatorFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -40,11 +40,11 @@ IAssemblyCategoriesCalculator CreateAssemblyCategoriesCalculator(IAssemblyToolKernelFactory factory); /// - /// Creates a failure mechanism section assessment assembly calculator. + /// Creates a failure mechanism section assembly calculator. /// /// The factory responsible for creating the assembly kernel. - /// The failure mechanism section assessment assembly calculator. + /// The failure mechanism section assembly calculator. /// Thrown when is null. - IFailureMechanismSectionAssessmentAssemblyCalculator CreateFailureMechanismSectionAssessmentAssemblyCalculator(IAssemblyToolKernelFactory factory); + IFailureMechanismSectionAssemblyCalculator CreateFailureMechanismSectionAssemblyCalculator(IAssemblyToolKernelFactory factory); } } \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj =================================================================== diff -u -r5b0e8c5af142efae756ed228ffd8ddbd8457474a -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.csproj) (revision 5b0e8c5af142efae756ed228ffd8ddbd8457474a) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Ringtoets.AssemblyTool.KernelWrapper.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.csproj) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -14,9 +14,9 @@ - + - + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/AssemblyToolCalculatorFactoryTest.cs =================================================================== diff -u -raf2dccd51c7d3ece1434603ea37e8f75cdbb54a2 -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/AssemblyToolCalculatorFactoryTest.cs (.../AssemblyToolCalculatorFactoryTest.cs) (revision af2dccd51c7d3ece1434603ea37e8f75cdbb54a2) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/AssemblyToolCalculatorFactoryTest.cs (.../AssemblyToolCalculatorFactoryTest.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -96,11 +96,11 @@ using (new AssemblyToolKernelFactoryConfig()) { // Call - IFailureMechanismSectionAssessmentAssemblyCalculator calculator = factory.CreateFailureMechanismSectionAssessmentAssemblyCalculator( + IFailureMechanismSectionAssemblyCalculator calculator = factory.CreateFailureMechanismSectionAssemblyCalculator( AssemblyToolKernelFactory.Instance); // Assert - Assert.IsInstanceOf(calculator); + Assert.IsInstanceOf(calculator); } } } Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorTest.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.Kernels; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Kernels.Assessments; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.Test.Calculators.Assessments +{ + [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_ThrowFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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_ThrowFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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_ThrowFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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_ThrowFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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_ThrowFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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_ThrowFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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 Fisheye: Tag 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assessments/FailureMechanismSectionAssessmentAssemblyCalculatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj =================================================================== diff -u -r5b0e8c5af142efae756ed228ffd8ddbd8457474a -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.Test.csproj) (revision 5b0e8c5af142efae756ed228ffd8ddbd8457474a) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Ringtoets.AssemblyTool.KernelWrapper.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.Test.csproj) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -23,7 +23,7 @@ - + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStubTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStubTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStubTest.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assessments; +using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assessments; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.Calculators.Assessments +{ + [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_ThrowsFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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_ThrowsFailureMechanismSectionAssessmentAssemblyCalculatorException() + { + // 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 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assessments/FailureMechanismSectionAssessmentAssemblyCalculatorStubTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/TestAssemblyToolCalculatorFactoryTest.cs =================================================================== diff -u -r3b93c6ea184a8517cebfe202dde334069e0cbe59 -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/TestAssemblyToolCalculatorFactoryTest.cs (.../TestAssemblyToolCalculatorFactoryTest.cs) (revision 3b93c6ea184a8517cebfe202dde334069e0cbe59) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/TestAssemblyToolCalculatorFactoryTest.cs (.../TestAssemblyToolCalculatorFactoryTest.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -41,7 +41,7 @@ // Assert Assert.IsInstanceOf(factory); Assert.IsNotNull(factory.LastCreatedAssemblyCategoriesCalculator); - Assert.IsNotNull(factory.LastCreatedFailureMechanismSectionAssessmentAssemblyCalculator); + Assert.IsNotNull(factory.LastCreatedFailureMechanismSectionAssemblyCalculator); } [Test] @@ -65,11 +65,11 @@ var factory = new TestAssemblyToolCalculatorFactory(); // Call - IFailureMechanismSectionAssessmentAssemblyCalculator calculator = factory.CreateFailureMechanismSectionAssessmentAssemblyCalculator(null); + IFailureMechanismSectionAssemblyCalculator calculator = factory.CreateFailureMechanismSectionAssemblyCalculator(null); // Assert - Assert.IsInstanceOf(calculator); - Assert.AreSame(factory.LastCreatedFailureMechanismSectionAssessmentAssemblyCalculator, calculator); + Assert.IsInstanceOf(calculator); + Assert.AreSame(factory.LastCreatedFailureMechanismSectionAssemblyCalculator, calculator); } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStubTest.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStubTest.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStubTest.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assessments; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.Kernels.Assessments +{ + [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 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStubTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/TestAssemblyToolKernelFactoryTest.cs =================================================================== diff -u -rc0389fd4c1b36538e525337a16b67f30ae866f7b -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/TestAssemblyToolKernelFactoryTest.cs (.../TestAssemblyToolKernelFactoryTest.cs) (revision c0389fd4c1b36538e525337a16b67f30ae866f7b) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/TestAssemblyToolKernelFactoryTest.cs (.../TestAssemblyToolKernelFactoryTest.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -39,7 +39,7 @@ // Assert Assert.IsInstanceOf(factory); Assert.IsNotNull(factory.LastCreatedAssemblyCategoriesKernel); - Assert.IsNotNull(factory.LastCreatedFailureMechanismSectionAssessmentAssemblyKernel); + Assert.IsNotNull(factory.LastCreatedFailureMechanismSectionAssemblyKernel); } [Test] @@ -65,7 +65,7 @@ IFailureMechanismSectionAssemblyCalculator kernel = factory.CreateFailureMechanismSectionAssemblyKernel(); // Assert - Assert.AreSame(factory.LastCreatedFailureMechanismSectionAssessmentAssemblyKernel, kernel); + Assert.AreSame(factory.LastCreatedFailureMechanismSectionAssemblyKernel, kernel); } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj =================================================================== diff -u -rfc7fbe9882364e7caae2093c378d3cacd8858d00 -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision fc7fbe9882364e7caae2093c378d3cacd8858d00) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -18,10 +18,10 @@ - + - + Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStub.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStub.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assessments/FailureMechanismSectionAssemblyCalculatorStub.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assessments; +using Ringtoets.Common.Data.AssemblyTool; +using Ringtoets.Common.Data.FailureMechanism; + +namespace Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assessments +{ + /// + /// 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 FailureMechanismSectionAssessmentAssemblyCalculatorException("Message", new Exception()); + } + + SimpleAssessmentInput = input; + + return SimpleAssessmentAssemblyOutput ?? + (SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0, FailureMechanismSectionAssemblyCategoryGroup.Iv)); + } + + public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType input) + { + if (ThrowExceptionOnCalculate) + { + throw new FailureMechanismSectionAssessmentAssemblyCalculatorException("Message", new Exception()); + } + + SimpleAssessmentValidityOnlyInput = input; + + return SimpleAssessmentAssemblyOutput ?? + (SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(1, FailureMechanismSectionAssemblyCategoryGroup.VIIv)); + } + } +} Fisheye: Tag 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assessments/FailureMechanismSectionAssessmentAssemblyCalculatorStub.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/TestAssemblyToolCalculatorFactory.cs =================================================================== diff -u -r3b93c6ea184a8517cebfe202dde334069e0cbe59 -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/TestAssemblyToolCalculatorFactory.cs (.../TestAssemblyToolCalculatorFactory.cs) (revision 3b93c6ea184a8517cebfe202dde334069e0cbe59) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/TestAssemblyToolCalculatorFactory.cs (.../TestAssemblyToolCalculatorFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -39,7 +39,7 @@ public TestAssemblyToolCalculatorFactory() { LastCreatedAssemblyCategoriesCalculator = new AssemblyCategoriesCalculatorStub(); - LastCreatedFailureMechanismSectionAssessmentAssemblyCalculator = new FailureMechanismSectionAssessmentAssemblyCalculatorStub(); + LastCreatedFailureMechanismSectionAssemblyCalculator = new FailureMechanismSectionAssemblyCalculatorStub(); } /// @@ -48,18 +48,18 @@ public AssemblyCategoriesCalculatorStub LastCreatedAssemblyCategoriesCalculator { get; } /// - /// Gets the last created . + /// Gets the last created . /// - public FailureMechanismSectionAssessmentAssemblyCalculatorStub LastCreatedFailureMechanismSectionAssessmentAssemblyCalculator { get; } + public FailureMechanismSectionAssemblyCalculatorStub LastCreatedFailureMechanismSectionAssemblyCalculator { get; } public IAssemblyCategoriesCalculator CreateAssemblyCategoriesCalculator(IAssemblyToolKernelFactory factory) { return LastCreatedAssemblyCategoriesCalculator; } - public IFailureMechanismSectionAssessmentAssemblyCalculator CreateFailureMechanismSectionAssessmentAssemblyCalculator(IAssemblyToolKernelFactory factory) + public IFailureMechanismSectionAssemblyCalculator CreateFailureMechanismSectionAssemblyCalculator(IAssemblyToolKernelFactory factory) { - return LastCreatedFailureMechanismSectionAssessmentAssemblyCalculator; + return LastCreatedFailureMechanismSectionAssemblyCalculator; } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStub.cs =================================================================== diff -u --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStub.cs (revision 0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssemblyKernelStub.cs (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -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.Assessments +{ + /// + /// 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 9ec0b6f985cdd1b151e4081ca256194eb09a32f0 refers to a dead (removed) revision in file `Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStub.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/TestAssemblyToolKernelFactory.cs =================================================================== diff -u -rc0389fd4c1b36538e525337a16b67f30ae866f7b -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/TestAssemblyToolKernelFactory.cs (.../TestAssemblyToolKernelFactory.cs) (revision c0389fd4c1b36538e525337a16b67f30ae866f7b) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/TestAssemblyToolKernelFactory.cs (.../TestAssemblyToolKernelFactory.cs) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -38,7 +38,7 @@ public TestAssemblyToolKernelFactory() { LastCreatedAssemblyCategoriesKernel = new AssemblyCategoriesKernelStub(); - LastCreatedFailureMechanismSectionAssessmentAssemblyKernel = new FailureMechanismSectionAssessmentAssemblyKernelStub(); + LastCreatedFailureMechanismSectionAssemblyKernel = new FailureMechanismSectionAssemblyKernelStub(); } /// @@ -47,9 +47,9 @@ public AssemblyCategoriesKernelStub LastCreatedAssemblyCategoriesKernel { get; } /// - /// Gets the last created failure mechanism section assessment assembly kernel. + /// Gets the last created failure mechanism section assembly kernel. /// - public FailureMechanismSectionAssessmentAssemblyKernelStub LastCreatedFailureMechanismSectionAssessmentAssemblyKernel { get; } + public FailureMechanismSectionAssemblyKernelStub LastCreatedFailureMechanismSectionAssemblyKernel { get; } public ICategoriesCalculator CreateAssemblyCategoriesKernel() { @@ -58,7 +58,7 @@ public IFailureMechanismSectionAssemblyCalculator CreateFailureMechanismSectionAssemblyKernel() { - return LastCreatedFailureMechanismSectionAssessmentAssemblyKernel; + return LastCreatedFailureMechanismSectionAssemblyKernel; } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj =================================================================== diff -u -rc0389fd4c1b36538e525337a16b67f30ae866f7b -r9ec0b6f985cdd1b151e4081ca256194eb09a32f0 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision c0389fd4c1b36538e525337a16b67f30ae866f7b) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.csproj) (revision 9ec0b6f985cdd1b151e4081ca256194eb09a32f0) @@ -16,11 +16,11 @@ - + - +