Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionCategoryGroupCreator.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionCategoryGroupCreator.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionCategoryGroupCreator.cs (revision a3924f73a5f753dfc63ab7c195260ea2b79a3b2d) @@ -0,0 +1,76 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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 Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.IO.Model.Enums; + +namespace Ringtoets.Integration.IO.Creators +{ + /// + /// Creator to create . + /// + public static class SerializableFailureMechanismSectionCategoryGroupCreator + { + /// + /// Creates a based on its input. + /// + /// The to + /// create a for. + /// A . + /// Thrown when + /// is an invalid value. + /// Thrown when + /// is a valid value, but unsupported. + public static SerializableFailureMechanismSectionCategoryGroup Create(FailureMechanismSectionAssemblyCategoryGroup categoryGroup) + { + if (!Enum.IsDefined(typeof(FailureMechanismSectionAssemblyCategoryGroup), categoryGroup)) + { + throw new InvalidEnumArgumentException(nameof(categoryGroup), + (int) categoryGroup, + typeof(FailureMechanismSectionAssemblyCategoryGroup)); + } + + switch (categoryGroup) + { + case FailureMechanismSectionAssemblyCategoryGroup.NotApplicable: + return SerializableFailureMechanismSectionCategoryGroup.NotApplicable; + case FailureMechanismSectionAssemblyCategoryGroup.Iv: + return SerializableFailureMechanismSectionCategoryGroup.Iv; + case FailureMechanismSectionAssemblyCategoryGroup.IIv: + return SerializableFailureMechanismSectionCategoryGroup.IIv; + case FailureMechanismSectionAssemblyCategoryGroup.IIIv: + return SerializableFailureMechanismSectionCategoryGroup.IIIv; + case FailureMechanismSectionAssemblyCategoryGroup.IVv: + return SerializableFailureMechanismSectionCategoryGroup.IVv; + case FailureMechanismSectionAssemblyCategoryGroup.Vv: + return SerializableFailureMechanismSectionCategoryGroup.Vv; + case FailureMechanismSectionAssemblyCategoryGroup.VIv: + return SerializableFailureMechanismSectionCategoryGroup.VIv; + case FailureMechanismSectionAssemblyCategoryGroup.VIIv: + return SerializableFailureMechanismSectionCategoryGroup.VIIv; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj =================================================================== diff -u -r1879fa4ddaffba451a510edcc1dfe75d45359fdb -ra3924f73a5f753dfc63ab7c195260ea2b79a3b2d --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 1879fa4ddaffba451a510edcc1dfe75d45359fdb) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision a3924f73a5f753dfc63ab7c195260ea2b79a3b2d) @@ -44,6 +44,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionCategoryGroupCreatorTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionCategoryGroupCreatorTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionCategoryGroupCreatorTest.cs (revision a3924f73a5f753dfc63ab7c195260ea2b79a3b2d) @@ -0,0 +1,79 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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.TestUtil; +using NUnit.Framework; +using Ringtoets.AssemblyTool.Data; +using Ringtoets.AssemblyTool.IO.Model.Enums; +using Ringtoets.Integration.IO.Creators; + +namespace Ringtoets.Integration.IO.Test.Creators +{ + [TestFixture] + public class SerializableFailureMechanismSectionCategoryGroupCreatorTest + { + [Test] + public void Create_InvalidFailureMechanismSectionAssemblyCategoryGroup_ThrowInvalidEnumArgumentException() + { + // Setup + const FailureMechanismSectionAssemblyCategoryGroup groupInput = (FailureMechanismSectionAssemblyCategoryGroup) 999; + + // Call + TestDelegate call = () => SerializableFailureMechanismSectionCategoryGroupCreator.Create(groupInput); + + // Assert + string message = $"The value of argument 'categoryGroup' ({(int) groupInput}) is invalid for Enum type '{nameof(FailureMechanismSectionAssemblyCategoryGroup)}'."; + var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message); + Assert.AreEqual("categoryGroup", exception.ParamName); + } + + [Test] + public void Create_WithFailureMechanismSectionAssemblyCategoryGroupNone_ThrowsNotSupportedException() + { + // Call + TestDelegate call = () => SerializableFailureMechanismSectionCategoryGroupCreator.Create(FailureMechanismSectionAssemblyCategoryGroup.None); + + // Assert + Assert.Throws(call); + } + + [Test] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.NotApplicable, SerializableFailureMechanismSectionCategoryGroup.NotApplicable)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.Iv, SerializableFailureMechanismSectionCategoryGroup.Iv)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.IIv, SerializableFailureMechanismSectionCategoryGroup.IIv)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.IIIv, SerializableFailureMechanismSectionCategoryGroup.IIIv)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.IVv, SerializableFailureMechanismSectionCategoryGroup.IVv)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.Vv, SerializableFailureMechanismSectionCategoryGroup.Vv)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.VIv, SerializableFailureMechanismSectionCategoryGroup.VIv)] + [TestCase(FailureMechanismSectionAssemblyCategoryGroup.VIIv, SerializableFailureMechanismSectionCategoryGroup.VIIv)] + public void Create_WithFailureMechanismSectionCategoryGroup_ReturnsExpectedValues(FailureMechanismSectionAssemblyCategoryGroup categoryGroup, + SerializableFailureMechanismSectionCategoryGroup expectedGroup) + { + // Call + SerializableFailureMechanismSectionCategoryGroup serializableGroup = SerializableFailureMechanismSectionCategoryGroupCreator.Create(categoryGroup); + + // Assert + Assert.AreEqual(expectedGroup, serializableGroup); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj =================================================================== diff -u -r1879fa4ddaffba451a510edcc1dfe75d45359fdb -ra3924f73a5f753dfc63ab7c195260ea2b79a3b2d --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 1879fa4ddaffba451a510edcc1dfe75d45359fdb) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision a3924f73a5f753dfc63ab7c195260ea2b79a3b2d) @@ -1,4 +1,4 @@ - + {06C448C6-CBDE-4579-B5B6-1B8074E022ED} @@ -46,6 +46,7 @@ +