Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r261d8e56f76b7bb4f5c5be7082bc3dfcb281657c -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 261d8e56f76b7bb4f5c5be7082bc3dfcb281657c) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -1632,27 +1632,27 @@ /// /// Looks up a localized string similar to Coördinaat van een punt bevat ongeldige waarde.. /// - public static string SoilLayer2DReader_Could_not_parse_point_location { + public static string SoilLayer2DGeometryReader_Could_not_parse_point_location { get { - return ResourceManager.GetString("SoilLayer2DReader_Could_not_parse_point_location", resourceCulture); + return ResourceManager.GetString("SoilLayer2DGeometryReader_Could_not_parse_point_location", resourceCulture); } } /// /// Looks up a localized string similar to Het XML-document dat de geometrie beschrijft voor de laag is niet geldig.. /// - public static string SoilLayer2DReader_Geometry_contains_no_valid_xml { + public static string SoilLayer2DGeometryReader_Geometry_contains_no_valid_xml { get { - return ResourceManager.GetString("SoilLayer2DReader_Geometry_contains_no_valid_xml", resourceCulture); + return ResourceManager.GetString("SoilLayer2DGeometryReader_Geometry_contains_no_valid_xml", resourceCulture); } } /// /// Looks up a localized string similar to De geometrie is leeg.. /// - public static string SoilLayer2DReader_Geometry_is_null { + public static string SoilLayer2DGeometryReader_Geometry_is_null { get { - return ResourceManager.GetString("SoilLayer2DReader_Geometry_is_null", resourceCulture); + return ResourceManager.GetString("SoilLayer2DGeometryReader_Geometry_is_null", resourceCulture); } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r261d8e56f76b7bb4f5c5be7082bc3dfcb281657c -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 261d8e56f76b7bb4f5c5be7082bc3dfcb281657c) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -830,13 +830,13 @@ De segmenten van de geometrie van de laag vormen geen lus. - + Coördinaat van een punt bevat ongeldige waarde. - + Het XML-document dat de geometrie beschrijft voor de laag is niet geldig. - + De geometrie is leeg. Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r17e4a03119d9331cfcbe5b2e3e3255d7d05b74bb -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 17e4a03119d9331cfcbe5b2e3e3255d7d05b74bb) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -136,7 +136,7 @@ - + Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayer2DGeometryReader.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayer2DGeometryReader.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayer2DGeometryReader.cs (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -0,0 +1,233 @@ +// 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.Collections.ObjectModel; +using System.IO; +using System.Xml; +using System.Xml.Linq; +using System.Xml.Schema; +using System.Xml.XPath; +using Core.Common.Base.Geometry; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.Properties; + +namespace Ringtoets.Common.IO.SoilProfile +{ + /// + /// This class is responsible for reading an array of bytes and interpret this as an XML document, + /// which contains information about the geometry of a soil layer. + /// + internal class SoilLayer2DGeometryReader + { + private const string outerLoopElementName = "OuterLoop"; + private const string innerLoopElementName = "InnerLoop"; + private const string endPointElementName = "EndPoint"; + private const string headPointElementName = "HeadPoint"; + private const string geometryCurveElementName = "GeometryCurve"; + private const string xElementName = "X"; + private const string zElementName = "Z"; + + private readonly XmlSchemaSet schema; + + /// + /// Creates a new instance of . + /// + public SoilLayer2DGeometryReader() + { + schema = LoadXmlSchema(); + } + + /// + /// Reads a new using the as the source of the + /// geometry for a soil layer. + /// + /// An of which contains the information + /// of a soil layer in an XML document. + /// A new with information taken from the XML document. + /// Thrown when is null. + /// Thrown when: + /// + /// is not valid XML. + /// does not pass schema validation. + /// + /// + /// + public SoilLayer2D Read(byte[] geometry) + { + if (geometry == null) + { + throw new ArgumentNullException(nameof(geometry), Resources.SoilLayer2DGeometryReader_Geometry_is_null); + } + try + { + using (var stream = new MemoryStream(geometry)) + { + return Read(XDocument.Load(stream)); + } + } + catch (XmlException e) + { + throw new SoilLayerConversionException(Resources.SoilLayer2DGeometryReader_Geometry_contains_no_valid_xml, e); + } + } + + /// + /// Reads a new using the . + /// + /// An which contains the information + /// of a soil layer in an XML document. + /// A new with information taken from the XML document. + /// Thrown when is null. + /// Thrown when: + /// + /// is not valid XML. + /// does not pass schema validation. + /// + /// + /// + public SoilLayer2D Read(XDocument geometry) + { + if (geometry == null) + { + throw new ArgumentNullException(nameof(geometry)); + } + ValidateToSchema(geometry); + + return ParseLayer(geometry); + } + + /// + /// Validates the to the . + /// + /// The to validate. + /// Thrown when the validation failed. + private void ValidateToSchema(XDocument document) + { + try + { + document.Validate(schema, null); + } + catch (XmlSchemaValidationException e) + { + throw new SoilLayerConversionException(Resources.SoilLayer2DGeometryReader_Geometry_contains_no_valid_xml, e); + } + } + + private static XmlSchemaSet LoadXmlSchema() + { + var xmlSchemaSet = new XmlSchemaSet(); + xmlSchemaSet.Add(XmlSchema.Read(new StringReader(Resources.XmlGeometrySchema), null)); + return xmlSchemaSet; + } + + /// + /// Parses the XML element to create a 2D soil layer. + /// + /// The geometry. + /// XML for inner or outer geometry loops is invalid. + private static SoilLayer2D ParseLayer(XDocument geometry) + { + var soilLayer = new SoilLayer2D(); + + XElement xmlOuterLoop = geometry.XPathSelectElement($"//{outerLoopElementName}"); + IEnumerable xmlInnerLoops = geometry.XPathSelectElements($"//{innerLoopElementName}"); + + if (xmlOuterLoop != null) + { + soilLayer.OuterLoop = ParseGeometryLoop(xmlOuterLoop); + } + foreach (XElement loop in xmlInnerLoops) + { + soilLayer.AddInnerLoop(ParseGeometryLoop(loop)); + } + return soilLayer; + } + + /// + /// Parses the XML element to create a collection of describing + /// a geometric loop. + /// + /// The geometric loop element. + /// XML for any geometry curve is invalid. + private static IEnumerable ParseGeometryLoop(XElement loop) + { + var loops = new Collection(); + IEnumerable curves = loop.XPathSelectElements($"//{geometryCurveElementName}"); + + foreach (XElement curve in curves) + { + loops.Add(ParseGeometryCurve(curve)); + } + return loops; + } + + /// + /// Parses the XML element to create a . + /// + /// The geometry curve element. + /// XML for geometry curve is invalid. + private static Segment2D ParseGeometryCurve(XElement curve) + { + XElement headDefinition = curve.Element(headPointElementName); + XElement endDefinition = curve.Element(endPointElementName); + if (headDefinition == null || endDefinition == null) + { + throw new SoilLayerConversionException(Resources.SoilLayer2DGeometryReader_Geometry_contains_no_valid_xml); + } + + return new Segment2D(ParsePoint(headDefinition), ParsePoint(endDefinition)); + } + + /// + /// Parses the XML element to create a . + /// + /// The 2D point element. + /// Thrown when any of the following occurs: + /// + /// A coordinate value cannot be parsed. + /// XML for 2D point is invalid. + /// + private static Point2D ParsePoint(XElement point) + { + XElement xElement = point.Element(xElementName); + XElement yElement = point.Element(zElementName); + if (xElement == null || yElement == null) + { + throw new SoilLayerConversionException(Resources.SoilLayer2DGeometryReader_Geometry_contains_no_valid_xml); + } + + try + { + double x = XmlConvert.ToDouble(xElement.Value); + double y = XmlConvert.ToDouble(yElement.Value); + return new Point2D(x, y); + } + catch (SystemException e) when (e is ArgumentNullException || e is + FormatException + || e is OverflowException) + { + throw new SoilLayerConversionException(Resources.SoilLayer2DGeometryReader_Could_not_parse_point_location, e); + } + } + } +} \ No newline at end of file Fisheye: Tag 0b9d2e855b0a0471854910ec1f2a237b65aac8f0 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayer2DReader.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile1D.cs =================================================================== diff -u -r87f50177e6dfa9923f095f6d223774900705a61e -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile1D.cs (.../SoilProfile1D.cs) (revision 87f50177e6dfa9923f095f6d223774900705a61e) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile1D.cs (.../SoilProfile1D.cs) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -97,9 +97,9 @@ /// Thrown when is null. /// Thrown when: /// - /// contains no layers + /// contains no layers; /// contains a layer with the - /// less than + /// less than . /// /// private void ValidateLayersCollection(IEnumerable layers, double bottom) Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -rf92423bbc5ed838f76206bf93f2503c315bfdf0a -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision f92423bbc5ed838f76206bf93f2503c315bfdf0a) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -174,7 +174,7 @@ SoilLayer2D soilLayer; try { - soilLayer = new SoilLayer2DReader().Read(geometryValue); + soilLayer = new SoilLayer2DGeometryReader().Read(geometryValue); } catch (SoilLayerConversionException e) { Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r0b9d2e855b0a0471854910ec1f2a237b65aac8f0 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -116,7 +116,7 @@ - + Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DGeometryReaderTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DGeometryReaderTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DGeometryReaderTest.cs (revision 0b9d2e855b0a0471854910ec1f2a237b65aac8f0) @@ -0,0 +1,375 @@ +// 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.Globalization; +using System.IO; +using System.Linq; +using System.Xml; +using System.Xml.Linq; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.IO.Exceptions; +using Ringtoets.Common.IO.SoilProfile; + +namespace Ringtoets.Common.IO.Test.SoilProfile +{ + [TestFixture] + public class SoilLayer2DGeometryReaderTest + { + [Test] + public void Constructor_ReturnsNewInstance() + { + // Call + var result = new SoilLayer2DGeometryReader(); + + // Assert + Assert.NotNull(result); + } + + [Test] + public void Read_NullByteArray_ThrowsArgumentNullException() + { + // Setup + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read((byte[]) null); + + // Assert + var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "De geometrie is leeg."); + Assert.AreEqual("geometry", exception.ParamName); + } + + [Test] + public void Read_NullXmlDocument_ThrowsArgumentNullException() + { + // Setup + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read((XDocument) null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("geometry", paramName); + } + + [Test] + public void Read_XmlDocumentWithoutSaneContent_ThrowsSoilLayerConversionException() + { + // Setup + XDocument xmlDoc = GetXmlDocument(""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Het XML-document dat de geometrie beschrijft voor de laag is niet geldig.", exception.Message); + } + + [Test] + public void Read_XmlDocumentWithNoInnerLoops_ThrowsSoilLayerConversionException() + { + // Setup + XDocument xmlDoc = GetXmlDocument(""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Het XML-document dat de geometrie beschrijft voor de laag is niet geldig.", exception.Message); + } + + [Test] + public void Read_XmlDocumentWithNoOuterLoop_ThrowsSoilLayerConversionException() + { + // Setup + XDocument xmlDoc = GetXmlDocument(""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Het XML-document dat de geometrie beschrijft voor de laag is niet geldig.", exception.Message); + } + + [Test] + public void Read_XmlDocumentWithEmptyInnerLoopAndOuterLoop_ReturnsLayerWithEmptyInnerLoopAndEmptyOuterLoop() + { + // Setup + XDocument xmlDoc = GetXmlDocument(""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + SoilLayer2D result = reader.Read(xmlDoc); + + // Assert + Assert.NotNull(result); + CollectionAssert.IsEmpty(result.OuterLoop); + Assert.AreEqual(1, result.InnerLoops.Count()); + CollectionAssert.IsEmpty(result.InnerLoops.ElementAt(0)); + } + + [Test] + [TestCase("x")] + [TestCase("")] + public void Read_XmlDocumentWithInvalidPointCoordinate_ThrowsSoilLayerConversionException(string incorrectNumber) + { + // Setup + XDocument xmlDoc = GetXmlDocument( + "" + + $"{incorrectNumber}1.2" + + "1.21.2" + + ""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Coördinaat van een punt bevat ongeldige waarde.", exception.Message); + } + + [Test] + public void Read_XmlDocumentWithOverflowingPointCoordinate_ThrowsSoilLayerConversionException() + { + // Setup + XDocument xmlDoc = GetXmlDocument( + "" + + $"{double.MaxValue}1.2" + + "1.21.2" + + ""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("Coördinaat van een punt bevat ongeldige waarde.", exception.Message); + } + + [Test] + [SetCulture("nl-NL")] + public void Read_NLXmlDocumentPointInOuterLoop_ReturnsLayerWithOuterLoopWithPoint() + { + Read_XmlDocumentPointInOuterLoop_ReturnsLayerWithOuterLoopWithPoint(); + } + + [Test] + [SetCulture("en-US")] + public void Read_ENXmlDocumentPointInOuterLoop_ReturnsLayerWithOuterLoopWithPoint() + { + Read_XmlDocumentPointInOuterLoop_ReturnsLayerWithOuterLoopWithPoint(); + } + + [Test] + public void Read_XmlDocumentPointsInInnerLoop_ReturnsLayerWithInnerLoopWithSegment() + { + // Setup + var random = new Random(22); + CultureInfo invariantCulture = CultureInfo.InvariantCulture; + + double x1 = random.NextDouble(); + double x2 = random.NextDouble(); + double y1 = random.NextDouble(); + double y2 = random.NextDouble(); + + string x1String = x1.ToString(invariantCulture); + string x2String = x2.ToString(invariantCulture); + string y1String = y1.ToString(invariantCulture); + string y2String = y2.ToString(invariantCulture); + double parsedX1 = double.Parse(x1String, invariantCulture); + double parsedX2 = double.Parse(x2String, invariantCulture); + double parsedY1 = double.Parse(y1String, invariantCulture); + double parsedY2 = double.Parse(y2String, invariantCulture); + XDocument xmlDoc = GetXmlDocument( + string.Format(invariantCulture, + "" + + "{0}0.1{1}" + + "{2}0.1{3}" + + "" + + "{0}0.1{1}" + + "{2}0.1{3}" + + "", + x1String, y1String, x2String, y2String)); + var reader = new SoilLayer2DGeometryReader(); + + // Call + SoilLayer2D result = reader.Read(xmlDoc); + + // Assert + Assert.NotNull(result); + var expectedSegment = new Segment2D(new Point2D(parsedX1, parsedY1), new Point2D(parsedX2, parsedY2)); + var expectedCollection = new[] + { + new List + { + expectedSegment, + expectedSegment + } + }; + CollectionAssert.AreEqual(expectedCollection, result.InnerLoops); + } + + [Test] + public void Read_XmlDocumentSinglePointOuterLoopGeometryCurve_ThrowsSoilLayerConversionException() + { + // Setup + XDocument xmlDoc = GetXmlDocument( + "" + + "10.11.1" + + ""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Read_XmlDocumentSinglePointInnerLoopGeometryCurve_ThrowsSoilLayerConversionException() + { + // Setup + XDocument xmlDoc = GetXmlDocument( + "" + + "00.11.1" + + ""); + var reader = new SoilLayer2DGeometryReader(); + + // Call + TestDelegate test = () => reader.Read(xmlDoc); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Read_XmlDocumentEqualSegments_ReturnsTwoEqualSegments() + { + // Setup + XDocument xmlDoc = GetXmlDocument( + "" + + "" + + "001.1101.1" + + "" + + "" + + "001.1101.1" + + "" + + ""); + + var reader = new SoilLayer2DGeometryReader(); + + // Call + SoilLayer2D result = reader.Read(xmlDoc); + + // Assert + Assert.AreEqual(2, result.OuterLoop.Count()); + Assert.AreEqual(result.OuterLoop.ElementAt(0), result.OuterLoop.ElementAt(1)); + } + + private static void Read_XmlDocumentPointInOuterLoop_ReturnsLayerWithOuterLoopWithPoint() + { + // Setup + var random = new Random(22); + CultureInfo invariantCulture = CultureInfo.InvariantCulture; + + double x1 = random.NextDouble(); + double x2 = random.NextDouble(); + double y1 = random.NextDouble(); + double y2 = random.NextDouble(); + + string x1String = x1.ToString(invariantCulture); + string x2String = x2.ToString(invariantCulture); + string y1String = y1.ToString(invariantCulture); + string y2String = y2.ToString(invariantCulture); + double parsedX1 = XmlConvert.ToDouble(x1String); + double parsedX2 = XmlConvert.ToDouble(x2String); + double parsedY1 = XmlConvert.ToDouble(y1String); + double parsedY2 = XmlConvert.ToDouble(y2String); + XDocument bytes = GetXmlDocument( + string.Format(invariantCulture, + "" + + "{0}0.1{1}" + + "{2}0.1{3}" + + "" + + "{0}0.1{1}" + + "{2}0.1{3}" + + "", + x1String, y1String, x2String, y2String)); + + var reader = new SoilLayer2DGeometryReader(); + + // Call + SoilLayer2D result = reader.Read(bytes); + + // Assert + Assert.NotNull(result); + var expectedSegment = new Segment2D(new Point2D(parsedX1, parsedY1), new Point2D(parsedX2, parsedY2)); + CollectionAssert.AreEqual(new List + { + expectedSegment, + expectedSegment + }, result.OuterLoop); + } + + /// + /// Takes a which describes an XML document and returns + /// an from this. + /// + /// The to convert to an . + /// The constructed from . + /// Thrown when is null. + /// Thrown when does not describe + /// a valid XML document. + private static XDocument GetXmlDocument(string str) + { + return XDocument.Load(new MemoryStream(GetByteArray(str))); + } + + /// + /// Takes a and returns an of , + /// which contains the same information as the original . + /// + /// The to convert to an of + /// . + /// The of constructed from + /// . + private static byte[] GetByteArray(string str) + { + var bytes = new byte[str.Length * sizeof(char)]; + Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); + return bytes; + } + } +} \ No newline at end of file Fisheye: Tag 0b9d2e855b0a0471854910ec1f2a237b65aac8f0 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayer2DReaderTest.cs'. Fisheye: No comparison available. Pass `N' to diff?