Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r2a585c57b57dac62d39293e51dda15c7392305de -r70e6f175074b3d62532adfda735e6f719602f3b1 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 2a585c57b57dac62d39293e51dda15c7392305de) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 70e6f175074b3d62532adfda735e6f719602f3b1) @@ -531,6 +531,7 @@ + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Serializers/DataCollectionSerializer.cs =================================================================== diff -u -r2a585c57b57dac62d39293e51dda15c7392305de -r70e6f175074b3d62532adfda735e6f719602f3b1 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Serializers/DataCollectionSerializer.cs (.../DataCollectionSerializer.cs) (revision 2a585c57b57dac62d39293e51dda15c7392305de) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Serializers/DataCollectionSerializer.cs (.../DataCollectionSerializer.cs) (revision 70e6f175074b3d62532adfda735e6f719602f3b1) @@ -29,10 +29,10 @@ namespace Application.Ringtoets.Storage.Serializers { /// - /// Converter class that converts between a collection of and an XML representation of that data. + /// Converter class that converts between a collection of and + /// an XML representation of that data. /// internal abstract class DataCollectionSerializer - where TData : class where TSerializedData : class { private static readonly Type serializationRootType = typeof(TSerializedData[]); Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Serializers/TangentLinesXmlSerializer.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Serializers/TangentLinesXmlSerializer.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Serializers/TangentLinesXmlSerializer.cs (revision 70e6f175074b3d62532adfda735e6f719602f3b1) @@ -0,0 +1,64 @@ +// 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.Collections.Generic; +using System.Linq; + +namespace Application.Ringtoets.Storage.Serializers +{ + /// + /// Converter class that converts between tangent lines and an XML representation of that data. + /// + internal class TangentLinesXmlSerializer : DataCollectionSerializer + { + protected override SerializableTangentLine[] ToSerializableData(IEnumerable elements) + { + return elements.Select(e => new SerializableTangentLine(e)).ToArray(); + } + + protected override double[] FromSerializableData(IEnumerable serializedElements) + { + return serializedElements.Select(se => se.ToTangentLine()).ToArray(); + } + + [Serializable] + internal class SerializableTangentLine + { + private readonly double tangentLine; + + /// + /// Creates a new instance of . + /// + /// The to base the + /// on. + public SerializableTangentLine(double tangentLine) + { + this.tangentLine = tangentLine; + } + + public double ToTangentLine() + { + return tangentLine; + } + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r2a585c57b57dac62d39293e51dda15c7392305de -r70e6f175074b3d62532adfda735e6f719602f3b1 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 2a585c57b57dac62d39293e51dda15c7392305de) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 70e6f175074b3d62532adfda735e6f719602f3b1) @@ -274,6 +274,7 @@ + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Serializers/TangentLinesXmlSerializerTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Serializers/TangentLinesXmlSerializerTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Serializers/TangentLinesXmlSerializerTest.cs (revision 70e6f175074b3d62532adfda735e6f719602f3b1) @@ -0,0 +1,61 @@ +// 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 Application.Ringtoets.Storage.Serializers; +using NUnit.Framework; + +namespace Application.Ringtoets.Storage.Test.Serializers +{ + [TestFixture] + public class TangentLinesXmlSerializerTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var serializer = new TangentLinesXmlSerializer(); + + // Assert + Assert.IsInstanceOf>(serializer); + } + + [Test] + public void GivenArrayOfTangentLines_WhenConvertingRoundTrip_ThenEqualTangentLines() + { + // Given + var random = new Random(31); + var original = new[] + { + double.NaN, + random.NextDouble() + }; + var serializer = new TangentLinesXmlSerializer(); + + // When + string xml = serializer.ToXml(original); + double[] roundtripResult = serializer.FromXml(xml); + + // Then + CollectionAssert.AreEqual(original, roundtripResult); + } + } +} \ No newline at end of file