Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStubTest.cs =================================================================== diff -u -r8ffedce6423c90651a76ae74c34c75a298c10194 -r017a33e4110f1a0f76a875fa1266284d122ce30f --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStubTest.cs (.../AssessmentSectionAssemblyCalculatorStubTest.cs) (revision 8ffedce6423c90651a76ae74c34c75a298c10194) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStubTest.cs (.../AssessmentSectionAssemblyCalculatorStubTest.cs) (revision 017a33e4110f1a0f76a875fa1266284d122ce30f) @@ -44,6 +44,9 @@ Assert.IsNull(calculator.FailureMechanismAssemblyInput); Assert.IsNull(calculator.FailureMechanismAssemblyCategoryGroupInput); Assert.IsNull(calculator.AssemblyCategoriesInput); + Assert.IsNull(calculator.FailureMechanismsWithProbabilityInput); + Assert.AreEqual((AssessmentSectionAssemblyCategoryGroup) 0, + calculator.FailureMechanismsWithoutProbabilityInput); } [Test] @@ -151,7 +154,6 @@ { // Setup IEnumerable failureMechanisms = Enumerable.Empty(); - var calculator = new AssessmentSectionAssemblyCalculatorStub(); // Call @@ -179,6 +181,83 @@ Assert.IsNotNull(exception.InnerException); } + [Test] + public void AssembleAssessmentSection_ThrowExceptionOnCalculateFalseAndOutputNotSet_ReturnOutput() + { + // Setup + var random = new Random(21); + var calculator = new AssessmentSectionAssemblyCalculatorStub(); + + // Call + AssessmentSectionAssemblyCategoryGroup output = + calculator.AssembleAssessmentSection(random.NextEnumValue(), + new AssessmentSectionAssembly(random.NextDouble(), + random.NextEnumValue())); + + // Assert + Assert.AreEqual(AssessmentSectionAssemblyCategoryGroup.C, output); + } + + [Test] + public void AssembleAssessmentSection_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput() + { + // Setup + var random = new Random(21); + var calculator = new AssessmentSectionAssemblyCalculatorStub + { + AssessmentSectionAssemblyCategoryGroupOutput = random.NextEnumValue() + }; + + // Call + AssessmentSectionAssemblyCategoryGroup output = + calculator.AssembleAssessmentSection(random.NextEnumValue(), + new AssessmentSectionAssembly(random.NextDouble(), + random.NextEnumValue())); + + // Assert + Assert.AreEqual(calculator.AssessmentSectionAssemblyCategoryGroupOutput, output); + } + + [Test] + public void AssembleAssessmentSection_ThrowExceptionOnCalculateFalse_SetsInput() + { + // Setup + var random = new Random(21); + var failureMechanismsWithoutProbability = random.NextEnumValue(); + var failureMechanismsWithProbability = new AssessmentSectionAssembly(random.NextDouble(), + random.NextEnumValue()); + var calculator = new AssessmentSectionAssemblyCalculatorStub(); + + // Call + calculator.AssembleAssessmentSection(failureMechanismsWithoutProbability, failureMechanismsWithProbability); + + // Assert + Assert.AreEqual(failureMechanismsWithoutProbability, calculator.FailureMechanismsWithoutProbabilityInput); + Assert.AreSame(failureMechanismsWithProbability, calculator.FailureMechanismsWithProbabilityInput); + } + + [Test] + public void AssembleAssessmentSection_ThrowExceptionOnCalculateTrue_ThrowsAssessmentSectionAssemblyCalculatorException() + { + // Setup + var random = new Random(21); + var calculator = new AssessmentSectionAssemblyCalculatorStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate call = () => + calculator.AssembleAssessmentSection(random.NextEnumValue(), + new AssessmentSectionAssembly(random.NextDouble(), + random.NextEnumValue())); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("Message", exception.Message); + Assert.IsNotNull(exception.InnerException); + } + private static AssemblyCategoriesInput CreateAssemblyCategoriesInput() { var random = new Random(21); Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStub.cs =================================================================== diff -u -r8ffedce6423c90651a76ae74c34c75a298c10194 -r017a33e4110f1a0f76a875fa1266284d122ce30f --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStub.cs (.../AssessmentSectionAssemblyCalculatorStub.cs) (revision 8ffedce6423c90651a76ae74c34c75a298c10194) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/AssessmentSectionAssemblyCalculatorStub.cs (.../AssessmentSectionAssemblyCalculatorStub.cs) (revision 017a33e4110f1a0f76a875fa1266284d122ce30f) @@ -44,20 +44,30 @@ public IEnumerable FailureMechanismAssemblyInput { get; private set; } /// - /// Gets the collection of failure mechanism assembly input when assembling the - /// assessment section with failure mechanisms without probability + /// Gets the collection of failure mechanism assembly category group input when assembling the + /// assessment section with failure mechanisms without probability. /// public IEnumerable FailureMechanismAssemblyCategoryGroupInput { get; private set; } /// + /// Gets the failure mechanisms without probability input when assembling the assessment section. + /// + public AssessmentSectionAssemblyCategoryGroup FailureMechanismsWithoutProbabilityInput { get; private set; } + + /// + /// Gets the failure mechanisms with probability input when assembling the assessment section. + /// + public AssessmentSectionAssembly FailureMechanismsWithProbabilityInput { get; private set; } + + /// /// Gets or sets the output of the assessment section assembly for failure /// mechanisms with probability. /// public AssessmentSectionAssembly AssessmentSectionAssemblyOutput { get; set; } /// - /// Gets or sets the output of the assessment section assembly for failure - /// mechanisms without probability. + /// Gets or sets the output of the assessment section assembly category group for failure + /// mechanisms without probability or for assembling the assessment section. /// public AssessmentSectionAssemblyCategoryGroup? AssessmentSectionAssemblyCategoryGroupOutput { get; set; } @@ -96,7 +106,15 @@ public AssessmentSectionAssemblyCategoryGroup AssembleAssessmentSection(AssessmentSectionAssemblyCategoryGroup failureMechanismsWithoutProbability, AssessmentSectionAssembly failureMechanismsWithProbability) { - throw new NotImplementedException(); + if (ThrowExceptionOnCalculate) + { + throw new AssessmentSectionAssemblyCalculatorException("Message", new Exception()); + } + + FailureMechanismsWithoutProbabilityInput = failureMechanismsWithoutProbability; + FailureMechanismsWithProbabilityInput = failureMechanismsWithProbability; + + return AssessmentSectionAssemblyCategoryGroupOutput ?? AssessmentSectionAssemblyCategoryGroup.C; } } } \ No newline at end of file