Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/GrassCoverErosionInwards/DikeProfileCreateExtensions.cs =================================================================== diff -u -rff51075f9bb18ac60d0ab4de5aa50dc87fe73554 -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/GrassCoverErosionInwards/DikeProfileCreateExtensions.cs (.../DikeProfileCreateExtensions.cs) (revision ff51075f9bb18ac60d0ab4de5aa50dc87fe73554) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Create/GrassCoverErosionInwards/DikeProfileCreateExtensions.cs (.../DikeProfileCreateExtensions.cs) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -57,7 +57,7 @@ X = dikeProfile.WorldReferencePoint.X, Y = dikeProfile.WorldReferencePoint.Y, X0 = dikeProfile.X0, - DikeGeometryXml = new RoughnessPointXmlSerializer().ToXml(dikeProfile.DikeGeometry), + DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry), ForeshoreXml = new Point2DXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry), Orientation = dikeProfile.Orientation, DikeHeight = dikeProfile.DikeHeight, Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Read/GrassCoverErosionInwards/DikeProfileEntityReadExtensions.cs =================================================================== diff -u -rff51075f9bb18ac60d0ab4de5aa50dc87fe73554 -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Read/GrassCoverErosionInwards/DikeProfileEntityReadExtensions.cs (.../DikeProfileEntityReadExtensions.cs) (revision ff51075f9bb18ac60d0ab4de5aa50dc87fe73554) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Read/GrassCoverErosionInwards/DikeProfileEntityReadExtensions.cs (.../DikeProfileEntityReadExtensions.cs) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -56,7 +56,7 @@ } var dikeProfile = new DikeProfile(new Point2D(entity.X.ToNullAsNaN(), entity.Y.ToNullAsNaN()), - new RoughnessPointXmlSerializer().FromXml(entity.DikeGeometryXml), + new RoughnessPointCollectionXmlSerializer().FromXml(entity.DikeGeometryXml), new Point2DXmlSerializer().FromXml(entity.ForeshoreXml), CreateBreakWater(entity), CreateProperties(entity)); Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj =================================================================== diff -u -r48ccf93f389ff657634f4dd1a1c6c3e414c88b7a -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj (.../Ringtoets.Storage.Core.csproj) (revision 48ccf93f389ff657634f4dd1a1c6c3e414c88b7a) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Ringtoets.Storage.Core.csproj (.../Ringtoets.Storage.Core.csproj) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -427,7 +427,7 @@ - + Index: Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/RoughnessPointCollectionXmlSerializer.cs =================================================================== diff -u --- Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/RoughnessPointCollectionXmlSerializer.cs (revision 0) +++ Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/RoughnessPointCollectionXmlSerializer.cs (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -0,0 +1,73 @@ +// 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.Geometry; +using Ringtoets.Common.Data.DikeProfiles; + +namespace Ringtoets.Storage.Core.Serializers +{ + /// + /// Converter class that converts between a collection of + /// and an XML representation of that data. + /// + internal class RoughnessPointCollectionXmlSerializer : DataCollectionSerializer + { + protected override SerializableRoughnessPoint[] ToSerializableData(IEnumerable elements) + { + return elements.Select(p => new SerializableRoughnessPoint(p)).ToArray(); + } + + protected override RoughnessPoint[] FromSerializableData(IEnumerable serializedElements) + { + return serializedElements.Select(sp => sp.ToRoughnessPoint()).ToArray(); + } + + [Serializable] + [DataContract(Name = nameof(SerializableRoughnessPoint), Namespace = "")] + internal class SerializableRoughnessPoint + { + [DataMember] + private readonly double x; + + [DataMember] + private readonly double y; + + [DataMember] + private readonly double roughness; + + public SerializableRoughnessPoint(RoughnessPoint point) + { + x = point.Point.X; + y = point.Point.Y; + roughness = point.Roughness; + } + + public RoughnessPoint ToRoughnessPoint() + { + return new RoughnessPoint(new Point2D(x, y), roughness); + } + } + } +} \ No newline at end of file Fisheye: Tag 39a538cc9e60cd38cce11cc102384af799b75038 refers to a dead (removed) revision in file `Ringtoets/Storage/src/Ringtoets.Storage.Core/Serializers/RoughnessPointXmlSerializer.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/GrassCoverErosionInwards/DikeProfileCreateExtensionsTest.cs =================================================================== diff -u -r72a430c1611547a48f7ef87c1d0cb99c6662765c -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/GrassCoverErosionInwards/DikeProfileCreateExtensionsTest.cs (.../DikeProfileCreateExtensionsTest.cs) (revision 72a430c1611547a48f7ef87c1d0cb99c6662765c) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Create/GrassCoverErosionInwards/DikeProfileCreateExtensionsTest.cs (.../DikeProfileCreateExtensionsTest.cs) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -83,7 +83,7 @@ Assert.AreEqual(dikeProfile.WorldReferencePoint.Y, entity.Y); Assert.AreEqual(dikeProfile.X0, entity.X0); Assert.AreEqual(order, entity.Order); - string convertedDikeGeometry = new RoughnessPointXmlSerializer().ToXml(dikeProfile.DikeGeometry); + string convertedDikeGeometry = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry); Assert.AreEqual(convertedDikeGeometry, entity.DikeGeometryXml); string convertedForeshoreGeometry = new Point2DXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry); Assert.AreEqual(convertedForeshoreGeometry, entity.ForeshoreXml); @@ -163,7 +163,7 @@ Assert.AreEqual(dikeProfile.WorldReferencePoint.Y, entity.Y); Assert.AreEqual(dikeProfile.X0, entity.X0); Assert.AreEqual(order, entity.Order); - string convertedDikeGeometry = new RoughnessPointXmlSerializer().ToXml(dikeProfile.DikeGeometry); + string convertedDikeGeometry = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry); Assert.AreEqual(convertedDikeGeometry, entity.DikeGeometryXml); string convertedForeshoreGeometry = new Point2DXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry); Assert.AreEqual(convertedForeshoreGeometry, entity.ForeshoreXml); Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/FailureMechanismEntityReadExtensionsTest.cs =================================================================== diff -u -r48ccf93f389ff657634f4dd1a1c6c3e414c88b7a -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 48ccf93f389ff657634f4dd1a1c6c3e414c88b7a) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -1237,7 +1237,7 @@ public void ReadAsGrassCoverErosionInwardsFailureMechanism_WithDikeProfilesSet_ReturnsGrassCoverErosionInwardsFailureMechanismWithDikeProfilesAdded() { // Setup - string emptyDikeGeometryXml = new RoughnessPointXmlSerializer().ToXml(new RoughnessPoint[0]); + string emptyDikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(new RoughnessPoint[0]); string emptyForeshoreBinaryXml = new Point2DXmlSerializer().ToXml(new Point2D[0]); const string sourcePath = "some/path/to/my/dikeprofiles"; var entity = new FailureMechanismEntity Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/GrassCoverErosionInwards/DikeProfileEntityReadExtensionsTest.cs =================================================================== diff -u -reba63f243a045c42f7a8f8a7f7b65b79f2b281d7 -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/GrassCoverErosionInwards/DikeProfileEntityReadExtensionsTest.cs (.../DikeProfileEntityReadExtensionsTest.cs) (revision eba63f243a045c42f7a8f8a7f7b65b79f2b281d7) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/GrassCoverErosionInwards/DikeProfileEntityReadExtensionsTest.cs (.../DikeProfileEntityReadExtensionsTest.cs) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -63,7 +63,7 @@ { Id = "id", ForeshoreXml = new Point2DXmlSerializer().ToXml(new Point2D[0]), - DikeGeometryXml = new RoughnessPointXmlSerializer().ToXml(new RoughnessPoint[0]) + DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(new RoughnessPoint[0]) }; // Precondition @@ -138,7 +138,7 @@ BreakWaterHeight = null, BreakWaterType = null, ForeshoreXml = new Point2DXmlSerializer().ToXml(foreshorePoints), - DikeGeometryXml = new RoughnessPointXmlSerializer().ToXml(roughnessPoints), + DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints), DikeHeight = 1.2, X = 3.4, Y = 5.6, @@ -186,7 +186,7 @@ BreakWaterHeight = height, BreakWaterType = Convert.ToByte(type), ForeshoreXml = new Point2DXmlSerializer().ToXml(foreshorePoints), - DikeGeometryXml = new RoughnessPointXmlSerializer().ToXml(roughnessPoints), + DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints), DikeHeight = 4.5, X = 93.0, Y = 945.6, Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs =================================================================== diff -u -r5a1e32bf0ca1dbbc967a1f6168abb94869105a64 -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs) (revision 5a1e32bf0ca1dbbc967a1f6168abb94869105a64) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Read/GrassCoverErosionInwards/GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs (.../GrassCoverErosionInwardsCalculationEntityReadExtensionsTest.cs) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -196,7 +196,7 @@ var dikeProfileEntity = new DikeProfileEntity { Id = "a", - DikeGeometryXml = new RoughnessPointXmlSerializer().ToXml(new RoughnessPoint[0]), + DikeGeometryXml = new RoughnessPointCollectionXmlSerializer().ToXml(new RoughnessPoint[0]), ForeshoreXml = new Point2DXmlSerializer().ToXml(new Point2D[0]) }; var entity = new GrassCoverErosionInwardsCalculationEntity Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj =================================================================== diff -u -r48ccf93f389ff657634f4dd1a1c6c3e414c88b7a -r39a538cc9e60cd38cce11cc102384af799b75038 --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj (.../Ringtoets.Storage.Core.Test.csproj) (revision 48ccf93f389ff657634f4dd1a1c6c3e414c88b7a) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Ringtoets.Storage.Core.Test.csproj (.../Ringtoets.Storage.Core.Test.csproj) (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -141,7 +141,7 @@ - + Index: Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/RoughnessPointCollectionXmlSerializerTest.cs =================================================================== diff -u --- Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/RoughnessPointCollectionXmlSerializerTest.cs (revision 0) +++ Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/RoughnessPointCollectionXmlSerializerTest.cs (revision 39a538cc9e60cd38cce11cc102384af799b75038) @@ -0,0 +1,86 @@ +// 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.Collections; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Storage.Core.Serializers; +using Ringtoets.Storage.Core.TestUtil.Serializers; + +namespace Ringtoets.Storage.Core.Test.Serializers +{ + [TestFixture] + public class RoughnessPointCollectionXmlSerializerTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var serializer = new RoughnessPointCollectionXmlSerializer(); + + // Assert + Assert.IsInstanceOf>(serializer); + SerializerTestHelper.AssertSerializedData(typeof(RoughnessPointCollectionXmlSerializer.SerializableRoughnessPoint)); + } + + [Test] + public void GivenArrayWithRoughnessPoint_WhenConvertingRoundTrip_ThenEqualArrayOfRoughnessPoint() + { + // Given + var original = new[] + { + new RoughnessPoint(new Point2D(-7.7, -6.6), 0.5), + new RoughnessPoint(new Point2D(-5.5, -4.4), 0.6), + new RoughnessPoint(new Point2D(-3.3, -2.2), 0.7), + new RoughnessPoint(new Point2D(-1.1, 0.0), 0.8), + new RoughnessPoint(new Point2D(1.1, 2.2), 0.9), + new RoughnessPoint(new Point2D(3.3, 4.4), 1.0), + new RoughnessPoint(new Point2D(5.5, 6.6), 0.9), + new RoughnessPoint(new Point2D(7.7, 8.8), 0.8), + new RoughnessPoint(new Point2D(9.9, 10.10), 0.7) + }; + var converter = new RoughnessPointCollectionXmlSerializer(); + + // When + string xml = converter.ToXml(original); + RoughnessPoint[] roundtripResult = converter.FromXml(xml); + + // Then + CollectionAssert.AreEqual(original, roundtripResult, new RoughnessPointComparer()); + } + + private class RoughnessPointComparer : IComparer + { + public int Compare(object x, object y) + { + var x1 = (RoughnessPoint) x; + var y1 = (RoughnessPoint) y; + if (x1.Point.Equals(y1.Point) && x1.Roughness.Equals(y1.Roughness)) + { + return 0; + } + + return 1; + } + } + } +} \ No newline at end of file Fisheye: Tag 39a538cc9e60cd38cce11cc102384af799b75038 refers to a dead (removed) revision in file `Ringtoets/Storage/test/Ringtoets.Storage.Core.Test/Serializers/RoughnessPointXmlSerializerTest.cs'. Fisheye: No comparison available. Pass `N' to diff?