Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionCreator.cs =================================================================== diff -u --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionCreator.cs (revision 0) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Creators/SerializableFailureMechanismSectionCreator.cs (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b) @@ -0,0 +1,75 @@ +// 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 Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.Enums; +using Ringtoets.Integration.IO.Assembly; +using Ringtoets.Integration.IO.Helpers; +using Ringtoets.Integration.IO.Properties; + +namespace Ringtoets.Integration.IO.Creators +{ + /// + /// Creator to create instance of + /// + public static class SerializableFailureMechanismSectionCreator + { + /// + /// Creates a based on + /// an . + /// + /// The id generator to generate an id + /// for . + /// The + /// this section belongs to. + /// The + /// to create a for. + /// A . + /// Thrown when any parameter is null. + public static SerializableFailureMechanismSection Create(UniqueIdentifierGenerator idGenerator, + SerializableFailureMechanismSectionCollection serializableCollection, + ExportableFailureMechanismSection section) + { + if (idGenerator == null) + { + throw new ArgumentNullException(nameof(idGenerator)); + } + + if (serializableCollection == null) + { + throw new ArgumentNullException(nameof(serializableCollection)); + } + + if (section == null) + { + throw new ArgumentNullException(nameof(section)); + } + + return new SerializableFailureMechanismSection(idGenerator.GetNewId(Resources.SerializableFailureMechanismSection_IdPrefix), + serializableCollection, + section.StartDistance, + section.EndDistance, + section.Geometry, + SerializableFailureMechanismSectionType.FailureMechanism); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r1879fa4ddaffba451a510edcc1dfe75d45359fdb -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1879fa4ddaffba451a510edcc1dfe75d45359fdb) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b) @@ -118,6 +118,15 @@ } /// + /// Looks up a localized string similar to Wks. + /// + internal static string SerializableFailureMechanismSection_IdPrefix { + get { + return ResourceManager.GetString("SerializableFailureMechanismSection_IdPrefix", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Vo. /// internal static string SerializableTotalAssemblyResult_IdPrefix { Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.resx =================================================================== diff -u -r1879fa4ddaffba451a510edcc1dfe75d45359fdb -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision 1879fa4ddaffba451a510edcc1dfe75d45359fdb) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Properties/Resources.resx (.../Resources.resx) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b) @@ -132,4 +132,7 @@ Ts + + Wks + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj =================================================================== diff -u -r597dfc8dd0177c9739b61f0fc6a983306b0d3aff -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b --- Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision 597dfc8dd0177c9739b61f0fc6a983306b0d3aff) +++ Ringtoets/Integration/src/Ringtoets.Integration.IO/Ringtoets.Integration.IO.csproj (.../Ringtoets.Integration.IO.csproj) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b) @@ -46,6 +46,7 @@ + Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionCreatorTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionCreatorTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Creators/SerializableFailureMechanismSectionCreatorTest.cs (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b) @@ -0,0 +1,103 @@ +// 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 NUnit.Framework; +using Ringtoets.AssemblyTool.IO.Model; +using Ringtoets.AssemblyTool.IO.Model.Enums; +using Ringtoets.AssemblyTool.IO.Model.Helpers; +using Ringtoets.Integration.IO.Assembly; +using Ringtoets.Integration.IO.Creators; +using Ringtoets.Integration.IO.Helpers; +using Ringtoets.Integration.IO.TestUtil; + +namespace Ringtoets.Integration.IO.Test.Creators +{ + [TestFixture] + public class SerializableFailureMechanismSectionCreatorTest + { + [Test] + public void Create_IdGeneratorNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableFailureMechanismSectionCreator.Create(null, + new SerializableFailureMechanismSectionCollection(), + ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("idGenerator", exception.ParamName); + } + + [Test] + public void Create_CollectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableFailureMechanismSectionCreator.Create(new UniqueIdentifierGenerator(), + null, + ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("serializableCollection", exception.ParamName); + } + + [Test] + public void Create_SectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => SerializableFailureMechanismSectionCreator.Create(new UniqueIdentifierGenerator(), + new SerializableFailureMechanismSectionCollection(), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("section", exception.ParamName); + } + + [Test] + public void Create_WithSection_ReturnsSerializableFailureMechanismSection() + { + // Setup + const string collectionId = "collectionId"; + var collection = new SerializableFailureMechanismSectionCollection(collectionId, new SerializableFailureMechanism()); + + var idGenerator = new UniqueIdentifierGenerator(); + ExportableFailureMechanismSection section = ExportableFailureMechanismSectionTestFactory.CreateExportableFailureMechanismSection(); + + // Call + SerializableFailureMechanismSection serializableSection = + SerializableFailureMechanismSectionCreator.Create(idGenerator, collection, section); + + // Assert + Assert.AreEqual("Wks.0", serializableSection.Id); + Assert.AreEqual(collection.Id, serializableSection.FailureMechanismSectionCollectionId); + + Assert.AreEqual(GeometrySerializationFormatter.Format(section.Geometry), + serializableSection.Geometry.LineString.Geometry); + Assert.AreEqual(section.StartDistance, serializableSection.StartDistance.Value); + Assert.AreEqual(section.EndDistance, serializableSection.EndDistance.Value); + Assert.AreEqual(SerializableFailureMechanismSectionType.FailureMechanism, + serializableSection.FailureMechanismSectionType); + Assert.IsNull(serializableSection.AssemblyMethod); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj =================================================================== diff -u -r597dfc8dd0177c9739b61f0fc6a983306b0d3aff -rce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b --- Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision 597dfc8dd0177c9739b61f0fc6a983306b0d3aff) +++ Ringtoets/Integration/test/Ringtoets.Integration.IO.Test/Ringtoets.Integration.IO.Test.csproj (.../Ringtoets.Integration.IO.Test.csproj) (revision ce42b439da4acd8052e1a3ecf9f7d2d28fa88d7b) @@ -46,6 +46,7 @@ +