Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Categories/AssemblyCategoriesCalculator.cs =================================================================== diff -u -raf2dccd51c7d3ece1434603ea37e8f75cdbb54a2 -rc1069e6cf39338685915adbe417b2bfa28e3ac22 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Categories/AssemblyCategoriesCalculator.cs (.../AssemblyCategoriesCalculator.cs) (revision af2dccd51c7d3ece1434603ea37e8f75cdbb54a2) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Categories/AssemblyCategoriesCalculator.cs (.../AssemblyCategoriesCalculator.cs) (revision c1069e6cf39338685915adbe417b2bfa28e3ac22) @@ -57,9 +57,9 @@ { try { - var kernelInput = new CalculateAssessmentSectionCategoriesInput(new Probability(signalingNorm), new Probability(lowerBoundaryNorm)); + var input = new CalculateAssessmentSectionCategoriesInput(new Probability(signalingNorm), new Probability(lowerBoundaryNorm)); ICategoriesCalculator kernel = factory.CreateAssemblyCategoriesKernel(); - CalculationOutput output = kernel.CalculateAssessmentSectionCategories(kernelInput); + CalculationOutput output = kernel.CalculateAssessmentSectionCategories(input); return AssessmentSectionAssemblyCategoryCreator.CreateAssessmentSectionAssemblyCategories(output); } @@ -68,5 +68,11 @@ throw new AssemblyCategoriesCalculatorException(e.Message, e); } } + + public IEnumerable CalculateFailureMechanismSectionCategories(double signalingNorm, double lowerBoundaryNorm, + double probabilityDistributionFactor, double n) + { + throw new NotImplementedException(); + } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Categories/IAssemblyCategoriesCalculator.cs =================================================================== diff -u -r7f7cb92f29ad73708c2346df6efd1c39fc29d41c -rc1069e6cf39338685915adbe417b2bfa28e3ac22 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Categories/IAssemblyCategoriesCalculator.cs (.../IAssemblyCategoriesCalculator.cs) (revision 7f7cb92f29ad73708c2346df6efd1c39fc29d41c) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Categories/IAssemblyCategoriesCalculator.cs (.../IAssemblyCategoriesCalculator.cs) (revision c1069e6cf39338685915adbe417b2bfa28e3ac22) @@ -28,13 +28,6 @@ /// /// Interface representing an assembly categories calculator. /// - /// - /// This interface is introduced for being able to test the conversion of: - /// - /// Ringtoets assembly categories input into calculator input; - /// calculator output into Ringtoets assembly categories output. - /// - /// public interface IAssemblyCategoriesCalculator { /// @@ -43,10 +36,24 @@ /// The signaling norm to calculate with. /// The lower boundary norm to calculate with. /// An with categories of - /// . + /// . /// Thrown when an error occurs /// when performing the calculation. IEnumerable CalculateAssessmentSectionCategories( double signalingNorm, double lowerBoundaryNorm); + + /// + /// Performs the calculation for getting the failure mechanism section categories. + /// + /// The signaling norm to calculate with. + /// The lower boundary norm to calculate with. + /// The probability distribution factor to calculate with. + /// The n to calculate with. + /// An with categories of + /// . + /// Thrown when an error occurs + /// when performing the calculation. + IEnumerable CalculateFailureMechanismSectionCategories( + double signalingNorm, double lowerBoundaryNorm, double probabilityDistributionFactor, double n); } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Categories/AssemblyCategoriesCalculatorTest.cs =================================================================== diff -u -raf2dccd51c7d3ece1434603ea37e8f75cdbb54a2 -rc1069e6cf39338685915adbe417b2bfa28e3ac22 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Categories/AssemblyCategoriesCalculatorTest.cs (.../AssemblyCategoriesCalculatorTest.cs) (revision af2dccd51c7d3ece1434603ea37e8f75cdbb54a2) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Categories/AssemblyCategoriesCalculatorTest.cs (.../AssemblyCategoriesCalculatorTest.cs) (revision c1069e6cf39338685915adbe417b2bfa28e3ac22) @@ -141,6 +141,23 @@ } } + [Test] + public void CalculateFailureMechanismSectionCategories_Always_ThrowsNotImplementedException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + var calculator = new AssemblyCategoriesCalculator(factory); + + // Call + TestDelegate test = () => calculator.CalculateFailureMechanismSectionCategories(0, 0, 0, 0); + + // Assert + Assert.Throws(test); + } + } + private static CalculationOutput CreateKernelOutput() { var random = new Random(11); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Categories/AssemblyCategoriesCalculatorStubTest.cs =================================================================== diff -u -r7f7cb92f29ad73708c2346df6efd1c39fc29d41c -rc1069e6cf39338685915adbe417b2bfa28e3ac22 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Categories/AssemblyCategoriesCalculatorStubTest.cs (.../AssemblyCategoriesCalculatorStubTest.cs) (revision 7f7cb92f29ad73708c2346df6efd1c39fc29d41c) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Categories/AssemblyCategoriesCalculatorStubTest.cs (.../AssemblyCategoriesCalculatorStubTest.cs) (revision c1069e6cf39338685915adbe417b2bfa28e3ac22) @@ -41,6 +41,7 @@ // Assert Assert.IsInstanceOf(calculator); Assert.IsNull(calculator.AssessmentSectionCategoriesOutput); + Assert.IsNull(calculator.FailureMechanismSectionCategoriesOutput); } [Test] @@ -126,5 +127,93 @@ Assert.AreEqual("Message", exception.Message); Assert.IsNotNull(exception.InnerException); } + + [Test] + public void CalculateFailureMechanismSectionCategories_OutputNotSetAndThrowExceptionOnCalculateFalse_ReturnsCategories() + { + // Setup + var calculator = new AssemblyCategoriesCalculatorStub(); + + // Call + FailureMechanismSectionAssemblyCategory[] result = calculator.CalculateFailureMechanismSectionCategories(0, 0, 0, 0).ToArray(); + + // Assert + Assert.AreEqual(3, result.Length); + CollectionAssert.AreEqual(new[] + { + 1, + 2.01, + 3.01 + }, result.Select(r => r.LowerBoundary)); + CollectionAssert.AreEqual(new[] + { + 2, + 3, + 4 + }, result.Select(r => r.UpperBoundary)); + CollectionAssert.AreEqual(new[] + { + FailureMechanismSectionAssemblyCategoryGroup.Iv, + FailureMechanismSectionAssemblyCategoryGroup.IIv, + FailureMechanismSectionAssemblyCategoryGroup.IIIv + }, result.Select(r => r.Group)); + } + + [Test] + public void CalculateFailureMechanismSectionCategories_OutputSetAndThrowExceptionOnCalculateFalse_ReturnsCategories() + { + // Setup + var output = new FailureMechanismSectionAssemblyCategory[0]; + var calculator = new AssemblyCategoriesCalculatorStub + { + FailureMechanismSectionCategoriesOutput = output + }; + + // Call + IEnumerable result = calculator.CalculateFailureMechanismSectionCategories(0 ,0, 0, 0); + + // Assert + Assert.AreSame(output, result); + } + + [Test] + public void CalculateFailureMechanismSectionCategories_ThrowExceptionOnCalculateFalse_SetsInput() + { + // Setup + var random = new Random(39); + double signalingNorm = random.NextDouble(); + double lowerBoundaryNorm = random.NextDouble(); + double probabilityDistributionFactor = random.NextDouble(); + double n = random.NextDouble(); + + var calculator = new AssemblyCategoriesCalculatorStub(); + + // Call + calculator.CalculateFailureMechanismSectionCategories(signalingNorm, lowerBoundaryNorm, probabilityDistributionFactor, n); + + // Assert + Assert.AreEqual(signalingNorm, calculator.SignalingNorm); + Assert.AreEqual(lowerBoundaryNorm, calculator.LowerBoundaryNorm); + Assert.AreEqual(probabilityDistributionFactor, calculator.ProbabilityDistributionFactor); + Assert.AreEqual(n, calculator.N); + } + + [Test] + public void CalculateFailureMechanismSectionCategories_ThrowExceptionOnCalculateTrue_ThrowsAssemblyCategoriesCalculatorException() + { + // Setup + var calculator = new AssemblyCategoriesCalculatorStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => calculator.CalculateFailureMechanismSectionCategories(0, 0, 0, 0); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Categories/AssemblyCategoriesCalculatorStub.cs =================================================================== diff -u -raf2dccd51c7d3ece1434603ea37e8f75cdbb54a2 -rc1069e6cf39338685915adbe417b2bfa28e3ac22 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Categories/AssemblyCategoriesCalculatorStub.cs (.../AssemblyCategoriesCalculatorStub.cs) (revision af2dccd51c7d3ece1434603ea37e8f75cdbb54a2) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Categories/AssemblyCategoriesCalculatorStub.cs (.../AssemblyCategoriesCalculatorStub.cs) (revision c1069e6cf39338685915adbe417b2bfa28e3ac22) @@ -42,11 +42,26 @@ public double LowerBoundaryNorm { get; private set; } /// + /// Gets the probability distribution factor that is used in the calculation. + /// + public double ProbabilityDistributionFactor { get; private set; } + + /// + /// Gets the n that is used in the calculation. + /// + public double N { get; private set; } + + /// /// Gets or sets the output of the calculation. /// public IEnumerable AssessmentSectionCategoriesOutput { get; set; } /// + /// Gets or sets the output of the calculation. + /// + public IEnumerable FailureMechanismSectionCategoriesOutput { get; set; } + + /// /// Indicator whether an exception must be thrown when performing the calculation. /// public bool ThrowExceptionOnCalculate { private get; set; } @@ -69,5 +84,27 @@ new AssessmentSectionAssemblyCategory(3.01, 4, AssessmentSectionAssemblyCategoryGroup.C) }); } + + public IEnumerable CalculateFailureMechanismSectionCategories(double signalingNorm, double lowerBoundaryNorm, + double probabilityDistributionFactor, double n) + { + if (ThrowExceptionOnCalculate) + { + throw new AssemblyCategoriesCalculatorException("Message", new Exception()); + } + + SignalingNorm = signalingNorm; + LowerBoundaryNorm = lowerBoundaryNorm; + ProbabilityDistributionFactor = probabilityDistributionFactor; + N = n; + + return FailureMechanismSectionCategoriesOutput + ?? (FailureMechanismSectionCategoriesOutput = new[] + { + new FailureMechanismSectionAssemblyCategory(1, 2, FailureMechanismSectionAssemblyCategoryGroup.Iv), + new FailureMechanismSectionAssemblyCategory(2.01, 3, FailureMechanismSectionAssemblyCategoryGroup.IIv), + new FailureMechanismSectionAssemblyCategory(3.01, 4, FailureMechanismSectionAssemblyCategoryGroup.IIIv) + }); + } } } \ No newline at end of file