2018-07-09 19:57:08 +01:00
|
|
|
|
using System.IO;
|
|
|
|
|
|
using Claunia.PropertyList;
|
2018-06-20 12:59:57 +02:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
|
|
namespace plistcil.test
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BinaryPropertyListWriterTests
|
|
|
|
|
|
{
|
|
|
|
|
|
[Fact]
|
2018-07-09 19:57:08 +01:00
|
|
|
|
public void Roundtrip2Test()
|
2018-06-20 12:59:57 +02:00
|
|
|
|
{
|
2018-07-09 19:57:08 +01:00
|
|
|
|
byte[] data = File.ReadAllBytes("test-files/plist2.bin");
|
2018-06-20 12:59:57 +02:00
|
|
|
|
NSObject root = PropertyListParser.Parse(data);
|
|
|
|
|
|
|
2018-07-09 19:57:08 +01:00
|
|
|
|
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
|
|
|
|
}
|
2018-06-26 13:59:12 +02:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2018-07-09 19:57:08 +01:00
|
|
|
|
public void Roundtrip3Test()
|
2018-06-26 13:59:12 +02:00
|
|
|
|
{
|
2018-07-09 19:57:08 +01:00
|
|
|
|
byte[] data = File.ReadAllBytes("test-files/plist3.bin");
|
2018-06-26 13:59:12 +02:00
|
|
|
|
NSObject root = PropertyListParser.Parse(data);
|
|
|
|
|
|
|
2018-07-09 19:57:08 +01:00
|
|
|
|
using(MemoryStream actualOutput = new MemoryStream())
|
|
|
|
|
|
using(Stream expectedOutput = File.OpenRead("test-files/plist3.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
|
|
|
|
}
|
2018-06-26 15:55:41 +02:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2018-07-09 19:57:08 +01:00
|
|
|
|
public void Roundtrip4Test()
|
2018-06-26 15:55:41 +02:00
|
|
|
|
{
|
2018-07-09 19:57:08 +01:00
|
|
|
|
byte[] data = File.ReadAllBytes("test-files/plist4.bin");
|
2018-06-26 15:55:41 +02:00
|
|
|
|
NSObject root = PropertyListParser.Parse(data);
|
|
|
|
|
|
|
2018-07-09 19:57:08 +01:00
|
|
|
|
using(MemoryStream actualOutput = new MemoryStream())
|
|
|
|
|
|
using(Stream expectedOutput = File.OpenRead("test-files/plist4.bin"))
|
|
|
|
|
|
using(ValidatingStream validatingStream = new ValidatingStream(actualOutput, expectedOutput))
|
|
|
|
|
|
{
|
|
|
|
|
|
BinaryPropertyListWriter writer = new BinaryPropertyListWriter(validatingStream);
|
|
|
|
|
|
writer.ReuseObjectIds = false;
|
|
|
|
|
|
writer.Write(root);
|
|
|
|
|
|
}
|
2018-06-26 15:55:41 +02:00
|
|
|
|
}
|
2018-06-26 17:09:33 +02:00
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2018-07-09 19:57:08 +01:00
|
|
|
|
public void RoundtripTest()
|
2018-06-26 17:09:33 +02:00
|
|
|
|
{
|
2018-07-09 19:57:08 +01:00
|
|
|
|
byte[] data = File.ReadAllBytes("test-files/plist.bin");
|
2018-06-26 17:09:33 +02:00
|
|
|
|
NSObject root = PropertyListParser.Parse(data);
|
|
|
|
|
|
|
2018-07-09 19:57:08 +01:00
|
|
|
|
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 17:09:33 +02:00
|
|
|
|
}
|
2018-06-20 12:59:57 +02:00
|
|
|
|
}
|
2018-07-09 19:57:08 +01:00
|
|
|
|
}
|