2018-06-20 12:59:57 +02:00
|
|
|
|
using Claunia.PropertyList;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace plistcil.test
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BinaryPropertyListWriterTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void RoundtripTest()
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] data = File.ReadAllBytes("test-files/plist.bin");
|
|
|
|
|
|
NSObject root = PropertyListParser.Parse(data);
|
|
|
|
|
|
|
|
|
|
|
|
using (MemoryStream actualOutput = new MemoryStream())
|
|
|
|
|
|
using (Stream expectedOutput = File.OpenRead("test-files/plist.bin"))
|
|
|
|
|
|
using (ValidatingStream validatingStream = new ValidatingStream(actualOutput, expectedOutput))
|
|
|
|
|
|
{
|
|
|
|
|
|
BinaryPropertyListWriter writer = new BinaryPropertyListWriter(validatingStream);
|
|
|
|
|
|
writer.ReuseObjectIds = false;
|
|
|
|
|
|
writer.Write(root);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-26 13:59:12 +02:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
|
public void Roundtrip2Test()
|
|
|
|
|
|
{
|
|
|
|
|
|
byte[] data = File.ReadAllBytes("test-files/plist2.bin");
|
|
|
|
|
|
NSObject root = PropertyListParser.Parse(data);
|
|
|
|
|
|
|
|
|
|
|
|
using (MemoryStream actualOutput = new MemoryStream())
|
|
|
|
|
|
using (Stream expectedOutput = File.OpenRead("test-files/plist2.bin"))
|
|
|
|
|
|
using (ValidatingStream validatingStream = new ValidatingStream(actualOutput, expectedOutput))
|
|
|
|
|
|
{
|
|
|
|
|
|
BinaryPropertyListWriter writer = new BinaryPropertyListWriter(validatingStream);
|
|
|
|
|
|
writer.ReuseObjectIds = false;
|
|
|
|
|
|
writer.Write(root);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-06-20 12:59:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|