Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensions.cs =================================================================== diff -u -r4a30aea5c764fc20099bd2b42798590705555633 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensions.cs (.../MacroStabilityInwardsOutputCreateExtensions.cs) (revision 4a30aea5c764fc20099bd2b42798590705555633) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensions.cs (.../MacroStabilityInwardsOutputCreateExtensions.cs) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -92,7 +92,7 @@ private static void SetSlipPlaneParametersToEntity(MacroStabilityInwardsCalculationOutputEntity entity, MacroStabilityInwardsSlipPlaneUpliftVan slipPlane) { - entity.SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(slipPlane.TangentLines); + entity.SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(slipPlane.TangentLines); MacroStabilityInwardsGrid leftGrid = slipPlane.LeftGrid; entity.SlipPlaneLeftGridXLeft = leftGrid.XLeft.ToNaNAsNull(); Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs =================================================================== diff -u -r4a30aea5c764fc20099bd2b42798590705555633 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs) (revision 4a30aea5c764fc20099bd2b42798590705555633) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -81,7 +81,7 @@ NumberOfVerticalPoints = entity.SlipPlaneRightGridNrOfVerticalPoints }; - RoundedDouble[] tangentLines = new TangentLinesXmlSerializer().FromXml(entity.SlipPlaneTangentLinesXml); + RoundedDouble[] tangentLines = new TangentLineCollectionXmlSerializer().FromXml(entity.SlipPlaneTangentLinesXml); return new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines); } Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj =================================================================== diff -u -r39a538cc9e60cd38cce11cc102384af799b75038 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj (.../Ringtoets.Storage.Core.csproj) (revision 39a538cc9e60cd38cce11cc102384af799b75038) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj (.../Ringtoets.Storage.Core.csproj) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -523,7 +523,7 @@ - + Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/TangentLineCollectionXmlSerializer.cs =================================================================== diff -u --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/TangentLineCollectionXmlSerializer.cs (revision 0) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/TangentLineCollectionXmlSerializer.cs (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -0,0 +1,68 @@ +// 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; +using System.Runtime.Serialization; +using Core.Common.Base.Data; + +namespace Ringtoets.Storage.Core.Serializers +{ + /// + /// Converter class that converts between tangent lines and an XML representation of that data. + /// + internal class TangentLineCollectionXmlSerializer : DataCollectionSerializer + { + protected override SerializableTangentLine[] ToSerializableData(IEnumerable elements) + { + return elements.Select(e => new SerializableTangentLine(e)).ToArray(); + } + + protected override RoundedDouble[] FromSerializableData(IEnumerable serializedElements) + { + return serializedElements.Select(se => se.ToTangentLine()).ToArray(); + } + + [Serializable] + [DataContract(Name = nameof(SerializableTangentLine), Namespace = "")] + internal class SerializableTangentLine + { + [DataMember] + private readonly double tangentLine; + + /// + /// Creates a new instance of . + /// + /// The to base the + /// on. + public SerializableTangentLine(double tangentLine) + { + this.tangentLine = tangentLine; + } + + public RoundedDouble ToTangentLine() + { + return (RoundedDouble) tangentLine; + } + } + } +} \ No newline at end of file Fisheye: Tag c7bccf3eec9c8a12124c3486a639906f27597ef5 refers to a dead (removed) revision in file `Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/TangentLinesXmlSerializer.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationEntityReadExtensionsTest.cs =================================================================== diff -u -r4a30aea5c764fc20099bd2b42798590705555633 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationEntityReadExtensionsTest.cs (.../MacroStabilityInwardsCalculationEntityReadExtensionsTest.cs) (revision 4a30aea5c764fc20099bd2b42798590705555633) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationEntityReadExtensionsTest.cs (.../MacroStabilityInwardsCalculationEntityReadExtensionsTest.cs) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -243,7 +243,7 @@ var calculationOutputEntity = new MacroStabilityInwardsCalculationOutputEntity { - SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(tangentLines), + SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(tangentLines), SlidingCurveSliceXML = new MacroStabilityInwardsSliceCollectionXmlSerializer().ToXml(slices), SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(1, 100), SlipPlaneLeftGridNrOfVerticalPoints = random.Next(1, 100), Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs =================================================================== diff -u -r4a30aea5c764fc20099bd2b42798590705555633 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs) (revision 4a30aea5c764fc20099bd2b42798590705555633) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -86,7 +86,7 @@ SlidingCurveRightSlidingCircleIteratedForce = random.NextDouble(), SlidingCurveRightSlidingCircleDrivingMoment = random.NextDouble(), SlidingCurveRightSlidingCircleResistingMoment = random.NextDouble(), - SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(tangentLines), + SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(tangentLines), SlipPlaneLeftGridXLeft = random.NextDouble(0.0, 1.0), SlipPlaneLeftGridXRight = random.NextDouble(2.0, 3.0), SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(1, 100), @@ -157,7 +157,7 @@ return new MacroStabilityInwardsCalculationOutputEntity { SlidingCurveSliceXML = new MacroStabilityInwardsSliceCollectionXmlSerializer().ToXml(new MacroStabilityInwardsSlice[0]), - SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(new RoundedDouble[0]), + SlipPlaneTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(new RoundedDouble[0]), SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(1, 100), SlipPlaneLeftGridNrOfVerticalPoints = random.Next(1, 100), SlipPlaneRightGridNrOfHorizontalPoints = random.Next(1, 100), Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj =================================================================== diff -u -r39a538cc9e60cd38cce11cc102384af799b75038 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj (.../Ringtoets.Storage.Core.Test.csproj) (revision 39a538cc9e60cd38cce11cc102384af799b75038) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj (.../Ringtoets.Storage.Core.Test.csproj) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -242,7 +242,7 @@ - + Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/TangentLineCollectionXmlSerializerTest.cs =================================================================== diff -u --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/TangentLineCollectionXmlSerializerTest.cs (revision 0) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/TangentLineCollectionXmlSerializerTest.cs (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -0,0 +1,65 @@ +// 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 Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Storage.Core.Serializers; +using Ringtoets.Storage.Core.TestUtil.Serializers; + +namespace Ringtoets.Storage.Core.Test.Serializers +{ + [TestFixture] + public class TangentLineCollectionXmlSerializerTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var serializer = new TangentLineCollectionXmlSerializer(); + + // Assert + Assert.IsInstanceOf>(serializer); + SerializerTestHelper.AssertSerializedData(typeof(TangentLineCollectionXmlSerializer.SerializableTangentLine)); + } + + [Test] + public void GivenArrayOfTangentLines_WhenConvertingRoundTrip_ThenEqualTangentLines() + { + // Given + var random = new Random(31); + var original = new[] + { + new RoundedDouble(2, double.NaN), + random.NextRoundedDouble() + }; + var serializer = new TangentLineCollectionXmlSerializer(); + + // When + string xml = serializer.ToXml(original); + RoundedDouble[] roundtripResult = serializer.FromXml(xml); + + // Then + CollectionAssert.AreEqual(original, roundtripResult); + } + } +} \ No newline at end of file Fisheye: Tag c7bccf3eec9c8a12124c3486a639906f27597ef5 refers to a dead (removed) revision in file `Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/TangentLinesXmlSerializerTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.TestUtil/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityTestHelper.cs =================================================================== diff -u -r4a30aea5c764fc20099bd2b42798590705555633 -rc7bccf3eec9c8a12124c3486a639906f27597ef5 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.TestUtil/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityTestHelper.cs (.../MacroStabilityInwardsCalculationOutputEntityTestHelper.cs) (revision 4a30aea5c764fc20099bd2b42798590705555633) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.TestUtil/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityTestHelper.cs (.../MacroStabilityInwardsCalculationOutputEntityTestHelper.cs) (revision c7bccf3eec9c8a12124c3486a639906f27597ef5) @@ -70,7 +70,7 @@ private static void AssertSlipPlaneProperties(MacroStabilityInwardsSlipPlaneUpliftVan slipPlane, MacroStabilityInwardsCalculationOutputEntity entity) { - string expectedTangentLinesXml = new TangentLinesXmlSerializer().ToXml(slipPlane.TangentLines); + string expectedTangentLinesXml = new TangentLineCollectionXmlSerializer().ToXml(slipPlane.TangentLines); Assert.AreEqual(expectedTangentLinesXml, entity.SlipPlaneTangentLinesXml); MacroStabilityInwardsGrid leftGrid = slipPlane.LeftGrid;