Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/AssessmentSectionAssemblyCalculator.cs =================================================================== diff -u -r57210ddafec2d829c866490aa0bd6cebfc2e3a62 -r93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/AssessmentSectionAssemblyCalculator.cs (.../AssessmentSectionAssemblyCalculator.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Calculators/Assembly/AssessmentSectionAssemblyCalculator.cs (.../AssessmentSectionAssemblyCalculator.cs) (revision 93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; using Ringtoets.AssemblyTool.Data; @@ -66,6 +67,10 @@ return AssessmentSectionAssemblyCreator.CreateAssessmentSectionAssembly(output); } + catch (AssemblyException e) + { + throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageTranslator.CreateErrorMessage(e.Errors), e); + } catch (Exception e) { throw new AssessmentSectionAssemblyCalculatorException(e.Message, e); @@ -83,6 +88,10 @@ return AssemblyCategoryCreator.CreateAssessmentSectionAssemblyCategory(output); } + catch (AssemblyException e) + { + throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageTranslator.CreateErrorMessage(e.Errors), e); + } catch (Exception e) { throw new AssessmentSectionAssemblyCalculatorException(e.Message, e); @@ -101,6 +110,10 @@ return AssessmentSectionAssemblyCreator.CreateAssessmentSectionAssembly(output).Group; } + catch (AssemblyException e) + { + throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageTranslator.CreateErrorMessage(e.Errors), e); + } catch (Exception e) { throw new AssessmentSectionAssemblyCalculatorException(e.Message, e); @@ -117,6 +130,10 @@ return CombinedFailureMechanismSectionAssemblyCreator.Create(output); } + catch (AssemblyException e) + { + throw new AssessmentSectionAssemblyCalculatorException(AssemblyErrorMessageTranslator.CreateErrorMessage(e.Errors), e); + } catch (Exception e) { throw new AssessmentSectionAssemblyCalculatorException(e.Message, e); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs =================================================================== diff -u -r57210ddafec2d829c866490aa0bd6cebfc2e3a62 -r93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs (.../AssessmentSectionAssemblyCalculatorTest.cs) (revision 57210ddafec2d829c866490aa0bd6cebfc2e3a62) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs (.../AssessmentSectionAssemblyCalculatorTest.cs) (revision 93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1) @@ -22,12 +22,14 @@ using System; using System.ComponentModel; using System.Linq; +using Assembly.Kernel.Exceptions; using Assembly.Kernel.Model; using Assembly.Kernel.Model.FmSectionTypes; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.KernelWrapper.Calculators; using Ringtoets.AssemblyTool.KernelWrapper.Calculators.Assembly; using Ringtoets.AssemblyTool.KernelWrapper.Creators; using Ringtoets.AssemblyTool.KernelWrapper.Kernels; @@ -205,7 +207,7 @@ { var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; AssessmentSectionAssemblyKernelStub kernel = factory.LastCreatedAssessmentSectionAssemblyKernel; - kernel.ThrowException = true; + kernel.ThrowExceptionOnCalculate = true; var calculator = new AssessmentSectionAssemblyCalculator(factory); @@ -223,6 +225,37 @@ } [Test] + public void AssembleFailureMechanismsWithProbability_KernelThrowsAssemblyException_ThrowsAssessmentSectionAssemblyCalculatorException() + { + // Setup + var random = new Random(21); + double signalingNorm = random.NextDouble(0, 0.5); + double lowerLimitNorm = random.NextDouble(0.5, 1); + + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + AssessmentSectionAssemblyKernelStub kernel = factory.LastCreatedAssessmentSectionAssemblyKernel; + kernel.ThrowAssemblyExceptionOnCalculate = true; + + var calculator = new AssessmentSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleFailureMechanisms(Enumerable.Empty(), + signalingNorm, + lowerLimitNorm); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.Message, AssemblyErrorMessageTranslator.CreateErrorMessage(new[] + { + new AssemblyErrorMessage(string.Empty, EAssemblyErrors.CategoryLowerLimitOutOfRange) + })); + } + } + + [Test] public void AssembleFailureMechanismsWithoutProbability_WithInvalidEnumInput_ThrowAssessmentSectionAssemblyCalculatorException() { // Setup @@ -329,7 +362,7 @@ { var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; AssessmentSectionAssemblyKernelStub kernel = factory.LastCreatedAssessmentSectionAssemblyKernel; - kernel.ThrowException = true; + kernel.ThrowExceptionOnCalculate = true; var calculator = new AssessmentSectionAssemblyCalculator(factory); @@ -345,6 +378,31 @@ } [Test] + public void AssembleFailureMechanismsWithoutProbability_KernelThrowsAssemblyException_ThrowsAssessmentSectionAssemblyCalculatorException() + { + // Setup + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + AssessmentSectionAssemblyKernelStub kernel = factory.LastCreatedAssessmentSectionAssemblyKernel; + kernel.ThrowAssemblyExceptionOnCalculate = true; + + var calculator = new AssessmentSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleFailureMechanisms(Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.Message, AssemblyErrorMessageTranslator.CreateErrorMessage(new[] + { + new AssemblyErrorMessage(string.Empty, EAssemblyErrors.CategoryLowerLimitOutOfRange) + })); + } + } + + [Test] [TestCase(AssessmentSectionAssemblyCategoryGroup.None, (AssessmentSectionAssemblyCategoryGroup) 99, TestName = "Invalid Input Failure Mechanisms With Probability")] [TestCase((AssessmentSectionAssemblyCategoryGroup) 99, AssessmentSectionAssemblyCategoryGroup.None, TestName = "Invalid Input Failure Mechanisms Without Probability")] public void AssembleAssessmentSection_WithInvalidInput_ThrowsAssessmentSectionAssemblyCalculatorException( @@ -478,7 +536,7 @@ { var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; AssessmentSectionAssemblyKernelStub kernel = factory.LastCreatedAssessmentSectionAssemblyKernel; - kernel.ThrowException = true; + kernel.ThrowExceptionOnCalculate = true; var calculator = new AssessmentSectionAssemblyCalculator(factory); @@ -495,6 +553,37 @@ } [Test] + public void AssembleAssessmentSection_KernelThrowsAssemblyException_ThrowsAssessmentSectionAssemblyCalculatorException() + { + // Setup + var random = new Random(21); + var failureMechanismsWithProbability = new AssessmentSectionAssembly(random.NextDouble(), + random.NextEnumValue()); + var failureMechanismsWithoutProbability = random.NextEnumValue(); + + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + AssessmentSectionAssemblyKernelStub kernel = factory.LastCreatedAssessmentSectionAssemblyKernel; + kernel.ThrowAssemblyExceptionOnCalculate = true; + + var calculator = new AssessmentSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleAssessmentSection(failureMechanismsWithoutProbability, + failureMechanismsWithProbability); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.Message, AssemblyErrorMessageTranslator.CreateErrorMessage(new[] + { + new AssemblyErrorMessage(string.Empty, EAssemblyErrors.CategoryLowerLimitOutOfRange) + })); + } + } + + [Test] public void AssembleCombinedFailureMechanismSections_WithInvalidInput_ThrowsAssessmentSectionAssemblyCalculatorException() { // Setup @@ -649,7 +738,7 @@ { var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; CombinedFailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedCombinedFailureMechanismSectionAssemblyKernel; - kernel.ThrowException = true; + kernel.ThrowExceptionOnCalculate = true; var calculator = new AssessmentSectionAssemblyCalculator(factory); @@ -670,6 +759,39 @@ } } + [Test] + public void AssembleCombinedFailureMechanismSections_KernelThrowsAssemblyException_ThrowsAssessmentSectionAssemblyCalculatorException() + { + // Setup + var random = new Random(21); + + using (new AssemblyToolKernelFactoryConfig()) + { + var factory = (TestAssemblyToolKernelFactory) AssemblyToolKernelFactory.Instance; + CombinedFailureMechanismSectionAssemblyKernelStub kernel = factory.LastCreatedCombinedFailureMechanismSectionAssemblyKernel; + kernel.ThrowAssemblyExceptionOnCalculate = true; + + var calculator = new AssessmentSectionAssemblyCalculator(factory); + + // Call + TestDelegate test = () => calculator.AssembleCombinedFailureMechanismSections(new[] + { + new[] + { + new CombinedAssemblyFailureMechanismSection(0, 1, random.NextEnumValue()) + } + }, random.NextDouble()).ToArray(); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.Message, AssemblyErrorMessageTranslator.CreateErrorMessage(new[] + { + new AssemblyErrorMessage(string.Empty, EAssemblyErrors.CategoryLowerLimitOutOfRange) + })); + } + } + private static EFailureMechanismCategory GetGroup(FailureMechanismAssemblyCategoryGroup originalGroup) { switch (originalGroup) Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/AssessmentSectionAssemblyKernelStubTest.cs =================================================================== diff -u -raff42da8fcf168a408902881180d6ceedbc58b08 -r93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/AssessmentSectionAssemblyKernelStubTest.cs (.../AssessmentSectionAssemblyKernelStubTest.cs) (revision aff42da8fcf168a408902881180d6ceedbc58b08) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/AssessmentSectionAssemblyKernelStubTest.cs (.../AssessmentSectionAssemblyKernelStubTest.cs) (revision 93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; using Core.Common.TestUtil; @@ -50,7 +51,7 @@ } [Test] - public void AssembleAssessmentSectionWbi2A1_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() + public void AssembleAssessmentSectionWbi2A1_ThrowExceptionsFalse_InputCorrectlySetToKernelAndCalculatedTrue() { // Setup var random = new Random(21); @@ -72,7 +73,7 @@ } [Test] - public void AssembleAssessmentSectionWbi2A1_ThrowExceptionOnCalculateFalse_ReturnAssessmentGrade() + public void AssembleAssessmentSectionWbi2A1_ThrowExceptionsFalse_ReturnAssessmentGrade() { // Setup var random = new Random(21); @@ -96,7 +97,7 @@ var random = new Random(21); var kernel = new AssessmentSectionAssemblyKernelStub { - ThrowException = true + ThrowExceptionOnCalculate = true }; // Call @@ -113,10 +114,35 @@ } [Test] - public void AssembleAssessmentSectionWbi2B1_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() + public void AssembleAssessmentSectionWbi2A1_ThrowAssemblyExceptionOnCalculateTrue_ThrowsException() { // Setup var random = new Random(21); + var kernel = new AssessmentSectionAssemblyKernelStub + { + ThrowAssemblyExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.AssembleAssessmentSectionWbi2A1(Enumerable.Empty(), + random.NextBoolean()); + + // Assert + var exception = Assert.Throws(test); + AssemblyErrorMessage errorMessage = exception.Errors.Single(); + Assert.AreEqual("entity", errorMessage.EntityId); + Assert.AreEqual(EAssemblyErrors.CategoryLowerLimitOutOfRange, errorMessage.ErrorCode); + + Assert.IsNull(kernel.FailureMechanismAssemblyResults); + Assert.IsNull(kernel.PartialAssembly); + Assert.IsFalse(kernel.Calculated); + } + + [Test] + public void AssembleAssessmentSectionWbi2B1_ThrowExceptionsFalse_InputCorrectlySetToKernelAndCalculatedTrue() + { + // Setup + var random = new Random(21); bool partialAssembly = random.NextBoolean(); AssessmentSection assessmentSection = CreateAssessmentSection(); IEnumerable assemblyResults = Enumerable.Empty(); @@ -137,7 +163,7 @@ } [Test] - public void AssembleAssessmentSectionWbi2B1_ThrowExceptionOnCalculateFalse_ReturnAssessmentGrade() + public void AssembleAssessmentSectionWbi2B1_ThrowExceptionsFalse_ReturnAssessmentGrade() { // Setup var random = new Random(21); @@ -162,7 +188,7 @@ var random = new Random(21); var kernel = new AssessmentSectionAssemblyKernelStub { - ThrowException = true + ThrowExceptionOnCalculate = true }; // Call @@ -180,9 +206,34 @@ } [Test] - public void AssembleAssessmentSectionWbi2C1_ThrowExceptionOnCalculateFalse_InputCorrectlySetToKernelAndCalculatedTrue() + public void AssembleAssessmentSectionWbi2B1_ThrowAssemblyExceptionOnCalculateTrue_ThrowsException() { // Setup + var random = new Random(21); + var kernel = new AssessmentSectionAssemblyKernelStub + { + ThrowAssemblyExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.AssembleAssessmentSectionWbi2B1(CreateAssessmentSection(), + Enumerable.Empty(), + random.NextBoolean()); + + // Assert + var exception = Assert.Throws(test); + AssemblyErrorMessage errorMessage = exception.Errors.Single(); + Assert.AreEqual("entity", errorMessage.EntityId); + Assert.AreEqual(EAssemblyErrors.CategoryLowerLimitOutOfRange, errorMessage.ErrorCode); + Assert.IsNull(kernel.FailureMechanismAssemblyResults); + Assert.IsNull(kernel.PartialAssembly); + Assert.IsFalse(kernel.Calculated); + } + + [Test] + public void AssembleAssessmentSectionWbi2C1_ThrowExceptionsFalse_InputCorrectlySetToKernelAndCalculatedTrue() + { + // Setup AssessmentSectionAssemblyResult assemblyResultNoFailureProbability = CreateAssemblyResult(); AssessmentSectionAssemblyResult assemblyResultWithFailureProbability = CreateAssemblyResult(); @@ -202,7 +253,7 @@ } [Test] - public void AssembleAssessmentSectionWbi2C1_ThrowExceptionOnCalculateFalse_ReturnAssessmentGrade() + public void AssembleAssessmentSectionWbi2C1_ThrowExceptionsFalse_ReturnAssessmentGrade() { // Setup var kernel = new AssessmentSectionAssemblyKernelStub @@ -224,7 +275,7 @@ // Setup var kernel = new AssessmentSectionAssemblyKernelStub { - ThrowException = true + ThrowExceptionOnCalculate = true }; // Call @@ -240,6 +291,29 @@ Assert.IsFalse(kernel.Calculated); } + [Test] + public void AssembleAssessmentSectionWbi2C1_ThrowAssemblyExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var kernel = new AssessmentSectionAssemblyKernelStub + { + ThrowAssemblyExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.AssembleAssessmentSectionWbi2C1(CreateAssemblyResult(), + CreateAssemblyResult()); + + // Assert + var exception = Assert.Throws(test); + AssemblyErrorMessage errorMessage = exception.Errors.Single(); + Assert.AreEqual("entity", errorMessage.EntityId); + Assert.AreEqual(EAssemblyErrors.CategoryLowerLimitOutOfRange, errorMessage.ErrorCode); + Assert.IsNull(kernel.AssemblyResultNoFailureProbability); + Assert.IsNull(kernel.AssemblyResultWithFailureProbability); + Assert.IsFalse(kernel.Calculated); + } + private static AssessmentSectionAssemblyResult CreateAssemblyResult() { var random = new Random(21); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStubTest.cs =================================================================== diff -u -r70196989bbf45e88c19faa7300c59f0b43714beb -r93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStubTest.cs (.../CombinedFailureMechanismSectionAssemblyKernelStubTest.cs) (revision 70196989bbf45e88c19faa7300c59f0b43714beb) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStubTest.cs (.../CombinedFailureMechanismSectionAssemblyKernelStubTest.cs) (revision 93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1) @@ -22,6 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; using Core.Common.TestUtil; @@ -94,7 +95,7 @@ var random = new Random(21); var kernel = new CombinedFailureMechanismSectionAssemblyKernelStub { - ThrowException = true + ThrowExceptionOnCalculate = true }; // Call @@ -111,5 +112,31 @@ Assert.IsNull(kernel.AssemblyResult); Assert.IsFalse(kernel.Calculated); } + + [Test] + public void AssembleCommonFailureMechanismSections_ThrowAssemblyExceptionOnCalculateTrue_ThrowsException() + { + // Setup + var random = new Random(21); + var kernel = new CombinedFailureMechanismSectionAssemblyKernelStub + { + ThrowAssemblyExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => kernel.AssembleCommonFailureMechanismSections(Enumerable.Empty(), + random.NextDouble(), random.NextBoolean()); + + // Assert + var exception = Assert.Throws(test); + AssemblyErrorMessage errorMessage = exception.Errors.Single(); + Assert.AreEqual("entity", errorMessage.EntityId); + Assert.AreEqual(EAssemblyErrors.CategoryLowerLimitOutOfRange, errorMessage.ErrorCode); + Assert.IsNull(kernel.AssessmentSectionLengthInput); + Assert.IsNull(kernel.FailureMechanismSectionListsInput); + Assert.IsNull(kernel.PartialAssembly); + Assert.IsNull(kernel.AssemblyResult); + Assert.IsFalse(kernel.Calculated); + } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/AssessmentSectionAssemblyKernelStub.cs =================================================================== diff -u -r28bcc5f05ac19148d432c3051a88758c60c9dc0c -r93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/AssessmentSectionAssemblyKernelStub.cs (.../AssessmentSectionAssemblyKernelStub.cs) (revision 28bcc5f05ac19148d432c3051a88758c60c9dc0c) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/AssessmentSectionAssemblyKernelStub.cs (.../AssessmentSectionAssemblyKernelStub.cs) (revision 93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; @@ -72,17 +73,19 @@ public bool Calculated { get; private set; } /// - /// Sets an indicator whether an exception must be thrown while performing a calculation. + /// Sets an indicator whether an must be thrown while performing a calculation. /// - public bool ThrowException { private get; set; } + public bool ThrowExceptionOnCalculate { private get; set; } + /// + /// Sets an indicator whether an must be thrown while performing a calculation. + /// + public bool ThrowAssemblyExceptionOnCalculate { private get; set; } + public EAssessmentGrade AssembleAssessmentSectionWbi2A1(IEnumerable failureMechanismAssemblyResults, bool partialAssembly) { - if (ThrowException) - { - throw new Exception("Message", new Exception()); - } + ThrowExceptions(); PartialAssembly = partialAssembly; FailureMechanismAssemblyResults = failureMechanismAssemblyResults; @@ -96,10 +99,7 @@ IEnumerable failureMechanismAssemblyResults, bool partialAssembly) { - if (ThrowException) - { - throw new Exception("Message", new Exception()); - } + ThrowExceptions(); PartialAssembly = partialAssembly; AssessmentSectionInput = section; @@ -113,10 +113,7 @@ public AssessmentSectionAssemblyResult AssembleAssessmentSectionWbi2C1(AssessmentSectionAssemblyResult assemblyResultNoFailureProbability, AssessmentSectionAssemblyResult assemblyResultWithFailureProbability) { - if (ThrowException) - { - throw new Exception("Message", new Exception()); - } + ThrowExceptions(); AssemblyResultNoFailureProbability = assemblyResultNoFailureProbability; AssemblyResultWithFailureProbability = assemblyResultWithFailureProbability; @@ -125,5 +122,18 @@ return AssessmentSectionAssemblyResult; } + + private void ThrowExceptions() + { + if (ThrowExceptionOnCalculate) + { + throw new Exception("Message", new Exception()); + } + + if (ThrowAssemblyExceptionOnCalculate) + { + throw new AssemblyException("entity", EAssemblyErrors.CategoryLowerLimitOutOfRange); + } + } } } \ No newline at end of file Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStub.cs =================================================================== diff -u -r28bcc5f05ac19148d432c3051a88758c60c9dc0c -r93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStub.cs (.../CombinedFailureMechanismSectionAssemblyKernelStub.cs) (revision 28bcc5f05ac19148d432c3051a88758c60c9dc0c) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Kernels/Assembly/CombinedFailureMechanismSectionAssemblyKernelStub.cs (.../CombinedFailureMechanismSectionAssemblyKernelStub.cs) (revision 93b73bcc0968d0bbd1a63d6fc1cfabf85fdf48e1) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using Assembly.Kernel.Exceptions; using Assembly.Kernel.Interfaces; using Assembly.Kernel.Model; @@ -32,11 +33,16 @@ public class CombinedFailureMechanismSectionAssemblyKernelStub : ICommonFailureMechanismSectionAssembler { /// - /// Sets an indicator whether an exception must be thrown while performing a calculation. + /// Sets an indicator whether an must be thrown while performing a calculation. /// - public bool ThrowException { private get; set; } + public bool ThrowExceptionOnCalculate { private get; set; } /// + /// Sets an indicator whether an must be thrown while performing a calculation. + /// + public bool ThrowAssemblyExceptionOnCalculate { private get; set; } + + /// /// Gets a value indicating whether a calculation was called or not. /// public bool Calculated { get; private set; } @@ -64,11 +70,16 @@ public AssemblyResult AssembleCommonFailureMechanismSections(IEnumerable failureMechanismSectionLists, double assessmentSectionLength, bool partialAssembly) { - if (ThrowException) + if (ThrowExceptionOnCalculate) { throw new Exception("Message", new Exception()); } + if (ThrowAssemblyExceptionOnCalculate) + { + throw new AssemblyException("entity", EAssemblyErrors.CategoryLowerLimitOutOfRange); + } + FailureMechanismSectionListsInput = failureMechanismSectionLists; AssessmentSectionLengthInput = assessmentSectionLength; PartialAssembly = partialAssembly;