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