Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Categories/AssessmentSectionAssemblyGroupBoundariesCalculator.cs =================================================================== diff -u -ra3cb986d016c29441ba8fc0e8fa65db6613aefcb -r57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0 --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Categories/AssessmentSectionAssemblyGroupBoundariesCalculator.cs (.../AssessmentSectionAssemblyGroupBoundariesCalculator.cs) (revision a3cb986d016c29441ba8fc0e8fa65db6613aefcb) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Calculators/Categories/AssessmentSectionAssemblyGroupBoundariesCalculator.cs (.../AssessmentSectionAssemblyGroupBoundariesCalculator.cs) (revision 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0) @@ -62,7 +62,7 @@ CategoriesList output = kernel.CalculateAssessmentSectionCategoryLimitsWbi21( new AssessmentSection(new Probability(signalingNorm), new Probability(lowerLimitNorm))); - return AssemblyCategoryCreator.CreateAssessmentSectionAssemblyCategories(output); + return AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyCategories(output); } catch (AssemblyException e) { Fisheye: Tag 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0 refers to a dead (removed) revision in file `Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssemblyCategoryCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssessmentSectionAssemblyGroupCreator.cs =================================================================== diff -u --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssessmentSectionAssemblyGroupCreator.cs (revision 0) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssessmentSectionAssemblyGroupCreator.cs (revision 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0) @@ -0,0 +1,104 @@ +// 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 assessment section assembly groups. + /// + public static class AssessmentSectionAssemblyGroupCreator + { + /// + /// 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 CreateAssessmentSectionAssemblyCategories(CategoriesList groups) + { + if (groups == null) + { + throw new ArgumentNullException(nameof(groups)); + } + + return groups.Categories.Select( + categoriesOutput => new AssessmentSectionAssemblyGroupBoundaries( + categoriesOutput.LowerLimit, + categoriesOutput.UpperLimit, + CreateAssessmentSectionAssemblyGroup(categoriesOutput.Category))).ToArray(); + } + + /// + /// Creates an based on . + /// + /// The to convert. + /// A based on . + /// Thrown when + /// is an invalid value. + /// Thrown when + /// is a valid value, but unsupported. + public static AssessmentSectionAssemblyGroup CreateAssessmentSectionAssemblyGroup(EAssessmentGrade group) + { + if (!Enum.IsDefined(typeof(EAssessmentGrade), group)) + { + throw new InvalidEnumArgumentException(nameof(group), + (int) group, + typeof(EAssessmentGrade)); + } + + switch (group) + { + case EAssessmentGrade.APlus: + return AssessmentSectionAssemblyGroup.APlus; + case EAssessmentGrade.A: + return AssessmentSectionAssemblyGroup.A; + case EAssessmentGrade.B: + return AssessmentSectionAssemblyGroup.B; + case EAssessmentGrade.C: + return AssessmentSectionAssemblyGroup.C; + case EAssessmentGrade.D: + return AssessmentSectionAssemblyGroup.D; + case EAssessmentGrade.Gr: + return AssessmentSectionAssemblyGroup.None; + case EAssessmentGrade.Ngo: + return AssessmentSectionAssemblyGroup.NotAssessed; + case EAssessmentGrade.Nvt: + return AssessmentSectionAssemblyGroup.NotApplicable; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssessmentSectionAssemblyResultCreator.cs =================================================================== diff -u -r5f782332ee6ed380dc3272c5e17092c9a6cb943a -r57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0 --- Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssessmentSectionAssemblyResultCreator.cs (.../AssessmentSectionAssemblyResultCreator.cs) (revision 5f782332ee6ed380dc3272c5e17092c9a6cb943a) +++ Riskeer/AssemblyTool/src/Riskeer.AssemblyTool.KernelWrapper/Creators/AssessmentSectionAssemblyResultCreator.cs (.../AssessmentSectionAssemblyResultCreator.cs) (revision 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0) @@ -50,7 +50,7 @@ } return new AssessmentSectionAssemblyResult(result.FailureProbability, - AssemblyCategoryCreator.CreateAssessmentSectionAssemblyGroup(result.Category)); + AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup(result.Category)); } } } \ No newline at end of file Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs =================================================================== diff -u -r5f782332ee6ed380dc3272c5e17092c9a6cb943a -r57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0 --- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs (.../AssessmentSectionAssemblyCalculatorTest.cs) (revision 5f782332ee6ed380dc3272c5e17092c9a6cb943a) +++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Calculators/Assembly/AssessmentSectionAssemblyCalculatorTest.cs (.../AssessmentSectionAssemblyCalculatorTest.cs) (revision 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0) @@ -163,7 +163,7 @@ // Assert Assert.AreEqual(assemblyResult.FailureProbability, result.Probability); - Assert.AreEqual(AssemblyCategoryCreator.CreateAssessmentSectionAssemblyGroup(assemblyResult.Category), + Assert.AreEqual(AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup(assemblyResult.Category), result.AssemblyCategoryGroup); } } Fisheye: Tag 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0 refers to a dead (removed) revision in file `Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/AssemblyCategoryCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/AssessmentSectionAssemblyGroupCreatorTest.cs =================================================================== diff -u --- Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/AssessmentSectionAssemblyGroupCreatorTest.cs (revision 0) +++ Riskeer/AssemblyTool/test/Riskeer.AssemblyTool.KernelWrapper.Test/Creators/AssessmentSectionAssemblyGroupCreatorTest.cs (revision 57da5ea59cea2ac53c249bea9fe1dea9a9dfa5a0) @@ -0,0 +1,59 @@ +// 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.ComponentModel; +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 AssessmentSectionAssemblyGroupCreatorTest + { + [Test] + public void CreateAssessmentSectionAssemblyCategoryGroup_WithInvalidAssessmentGrade_ThrowsInvalidEnumArgumentException() + { + // Call + void Call() => AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup((EAssessmentGrade) 99); + + // Assert + const string exceptionMessage = "The value of argument 'group' (99) is invalid for Enum type 'EAssessmentGrade'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, exceptionMessage); + } + + [Test] + [TestCaseSource(typeof(AssessmentGradeConversionTestHelper), nameof(AssessmentGradeConversionTestHelper.AssessmentGradeConversionCases))] + public void CreateAssessmentSectionAssemblyGroup_WithValidAssessmentGrade_ExpectedAssessmentSectionAssemblyGroupResultType( + EAssessmentGrade group, + AssessmentSectionAssemblyGroup expectedCategoryGroup) + { + // Call + AssessmentSectionAssemblyGroup result = AssessmentSectionAssemblyGroupCreator.CreateAssessmentSectionAssemblyGroup(group); + + // Assert + Assert.AreEqual(expectedCategoryGroup, result); + } + } +} \ No newline at end of file