Index: Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailureMechanismSectionAssemblyGroupHelper.cs =================================================================== diff -u --- Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailureMechanismSectionAssemblyGroupHelper.cs (revision 0) +++ Riskeer/Common/src/Riskeer.Common.Forms/Helpers/FailureMechanismSectionAssemblyGroupHelper.cs (revision c8cd24c1b88b32c7dbf4ff380ed56c7ef1b65fcc) @@ -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; +using System.ComponentModel; +using Core.Common.Util; +using Riskeer.AssemblyTool.Data; +using Riskeer.AssemblyTool.Forms; + +namespace Riskeer.Common.Forms.Helpers +{ + /// + /// Helper class for displaying . + /// + public static class FailureMechanismSectionAssemblyGroupHelper + { + /// + /// Gets the display name of the given . + /// + /// The assembly group to get the display name for. + /// The display name. + /// Thrown when + /// is an invalid value. + /// Thrown when + /// is a valid value, but unsupported. + public static string GetAssemblyGroupDisplayName(FailureMechanismSectionAssemblyGroup assemblyGroup) + { + if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyGroup), assemblyGroup)) + { + throw new InvalidEnumArgumentException(nameof(assemblyGroup), + (int) assemblyGroup, + typeof(FailureMechanismSectionAssemblyGroup)); + } + + DisplayFailureMechanismSectionAssemblyGroup displayAssemblyGroup = DisplayFailureMechanismSectionAssemblyGroupConverter.Convert( + assemblyGroup); + + return new EnumDisplayWrapper(displayAssemblyGroup).DisplayName; + } + } +} \ No newline at end of file Index: Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailureMechanismSectionAssemblyGroupHelperTest.cs =================================================================== diff -u --- Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailureMechanismSectionAssemblyGroupHelperTest.cs (revision 0) +++ Riskeer/Common/test/Riskeer.Common.Forms.Test/Helpers/FailureMechanismSectionAssemblyGroupHelperTest.cs (revision c8cd24c1b88b32c7dbf4ff380ed56c7ef1b65fcc) @@ -0,0 +1,66 @@ +// 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 Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.AssemblyTool.Data; +using Riskeer.Common.Forms.Helpers; + +namespace Riskeer.Common.Forms.Test.Helpers +{ + [TestFixture] + public class FailureMechanismSectionAssemblyGroupHelperTest + { + [Test] + public void GetAssemblyGroupDisplayName_InvalidValue_ThrowsInvalidEnumArgumentException() + { + // Call + void Call() => FailureMechanismSectionAssemblyGroupHelper.GetAssemblyGroupDisplayName((FailureMechanismSectionAssemblyGroup) 99); + + // Assert + var expectedMessage = $"The value of argument 'assemblyGroup' (99) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyGroup)}'."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + } + + [Test] + [TestCase(FailureMechanismSectionAssemblyGroup.ND, "ND")] + [TestCase(FailureMechanismSectionAssemblyGroup.III, "+III")] + [TestCase(FailureMechanismSectionAssemblyGroup.II, "+II")] + [TestCase(FailureMechanismSectionAssemblyGroup.I, "+I")] + [TestCase(FailureMechanismSectionAssemblyGroup.ZeroPlus, "+0")] + [TestCase(FailureMechanismSectionAssemblyGroup.Zero, "0")] + [TestCase(FailureMechanismSectionAssemblyGroup.IMin, "-I")] + [TestCase(FailureMechanismSectionAssemblyGroup.IIMin, "-II")] + [TestCase(FailureMechanismSectionAssemblyGroup.IIIMin, "-III")] + [TestCase(FailureMechanismSectionAssemblyGroup.D, "D")] + [TestCase(FailureMechanismSectionAssemblyGroup.Gr, "")] + public void GetAssemblyGroupDisplayName_ValidValue_ReturnsDisplayName(FailureMechanismSectionAssemblyGroup categoryGroup, + string expectedDisplayName) + { + // Call + string displayName = FailureMechanismSectionAssemblyGroupHelper.GetAssemblyGroupDisplayName(categoryGroup); + + // Assert + Assert.AreEqual(expectedDisplayName, displayName); + } + } +} \ No newline at end of file