Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStubTest.cs =================================================================== diff -u -rc0389fd4c1b36538e525337a16b67f30ae866f7b -rfc7fbe9882364e7caae2093c378d3cacd8858d00 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStubTest.cs (.../FailureMechanismSectionAssessmentAssemblyKernelStubTest.cs) (revision c0389fd4c1b36538e525337a16b67f30ae866f7b) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStubTest.cs (.../FailureMechanismSectionAssessmentAssemblyKernelStubTest.cs) (revision fc7fbe9882364e7caae2093c378d3cacd8858d00) @@ -20,8 +20,13 @@ // 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; @@ -31,16 +36,85 @@ public class FailureMechanismSectionAssessmentAssemblyKernelStubTest { [Test] - public void SimpleAssessmentDirectFailureMechanisms_Always_ThrowNotImplementedException() + public void Constructor_ExpectedValues() { + // Call + var kernel = new FailureMechanismSectionAssessmentAssemblyKernelStub(); + + // Assert + Assert.IsInstanceOf(kernel); + Assert.IsFalse(kernel.Calculated); + Assert.IsNull(kernel.SimpleAssessmentFailureMechanismsInput); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernel() + { // Setup + var random = new Random(39); + var input = random.NextEnumValue(); + var kernel = new FailureMechanismSectionAssessmentAssemblyKernelStub(); // Call + kernel.SimpleAssessmentDirectFailureMechanisms(input); + + // Assert + Assert.AreEqual(input, kernel.SimpleAssessmentFailureMechanismsInput); + } + + [Test] + public void SimpleAssessmentDirectFailureMechanisms_ThrowExceptionOnCalculateFalse_SetCalculatedTrue() + { + // Setup + var kernel = new FailureMechanismSectionAssessmentAssemblyKernelStub(); + + // 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 FailureMechanismSectionAssessmentAssemblyKernelStub + { + 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 FailureMechanismSectionAssessmentAssemblyKernelStub + { + ThrowExceptionOnCalculate = true + }; + + // Call TestDelegate test = () => kernel.SimpleAssessmentDirectFailureMechanisms((SimpleCalculationResult) 0); // Assert - Assert.Throws(test); + 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] Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj =================================================================== diff -u -rc0389fd4c1b36538e525337a16b67f30ae866f7b -rfc7fbe9882364e7caae2093c378d3cacd8858d00 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision c0389fd4c1b36538e525337a16b67f30ae866f7b) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj (.../Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test.csproj) (revision fc7fbe9882364e7caae2093c378d3cacd8858d00) @@ -34,6 +34,10 @@ + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStub.cs =================================================================== diff -u -rc0389fd4c1b36538e525337a16b67f30ae866f7b -rfc7fbe9882364e7caae2093c378d3cacd8858d00 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStub.cs (.../FailureMechanismSectionAssessmentAssemblyKernelStub.cs) (revision c0389fd4c1b36538e525337a16b67f30ae866f7b) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assessments/FailureMechanismSectionAssessmentAssemblyKernelStub.cs (.../FailureMechanismSectionAssessmentAssemblyKernelStub.cs) (revision fc7fbe9882364e7caae2093c378d3cacd8858d00) @@ -19,6 +19,7 @@ // 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; @@ -32,79 +33,106 @@ /// public class FailureMechanismSectionAssessmentAssemblyKernelStub : IFailureMechanismSectionAssemblyCalculator { + /// + /// Gets the input used in . + /// + public SimpleCalculationResult? SimpleAssessmentFailureMechanismsInput { 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) { - throw new System.NotImplementedException(); + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + SimpleAssessmentFailureMechanismsInput = result; + Calculated = true; + return FailureMechanismSectionAssemblyCategoryResult; } public CalculationOutput SimpleAssessmentIndirectFailureMechanisms(SimpleCalculationResult result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput SimpleAssessmentDirectFailureMechanisms(SimpleCalculationResultValidityOnly result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationResult result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput DetailedAssessmentIndirectFailureMechanisms(DetailedCalculationResult result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationInputFromProbability input) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCategoryBoundariesCalculationResult calculationResults) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput DetailedAssessmentDirectFailureMechanisms(DetailedCalculationInputFromProbabilityWithLengthEffect input) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationResult result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput TailorMadeAssessmentIndirectFailureMechanisms(TailorMadeCalculationResult result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationInputFromProbability input) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCategoryCalculationResult result) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput TailorMadeAssessmentDirectFailureMechanisms(TailorMadeCalculationInputFromProbabilityWithLengthEffectFactor input) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput CombinedAssessmentFromFailureMechanismSectionResults(FailureMechanismSectionCategoryGroup resultSimpleAssessment, FailureMechanismSectionCategoryGroup resultDetailedAssessment, FailureMechanismSectionCategoryGroup resultTailorMadeAssessment) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } public CalculationOutput CombinedAssessmentFromFailureMechanismSectionResults(FailureMechanismSectionAssemblyCategoryResult resultSimpleAssessment, FailureMechanismSectionAssemblyCategoryResult resultDetailedAssessment, FailureMechanismSectionAssemblyCategoryResult resultTailorMadeAssessment) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } } -} +} \ No newline at end of file