Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs =================================================================== diff -u -r37b7aaa490f9f15c5722f95917802dac6bd8318d -r3199add8dbd09d0b4a9727fd6092ccc16d86563c --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs (.../FailureMechanismSectionAssemblyKernelStubTest.cs) (revision 37b7aaa490f9f15c5722f95917802dac6bd8318d) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs (.../FailureMechanismSectionAssemblyKernelStubTest.cs) (revision 3199add8dbd09d0b4a9727fd6092ccc16d86563c) @@ -460,19 +460,91 @@ } [Test] - public void TailorMadeAssessmentDirectFailureMechanismsWithProbability_Always_ThrowNotImplementedException() + public void TailorMadeAssessmentDirectFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() { // Setup + var random = new Random(39); + var input = new TailorMadeCalculationInputFromProbability( + new TailorMadeProbabilityCalculationResult(new Probability(random.NextDouble())), + new[] + { + new FailureMechanismSectionCategory(random.NextEnumValue(), + new Probability(random.NextRoundedDouble(0.0, 0.5)), + new Probability(random.NextRoundedDouble(0.6, 1.0))) + }); + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + // Precondition + Assert.IsFalse(kernel.Calculated); + // Call - TestDelegate test = () => kernel.TailorMadeAssessmentDirectFailureMechanisms((TailorMadeCalculationInputFromProbability) null); + kernel.TailorMadeAssessmentDirectFailureMechanisms(input); // Assert - Assert.Throws(test); + Assert.AreSame(input, kernel.TailorMadeCalculationInputFromProbabilityInput); + Assert.IsTrue(kernel.Calculated); } [Test] + public void TailorMadeAssessmentDirectFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyCategoryResult() + { + // Setup + var random = new Random(39); + var input = new TailorMadeCalculationInputFromProbability( + new TailorMadeProbabilityCalculationResult(new Probability(random.NextDouble())), + new[] + { + new FailureMechanismSectionCategory(random.NextEnumValue(), + new Probability(random.NextRoundedDouble(0.0, 0.5)), + new Probability(random.NextRoundedDouble(0.6, 1.0))) + }); + + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.IIIv, Probability.NaN)) + }; + + // Call + CalculationOutput result = kernel.TailorMadeAssessmentDirectFailureMechanisms(input); + + // Assert + Assert.AreSame(kernel.FailureMechanismSectionAssemblyCategoryResult, result); + } + + [Test] + public void TailorMadeAssessmentDirectFailureMechanismsWithProbability_ThrowExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var random = new Random(39); + var input = new TailorMadeCalculationInputFromProbability( + new TailorMadeProbabilityCalculationResult(new Probability(random.NextDouble())), + new[] + { + new FailureMechanismSectionCategory(random.NextEnumValue(), + new Probability(random.NextRoundedDouble(0.0, 0.5)), + new Probability(random.NextRoundedDouble(0.6, 1.0))) + }); + + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.TailorMadeAssessmentDirectFailureMechanisms(input); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + Assert.IsNull(kernel.TailorMadeCalculationInputFromProbabilityInput); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.FailureMechanismSectionAssemblyCategoryResult); + } + + [Test] public void TailorMadeAssessmentDirectFailureMechanismsWithCategories_Always_ThrowNotImplementedException() { // Setup Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs =================================================================== diff -u -r37b7aaa490f9f15c5722f95917802dac6bd8318d -r3199add8dbd09d0b4a9727fd6092ccc16d86563c --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs (.../FailureMechanismSectionAssemblyKernelStub.cs) (revision 37b7aaa490f9f15c5722f95917802dac6bd8318d) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs (.../FailureMechanismSectionAssemblyKernelStub.cs) (revision 3199add8dbd09d0b4a9727fd6092ccc16d86563c) @@ -54,6 +54,11 @@ public DetailedCalculationInputFromProbabilityWithLengthEffect DetailedAssessmentFailureMechanismFromProbabilityWithLengthEffectInput { get; private set; } /// + /// Gets the input used in . + /// + public TailorMadeCalculationInputFromProbability TailorMadeCalculationInputFromProbabilityInput { get; private set; } + + /// /// Gets a value indicating whether a calculation was called or not. /// public bool Calculated { get; private set; } @@ -183,7 +188,14 @@ public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationInputFromProbability input) { - throw new NotImplementedException(); + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + TailorMadeCalculationInputFromProbabilityInput = input; + Calculated = true; + return FailureMechanismSectionAssemblyCategoryResult; } public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCategoryCalculationResult result)