Index: Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCategoryCreator.cs =================================================================== diff -u -r7b5c9aa3a65821c1b219ba3ef2c99830c1e25d8a -r6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3 --- Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCategoryCreator.cs (.../AssemblyCategoryCreator.cs) (revision 7b5c9aa3a65821c1b219ba3ef2c99830c1e25d8a) +++ Ringtoets/AssemblyTool/src/Ringtoets.AssemblyTool.KernelWrapper/Creators/AssemblyCategoryCreator.cs (.../AssemblyCategoryCreator.cs) (revision 6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3) @@ -42,6 +42,7 @@ /// An /// with information taken from the . /// Thrown when is null. + /// Thrown when contains null items. /// Thrown when /// is an invalid value. /// Thrown when @@ -54,6 +55,11 @@ throw new ArgumentNullException(nameof(output)); } + if (output.Result.Contains(null)) + { + throw new ArgumentException(@"Output result cannot contain null items", nameof(output)); + } + return output.Result.Select( categoriesOutput => new AssessmentSectionAssemblyCategory(categoriesOutput.LowerBoundary, categoriesOutput.UpperBoundary, Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Categories/AssemblyCategoriesCalculatorTest.cs =================================================================== diff -u -r0c8ff298db78d2860268b9d951ed8e4a1b7d78d0 -r6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Categories/AssemblyCategoriesCalculatorTest.cs (.../AssemblyCategoriesCalculatorTest.cs) (revision 0c8ff298db78d2860268b9d951ed8e4a1b7d78d0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Calculators/Categories/AssemblyCategoriesCalculatorTest.cs (.../AssemblyCategoriesCalculatorTest.cs) (revision 6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3) @@ -234,10 +234,10 @@ return new CalculationOutput(new[] { - new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), - new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), - new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), - new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))) + new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))), + new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))), + new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))), + new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))) }); } @@ -247,10 +247,10 @@ return new CalculationOutput(new[] { - new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), - new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), - new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), - new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))) + new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))), + new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))), + new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))), + new FailureMechanismSectionCategory(random.NextEnumValue(), new Probability(random.GetFromRange(0, 0.5)), new Probability(random.GetFromRange(0.5, 1))) }); } } Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCategoryCreatorTest.cs =================================================================== diff -u -r0c8ff298db78d2860268b9d951ed8e4a1b7d78d0 -r6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCategoryCreatorTest.cs (.../AssemblyCategoryCreatorTest.cs) (revision 0c8ff298db78d2860268b9d951ed8e4a1b7d78d0) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCategoryCreatorTest.cs (.../AssemblyCategoryCreatorTest.cs) (revision 6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3) @@ -49,6 +49,27 @@ } [Test] + public void CreateAssessmentSectionAssemblyCategories_OutputContainsNull_ThrowsArgumentException() + { + // Setup + var random = new Random(11); + var output = new CalculationOutput(new[] + { + new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))), + null, + new AssessmentSectionCategory(random.NextEnumValue(), new Probability(random.Next(1)), new Probability(random.Next(1, 2))) + }); + + // Call + TestDelegate call = () => AssemblyCategoryCreator.CreateAssessmentSectionAssemblyCategories(output); + + // Assert + const string expectedMessage = "Output result cannot contain null items"; + var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call,expectedMessage); + Assert.AreEqual("output", exception.ParamName); + } + + [Test] public void CreateAssessmentSectionAssemblyCategories_WithOutput_ReturnAssessmentSectionAssemblyCategoryResult() { // Setup Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs =================================================================== diff -u -r39e13825618c9845e2100ae802a007c04c2e8517 -r6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs (.../FailureMechanismSectionAssemblyCalculatorStubTest.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStubTest.cs (.../FailureMechanismSectionAssemblyCalculatorStubTest.cs) (revision 6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3) @@ -38,6 +38,10 @@ // Assert Assert.IsInstanceOf(calculator); + Assert.AreEqual((SimpleAssessmentResultType) 0, + calculator.SimpleAssessmentInput); + Assert.AreEqual((SimpleAssessmentResultValidityOnlyType) 0, + calculator.SimpleAssessmentValidityOnlyInput); Assert.IsNull(calculator.SimpleAssessmentAssemblyOutput); } @@ -56,22 +60,6 @@ } [Test] - public void AssembleSimpleAssessment_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput() - { - // Setup - var calculator = new FailureMechanismSectionAssemblyCalculatorStub - { - SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0.4, FailureMechanismSectionAssemblyCategoryGroup.None) - }; - - // Call - FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultType.None); - - // Assert - Assert.AreSame(calculator.SimpleAssessmentAssemblyOutput, assembly); - } - - [Test] public void AssembleSimpleAssessment_ThrowExceptionOnCalculateFalse_SetsInput() { // Setup @@ -118,22 +106,6 @@ } [Test] - public void AssembleSimpleAssessmentValidityOnly_ThrowExceptionOnCalculateFalseAndOutputSet_ReturnOutput() - { - // Setup - var calculator = new FailureMechanismSectionAssemblyCalculatorStub - { - SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0.4, FailureMechanismSectionAssemblyCategoryGroup.None) - }; - - // Call - FailureMechanismSectionAssembly assembly = calculator.AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType.None); - - // Assert - Assert.AreSame(calculator.SimpleAssessmentAssemblyOutput, assembly); - } - - [Test] public void AssembleSimpleAssessmentValidityOnly_ThrowExceptionOnCalculateFalse_SetsInput() { // Setup Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Categories/AssemblyCategoriesKernelStubTest.cs =================================================================== diff -u -rc49950c03fc3c5c67c54870ce6a51aa8a42e3458 -r6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Categories/AssemblyCategoriesKernelStubTest.cs (.../AssemblyCategoriesKernelStubTest.cs) (revision c49950c03fc3c5c67c54870ce6a51aa8a42e3458) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Test/Kernels/Categories/AssemblyCategoriesKernelStubTest.cs (.../AssemblyCategoriesKernelStubTest.cs) (revision 6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3) @@ -41,6 +41,8 @@ // Assert Assert.IsInstanceOf(kernelStub); + Assert.AreEqual(0, kernelStub.LowerBoundaryNorm); + Assert.AreEqual(0, kernelStub.SignalingNorm); Assert.IsFalse(kernelStub.Calculated); } @@ -73,7 +75,8 @@ Assert.IsFalse(kernelStub.Calculated); // Call - kernelStub.CalculateAssessmentSectionCategories(new CalculateAssessmentSectionCategoriesInput(new Probability(0), new Probability(0))); + kernelStub.CalculateAssessmentSectionCategories(new CalculateAssessmentSectionCategoriesInput( + new Probability(0), new Probability(0))); // Assert Assert.IsTrue(kernelStub.Calculated); @@ -210,7 +213,7 @@ // Assert Assert.Throws(test); } - + [Test] public void CalculateGeotechnicFailureMechanismSectionCategories_Always_ThrowsNotImplementedException() { Index: Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs =================================================================== diff -u -r39e13825618c9845e2100ae802a007c04c2e8517 -r6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3 --- Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs (.../FailureMechanismSectionAssemblyCalculatorStub.cs) (revision 39e13825618c9845e2100ae802a007c04c2e8517) +++ Ringtoets/AssemblyTool/test/Ringtoets.AssemblyTool.KernelWrapper.TestUtil/Calculators/Assembly/FailureMechanismSectionAssemblyCalculatorStub.cs (.../FailureMechanismSectionAssemblyCalculatorStub.cs) (revision 6a9cb2d6ff7ad95ad9cdff2d2fdc998067e36cc3) @@ -34,7 +34,7 @@ /// /// Gets or sets the output of the calculation. /// - public FailureMechanismSectionAssembly SimpleAssessmentAssemblyOutput { get; set; } + public FailureMechanismSectionAssembly SimpleAssessmentAssemblyOutput { get; private set; } /// /// Gets the input of the calculation. @@ -60,8 +60,7 @@ SimpleAssessmentInput = input; - return SimpleAssessmentAssemblyOutput ?? - (SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0, FailureMechanismSectionAssemblyCategoryGroup.Iv)); + return SimpleAssessmentAssemblyOutput = new FailureMechanismSectionAssembly(0, FailureMechanismSectionAssemblyCategoryGroup.Iv); } public FailureMechanismSectionAssembly AssembleSimpleAssessment(SimpleAssessmentResultValidityOnlyType input)