Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Categories/FailureMechanismSectionAssemblyGroupBoundariesCalculator.cs =================================================================== diff -u -r79aa994fe07c9cfed13104e05df1810e6ae95e7b -rba1f27643eaa8f3da0b11c40189933fa43ec329d --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Categories/FailureMechanismSectionAssemblyGroupBoundariesCalculator.cs (.../FailureMechanismSectionAssemblyGroupBoundariesCalculator.cs) (revision 79aa994fe07c9cfed13104e05df1810e6ae95e7b) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Categories/FailureMechanismSectionAssemblyGroupBoundariesCalculator.cs (.../FailureMechanismSectionAssemblyGroupBoundariesCalculator.cs) (revision ba1f27643eaa8f3da0b11c40189933fa43ec329d) @@ -63,7 +63,7 @@ new AssessmentSection(AssemblyCalculatorInputCreator.CreateProbability(signalingNorm), AssemblyCalculatorInputCreator.CreateProbability(lowerLimitNorm))); - return AssemblyGroupBoundariesCreator.CreateFailureMechanismSectionAssemblyGroupBoundaries(output); + return FailureMechanismSectionAssemblyGroupCreator.CreateFailureMechanismSectionAssemblyGroupBoundaries(output); } catch (AssemblyException e) { Fisheye: Tag ba1f27643eaa8f3da0b11c40189933fa43ec329d refers to a dead (removed) revision in file `Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssemblyGroupBoundariesCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyGroupCreator.cs =================================================================== diff -u --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyGroupCreator.cs (revision 0) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/FailureMechanismSectionAssemblyGroupCreator.cs (revision ba1f27643eaa8f3da0b11c40189933fa43ec329d) @@ -0,0 +1,68 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using Assembly.Kernel.Model.Categories; +using Riskeer.AssemblyTool.Data; + +namespace Riskeer.AssemblyTool.KernelWrapper.Creators +{ + /// + /// Creates failure mechanism section assembly groups. + /// + internal static class FailureMechanismSectionAssemblyGroupCreator + { + /// + /// Creates a collection of + /// based on the information given in the . + /// + /// The with + /// to create the result for. + /// A collection of + /// with information taken from the . + /// Thrown when is null. + /// Thrown when + /// contains an invalid value. + /// Thrown when + /// contains a valid value, but unsupported. + public static IEnumerable CreateFailureMechanismSectionAssemblyGroupBoundaries( + CategoriesList groups) + { + if (groups == null) + { + throw new ArgumentNullException(nameof(groups)); + } + + return groups.Categories.Select(CreateFailureMechanismSectionAssemblyGroupBoundaries) + .ToArray(); + } + + private static FailureMechanismSectionAssemblyGroupBoundaries CreateFailureMechanismSectionAssemblyGroupBoundaries(InterpretationCategory group) + { + return new FailureMechanismSectionAssemblyGroupBoundaries( + group.LowerLimit, group.UpperLimit, + FailureMechanismSectionAssemblyGroupConverter.ConvertTo(group.Category)); + } + } +} \ No newline at end of file Fisheye: Tag ba1f27643eaa8f3da0b11c40189933fa43ec329d refers to a dead (removed) revision in file `Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/AssemblyGroupBoundariesCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionAssemblyGroupCreatorTest.cs =================================================================== diff -u --- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionAssemblyGroupCreatorTest.cs (revision 0) +++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/FailureMechanismSectionAssemblyGroupCreatorTest.cs (revision ba1f27643eaa8f3da0b11c40189933fa43ec329d) @@ -0,0 +1,88 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Assembly.Kernel.Model; +using Assembly.Kernel.Model.Categories; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.Data; +using Riskeer.AssemblyTool.KernelWrapper.Creators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil; + +namespace Riskeer.AssemblyTool.KernelWrapper.Test.Creators +{ + [TestFixture] + public class FailureMechanismSectionAssemblyGroupCreatorTest + { + [Test] + public void CreateFailureMechanismSectionAssemblyGroupBoundaries_GroupsNull_ThrowsArgumentNullException() + { + // Call + void Call() => FailureMechanismSectionAssemblyGroupCreator.CreateFailureMechanismSectionAssemblyGroupBoundaries(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("groups", exception.ParamName); + } + + [Test] + public void CreateFailureMechanismSectionAssemblyGroupBoundaries_WithGroups_ExpectedAssessmentSectionAssemblyGroupResultType() + { + // Setup + var random = new Random(11); + + var groups = new CategoriesList(new[] + { + new InterpretationCategory(random.NextEnumValue(), new Probability(0), new Probability(0.25)), + new InterpretationCategory(random.NextEnumValue(), new Probability(0.25), new Probability(0.5)), + new InterpretationCategory(random.NextEnumValue(), new Probability(0.5), new Probability(0.75)), + new InterpretationCategory(random.NextEnumValue(), new Probability(0.75), new Probability(1)) + }); + + // Call + IEnumerable result = + FailureMechanismSectionAssemblyGroupCreator.CreateFailureMechanismSectionAssemblyGroupBoundaries(groups); + + // Assert + AssemblyGroupBoundariesAssert.AssertFailureMechanismSectionAssemblyGroupBoundaries(groups, result); + } + + [Test] + public void CreateFailureMechanismSectionAssemblyGroupBoundaries_GroupWithInvalidInterpretationCategory_ThrowsInvalidEnumArgumentException() + { + // Setup + var groups = new CategoriesList(new[] + { + new InterpretationCategory((EInterpretationCategory) 99, new Probability(0), new Probability(1)) + }); + + // Call + void Call() => FailureMechanismSectionAssemblyGroupCreator.CreateFailureMechanismSectionAssemblyGroupBoundaries(groups); + + // Assert + var exceptionMessage = $"The value of argument 'group' (99) is invalid for Enum type '{nameof(EInterpretationCategory)}'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, exceptionMessage); + } + } +} \ No newline at end of file