// Copyright (C) Stichting Deltares 2016. 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.IO; using System.Xml; using System.Xml.Linq; using Ringtoets.Piping.IO.SoilProfile; namespace Ringtoets.Piping.IO.Test.TestHelpers { /// /// This class helps to create parameters for testing the . /// public static class StringGeometryHelper { /// /// Takes a which describes a 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. public 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 /// . public static byte[] GetByteArray(string str) { byte[] bytes = new byte[str.Length * sizeof(char)]; Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length); return bytes; } } }