Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs =================================================================== diff -u -r39e13825618c9845e2100ae802a007c04c2e8517 -r55dfc8f739672258343f1c85bac8629498b5b21e --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs (.../FailureMechanismSectionAssemblyKernelStubTest.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStubTest.cs (.../FailureMechanismSectionAssemblyKernelStubTest.cs) (revision 55dfc8f739672258343f1c85bac8629498b5b21e) @@ -48,6 +48,8 @@ Assert.IsNull(kernel.SimpleAssessmentFailureMechanismsValidityOnlyInput); } + #region Simple Assessment + [Test] public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernel() { @@ -201,6 +203,10 @@ Assert.Throws(test); } + #endregion + + #region Detailed Assessment + [Test] public void DetailedAssessmentDirectFailureMechanisms_Always_ThrowNotImplementedException() { @@ -228,19 +234,91 @@ } [Test] - public void DetailedAssessmentDirectFailureMechanismsWithProbability_Always_ThrowNotImplementedException() + public void DetailedAssessmentDirectFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() { // Setup + var random = new Random(39); + var input = new DetailedCalculationInputFromProbability( + 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.DetailedAssessmentDirectFailureMechanisms((DetailedCalculationInputFromProbability) null); + kernel.DetailedAssessmentDirectFailureMechanisms(input); // Assert - Assert.Throws(test); + Assert.AreSame(input, kernel.DetailedAssessmentFailureMechanismFromProbabilityInput); + Assert.IsTrue(kernel.Calculated); } [Test] + public void DetailedAssessmentDirectFailureMechanismsWithProbability_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyCategoryResult() + { + // Setup + var random = new Random(39); + var input = new DetailedCalculationInputFromProbability( + 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.DetailedAssessmentDirectFailureMechanisms(input); + + // Assert + Assert.AreSame(kernel.FailureMechanismSectionAssemblyCategoryResult, result); + } + + [Test] + public void DetailedAssessmentDirectFailureMechanismsWithProbability_ThrowExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var random = new Random(39); + var input = new DetailedCalculationInputFromProbability( + 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.DetailedAssessmentDirectFailureMechanisms(input); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + Assert.IsNull(kernel.DetailedAssessmentFailureMechanismFromProbabilityInput); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.FailureMechanismSectionAssemblyCategoryResult); + } + + [Test] public void DetailedAssessmentDirectFailureMechanismsWithBoundaries_Always_ThrowNotImplementedException() { // Setup @@ -254,19 +332,98 @@ } [Test] - public void DetailedAssessmentDirectFailureMechanismsWithLengthEffect_Always_ThrowNotImplementedException() + public void DetailedAssessmentDirectFailureMechanismsWithLengthEffect_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() { // Setup + var random = new Random(39); + var input = new DetailedCalculationInputFromProbabilityWithLengthEffect( + 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))) + }, + random.NextRoundedDouble(1.0, 40.0)); + var kernel = new FailureMechanismSectionAssemblyKernelStub(); + // Precondition + Assert.IsFalse(kernel.Calculated); + // Call - TestDelegate test = () => kernel.DetailedAssessmentDirectFailureMechanisms((DetailedCalculationInputFromProbabilityWithLengthEffect) null); + kernel.DetailedAssessmentDirectFailureMechanisms(input); // Assert - Assert.Throws(test); + Assert.AreSame(input, kernel.DetailedAssessmentFailureMechanismFromProbabilityWithLengthEffectInput); + Assert.IsTrue(kernel.Calculated); } [Test] + public void DetailedAssessmentDirectFailureMechanismsWithLengthEffect_ThrowExceptionOnCalculateFalse_ReturnFailureMechanismSectionAssemblyCategoryResult() + { + // Setup + var random = new Random(39); + var input = new DetailedCalculationInputFromProbabilityWithLengthEffect( + 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))) + }, + random.NextRoundedDouble(1.0, 40.0)); + + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + FailureMechanismSectionAssemblyCategoryResult = new CalculationOutput( + new FailureMechanismSectionAssemblyCategoryResult(FailureMechanismSectionCategoryGroup.IIIv, Probability.NaN)) + }; + + // Call + CalculationOutput result = kernel.DetailedAssessmentDirectFailureMechanisms(input); + + // Assert + Assert.AreSame(kernel.FailureMechanismSectionAssemblyCategoryResult, result); + } + + [Test] + public void DetailedAssessmentDirectFailureMechanismsWithLengthEffect_ThrowExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var random = new Random(39); + var input = new DetailedCalculationInputFromProbabilityWithLengthEffect( + 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))) + }, + random.NextRoundedDouble(1.0, 40.0)); + + var kernel = new FailureMechanismSectionAssemblyKernelStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.DetailedAssessmentDirectFailureMechanisms(input); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + Assert.IsNull(kernel.DetailedAssessmentFailureMechanismFromProbabilityWithLengthEffectInput); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.FailureMechanismSectionAssemblyCategoryResult); + } + + #endregion + + #region Tailor Made Assessment + + [Test] public void TailorMadeAssessmentDirectFailureMechanisms_Always_ThrowNotImplementedException() { // Setup @@ -331,6 +488,10 @@ Assert.Throws(test); } + #endregion + + #region Combined Assessment + [Test] public void CombinedAssessmentFromFailureMechanismSectionResults_Always_ThrowNotImplementedException() { @@ -356,5 +517,7 @@ // Assert Assert.Throws(test); } + + #endregion } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj =================================================================== diff -u -rd7696913d8f9239cb80eb2c3bac6cc0ccf23d479 -r55dfc8f739672258343f1c85bac8629498b5b21e --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision d7696913d8f9239cb80eb2c3bac6cc0ccf23d479) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision 55dfc8f739672258343f1c85bac8629498b5b21e) @@ -34,6 +34,10 @@ + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs =================================================================== diff -u -r39e13825618c9845e2100ae802a007c04c2e8517 -r55dfc8f739672258343f1c85bac8629498b5b21e --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs (.../FailureMechanismSectionAssemblyKernelStub.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/FailureMechanismSectionAssemblyKernelStub.cs (.../FailureMechanismSectionAssemblyKernelStub.cs) (revision 55dfc8f739672258343f1c85bac8629498b5b21e) @@ -44,6 +44,16 @@ public SimpleCalculationResultValidityOnly? SimpleAssessmentFailureMechanismsValidityOnlyInput { get; private set; } /// + /// Gets the input used in . + /// + public DetailedCalculationInputFromProbability DetailedAssessmentFailureMechanismFromProbabilityInput { get; private set; } + + /// + /// Gets the input used in . + /// + public DetailedCalculationInputFromProbability DetailedAssessmentFailureMechanismFromProbabilityWithLengthEffectInput { get; private set; } + + /// /// Gets a value indicating whether a calculation was called or not. /// public bool Calculated { get; private set; } @@ -99,7 +109,15 @@ public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationInputFromProbability input) { - throw new NotImplementedException(); + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + DetailedAssessmentFailureMechanismFromProbabilityInput = input; + Calculated = true; + return FailureMechanismSectionAssemblyCategoryResult; + } public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCategoryBoundariesCalculationResult calculationResults) @@ -109,7 +127,14 @@ public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationInputFromProbabilityWithLengthEffect input) { - throw new NotImplementedException(); + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + DetailedAssessmentFailureMechanismFromProbabilityWithLengthEffectInput = input; + Calculated = true; + return FailureMechanismSectionAssemblyCategoryResult; } public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationResult result)