Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssessmentSectionCategoryGroupCreator.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssessmentSectionCategoryGroupCreator.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableAssessmentSectionCategoryGroupCreator.cs (revision 05be5e79657a00455e43e78b629a074290b8d89e) @@ -0,0 +1,72 @@ +// 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 SerializableAssessmentSectionCategoryGroupCreator + { + /// + /// 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 SerializableAssessmentSectionCategoryGroup Create(AssessmentSectionAssemblyCategoryGroup categoryGroup) + { + if (!Enum.IsDefined(typeof(AssessmentSectionAssemblyCategoryGroup), categoryGroup)) + { + throw new InvalidEnumArgumentException(nameof(categoryGroup), + (int) categoryGroup, + typeof(AssessmentSectionAssemblyCategoryGroup)); + } + + switch (categoryGroup) + { + case AssessmentSectionAssemblyCategoryGroup.NotAssessed: + return SerializableAssessmentSectionCategoryGroup.NotAssessed; + case AssessmentSectionAssemblyCategoryGroup.APlus: + return SerializableAssessmentSectionCategoryGroup.APlus; + case AssessmentSectionAssemblyCategoryGroup.A: + return SerializableAssessmentSectionCategoryGroup.A; + case AssessmentSectionAssemblyCategoryGroup.B: + return SerializableAssessmentSectionCategoryGroup.B; + case AssessmentSectionAssemblyCategoryGroup.C: + return SerializableAssessmentSectionCategoryGroup.C; + case AssessmentSectionAssemblyCategoryGroup.D: + return SerializableAssessmentSectionCategoryGroup.D; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismCategoryGroupCreator.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismCategoryGroupCreator.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismCategoryGroupCreator.cs (revision 05be5e79657a00455e43e78b629a074290b8d89e) @@ -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 SerializableFailureMechanismCategoryGroupCreator + { + /// + /// 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 SerializableFailureMechanismCategoryGroup Create(FailureMechanismAssemblyCategoryGroup categoryGroup) + { + if (!Enum.IsDefined(typeof(FailureMechanismAssemblyCategoryGroup), categoryGroup)) + { + throw new InvalidEnumArgumentException(nameof(categoryGroup), + (int) categoryGroup, + typeof(FailureMechanismAssemblyCategoryGroup)); + } + + switch (categoryGroup) + { + case FailureMechanismAssemblyCategoryGroup.NotApplicable: + return SerializableFailureMechanismCategoryGroup.NotApplicable; + case FailureMechanismAssemblyCategoryGroup.It: + return SerializableFailureMechanismCategoryGroup.It; + case FailureMechanismAssemblyCategoryGroup.IIt: + return SerializableFailureMechanismCategoryGroup.IIt; + case FailureMechanismAssemblyCategoryGroup.IIIt: + return SerializableFailureMechanismCategoryGroup.IIIt; + case FailureMechanismAssemblyCategoryGroup.IVt: + return SerializableFailureMechanismCategoryGroup.IVt; + case FailureMechanismAssemblyCategoryGroup.Vt: + return SerializableFailureMechanismCategoryGroup.Vt; + case FailureMechanismAssemblyCategoryGroup.VIt: + return SerializableFailureMechanismCategoryGroup.VIt; + case FailureMechanismAssemblyCategoryGroup.VIIt: + return SerializableFailureMechanismCategoryGroup.VIIt; + default: + throw new NotSupportedException(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj =================================================================== diff -u -r533c09fa374c801775800668d9046f9470db2f07 -r05be5e79657a00455e43e78b629a074290b8d89e --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 533c09fa374c801775800668d9046f9470db2f07) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 05be5e79657a00455e43e78b629a074290b8d89e) @@ -36,7 +36,9 @@ + + Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssessmentSectionCategoryGroupCreatorTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssessmentSectionCategoryGroupCreatorTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableAssessmentSectionCategoryGroupCreatorTest.cs (revision 05be5e79657a00455e43e78b629a074290b8d89e) @@ -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 SerializableAssessmentSectionCategoryGroupCreatorTest + { + [Test] + public void Create_InvalidAssessmentSectionAssemblyCategoryGroup_ThrowInvalidEnumArgumentException() + { + // Setup + const AssessmentSectionAssemblyCategoryGroup groupInput = (AssessmentSectionAssemblyCategoryGroup) 999; + + // Call + TestDelegate call = () => SerializableAssessmentSectionCategoryGroupCreator.Create(groupInput); + + // Assert + string message = $"The value of argument 'categoryGroup' ({(int) groupInput}) is invalid for Enum type '{nameof(AssessmentSectionAssemblyCategoryGroup)}'."; + var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message); + Assert.AreEqual("categoryGroup", exception.ParamName); + } + + [Test] + [TestCase(AssessmentSectionAssemblyCategoryGroup.None)] + [TestCase(AssessmentSectionAssemblyCategoryGroup.NotApplicable)] + public void Create_WithNotSupportedInvalidCategoryGroup_ThrowsNotSupportedException(AssessmentSectionAssemblyCategoryGroup notSupportedCategoryGroup) + { + // Call + TestDelegate call = () => SerializableAssessmentSectionCategoryGroupCreator.Create(notSupportedCategoryGroup); + + // Assert + Assert.Throws(call); + } + + [Test] + [TestCase(AssessmentSectionAssemblyCategoryGroup.APlus, SerializableAssessmentSectionCategoryGroup.APlus)] + [TestCase(AssessmentSectionAssemblyCategoryGroup.A, SerializableAssessmentSectionCategoryGroup.A)] + [TestCase(AssessmentSectionAssemblyCategoryGroup.B, SerializableAssessmentSectionCategoryGroup.B)] + [TestCase(AssessmentSectionAssemblyCategoryGroup.C, SerializableAssessmentSectionCategoryGroup.C)] + [TestCase(AssessmentSectionAssemblyCategoryGroup.D, SerializableAssessmentSectionCategoryGroup.D)] + [TestCase(AssessmentSectionAssemblyCategoryGroup.NotAssessed, SerializableAssessmentSectionCategoryGroup.NotAssessed)] + public void Create_WithValidAssessmentSectionAssemblyCategoryGroup_ReturnExpectedValues(AssessmentSectionAssemblyCategoryGroup categoryGroup, + SerializableAssessmentSectionCategoryGroup expectedGroup) + { + // Call + SerializableAssessmentSectionCategoryGroup serializableGroup = SerializableAssessmentSectionCategoryGroupCreator.Create(categoryGroup); + + // Assert + Assert.AreEqual(expectedGroup, serializableGroup); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismGroupCreatorTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismGroupCreatorTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismGroupCreatorTest.cs (revision 05be5e79657a00455e43e78b629a074290b8d89e) @@ -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 SerializableFailureMechanismGroupCreatorTest + { + [Test] + public void Create_InvalidFailureMechanismAssemblyCategoryGroup_ThrowInvalidEnumArgumentException() + { + // Setup + const FailureMechanismAssemblyCategoryGroup groupInput = (FailureMechanismAssemblyCategoryGroup) 999; + + // Call + TestDelegate call = () => SerializableFailureMechanismCategoryGroupCreator.Create(groupInput); + + // Assert + string message = $"The value of argument 'categoryGroup' ({(int) groupInput}) is invalid for Enum type '{nameof(FailureMechanismAssemblyCategoryGroup)}'."; + var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, message); + Assert.AreEqual("categoryGroup", exception.ParamName); + } + + [Test] + public void Create_WithFailureMechanismCategoryGroupNone_ThrowsNotSupportedException() + { + // Call + TestDelegate call = () => SerializableFailureMechanismCategoryGroupCreator.Create(FailureMechanismAssemblyCategoryGroup.None); + + // Assert + Assert.Throws(call); + } + + [Test] + [TestCase(FailureMechanismAssemblyCategoryGroup.NotApplicable, SerializableFailureMechanismCategoryGroup.NotApplicable)] + [TestCase(FailureMechanismAssemblyCategoryGroup.It, SerializableFailureMechanismCategoryGroup.It)] + [TestCase(FailureMechanismAssemblyCategoryGroup.IIt, SerializableFailureMechanismCategoryGroup.IIt)] + [TestCase(FailureMechanismAssemblyCategoryGroup.IIIt, SerializableFailureMechanismCategoryGroup.IIIt)] + [TestCase(FailureMechanismAssemblyCategoryGroup.IVt, SerializableFailureMechanismCategoryGroup.IVt)] + [TestCase(FailureMechanismAssemblyCategoryGroup.Vt, SerializableFailureMechanismCategoryGroup.Vt)] + [TestCase(FailureMechanismAssemblyCategoryGroup.VIt, SerializableFailureMechanismCategoryGroup.VIt)] + [TestCase(FailureMechanismAssemblyCategoryGroup.VIIt, SerializableFailureMechanismCategoryGroup.VIIt)] + public void Create_WithFailureMechanismCategoryGroup_ReturnsExpectedValues(FailureMechanismAssemblyCategoryGroup categoryGroup, + SerializableFailureMechanismCategoryGroup expectedGroup) + { + // Call + SerializableFailureMechanismCategoryGroup serializableGroup = SerializableFailureMechanismCategoryGroupCreator.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 -r533c09fa374c801775800668d9046f9470db2f07 -r05be5e79657a00455e43e78b629a074290b8d89e --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 533c09fa374c801775800668d9046f9470db2f07) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 05be5e79657a00455e43e78b629a074290b8d89e) @@ -38,7 +38,9 @@ + +