mirror of
https://github.com/dcronqvist/DotTiled.git
synced 2025-05-09 02:16:02 +03:00
Getting further with the json support
This commit is contained in:
parent
5626614acd
commit
1168917c23
38 changed files with 1072 additions and 269 deletions
28
DotTiled.Tests/Serialization/TestData.cs
Normal file
28
DotTiled.Tests/Serialization/TestData.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Xml;
|
||||
|
||||
namespace DotTiled.Tests;
|
||||
|
||||
public static partial class TestData
|
||||
{
|
||||
public static XmlReader GetXmlReaderFor(string testDataFile)
|
||||
{
|
||||
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{testDataFile}";
|
||||
using var stream = typeof(TestData).Assembly.GetManifestResourceStream(fullyQualifiedTestDataFile)
|
||||
?? throw new ArgumentException($"Test data file '{fullyQualifiedTestDataFile}' not found");
|
||||
|
||||
using var stringReader = new StreamReader(stream);
|
||||
var xml = stringReader.ReadToEnd();
|
||||
var xmlStringReader = new StringReader(xml);
|
||||
return XmlReader.Create(xmlStringReader);
|
||||
}
|
||||
|
||||
public static string GetRawStringFor(string testDataFile)
|
||||
{
|
||||
var fullyQualifiedTestDataFile = $"DotTiled.Tests.{testDataFile}";
|
||||
using var stream = typeof(TestData).Assembly.GetManifestResourceStream(fullyQualifiedTestDataFile)
|
||||
?? throw new ArgumentException($"Test data file '{fullyQualifiedTestDataFile}' not found");
|
||||
|
||||
using var stringReader = new StreamReader(stream);
|
||||
return stringReader.ReadToEnd();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue