public async Task EncodeEmptyDirectoryTest()
        {
            MemoryStream outputStream = new MemoryStream();

            platform.WriteFileFunc = _ => outputStream;

            fileSystem.EnumFileSystemEntriesFunc = _ => {
                return(new[] { new FileSystemEntry(FileSystemEntryType.Directory, "dir", @"C:\dir\") });
            };

            await service.EncodeAsync(@"C:\dir\", @"C:\outputFile.dat", CancellationToken.None, null);

            byte[] expected = new BufferBuilder()
                              .AddByte(0x2)
                              .AddInt(0x0)
                              .AddByte(0x1)
                              .AddInt(0x6)
                              .AddString("dir")
                              .AddInt(0x0).GetData();
            CollectionAssert.AreEqual(expected, outputStream.ToArray());
        }
        public async Task EncodeDirectoryTest1()
        {
            MemoryStream outputStream = new MemoryStream();

            platform.WriteFileFunc = _ => outputStream;

            fileSystem.EnumFileSystemEntriesFunc = _ => {
                return(new[] {
                    new FileSystemEntry(FileSystemEntryType.Directory, "dir", @"C:\dir\", 2),
                    new FileSystemEntry(FileSystemEntryType.File, "f1.dat", @"C:\dir\f1.dat"),
                    new FileSystemEntry(FileSystemEntryType.File, "f2.dat", @"C:\dir\f2.dat"),
                    new FileSystemEntry(FileSystemEntryType.Directory, "subdir1", @"C:\dir\subdir1\"),
                    new FileSystemEntry(FileSystemEntryType.File, "f3.dat", @"C:\dir\subdir1\f3.dat"),
                    new FileSystemEntry(FileSystemEntryType.Directory, "subdir2", @"C:\dir\subdir2\"),
                    new FileSystemEntry(FileSystemEntryType.File, "f4.dat", @"C:\dir\subdir2\f4.dat"),
                });
            };

            Dictionary <string, byte[]> data = new Dictionary <string, byte[]> {
                { @"C:\dir\f1.dat", new byte[] { 0x1, 0x15, 0x15, 0x9, 0x9 } },
                { @"C:\dir\f2.dat", new byte[] { 0x15, 0x9, 0x9, 0x15 } },
                { @"C:\dir\subdir1\f3.dat", new byte[0] },
                { @"C:\dir\subdir2\f4.dat", new byte[] { 0x3, 0x1, 0x9 } },
            };

            platform.ReadFileFunc = x => new MemoryStream(data[x]);

            await service.EncodeAsync(@"C:\dir\", @"C:\outputFile.dat", CancellationToken.None, null);

            byte[] expected = new BufferBuilder()
                              .AddByte(0x2)
                              .AddInt(0x24)
                              .AddByte(0x1)
                              .AddLong(0x2)
                              .AddByte(0x3)
                              .AddLong(0x1)
                              .AddByte(0x9)
                              .AddLong(0x5)
                              .AddByte(0x15)
                              .AddLong(0x4)
                              .AddByte(0x1)
                              .AddInt(0x6)
                              .AddString("dir")
                              .AddInt(0x2)
                              .AddByte(0x0)
                              .AddInt(0xC)
                              .AddString("f1.dat")
                              .AddLong(0x9)
                              .AddByte(0x7D)
                              .AddByte(0x0)
                              .AddByte(0x0)
                              .AddInt(0xC)
                              .AddString("f2.dat")
                              .AddLong(0x6)
                              .AddByte(0x33)
                              .AddByte(0x1)
                              .AddInt(0xE)
                              .AddString("subdir1")
                              .AddInt(0x0)
                              .AddByte(0x0)
                              .AddInt(0xC)
                              .AddString("f3.dat")
                              .AddLong(0x0)
                              .AddByte(0x1)
                              .AddInt(0xE)
                              .AddString("subdir2")
                              .AddInt(0x0)
                              .AddByte(0x0)
                              .AddInt(0xC)
                              .AddString("f4.dat")
                              .AddLong(0x7)
                              .AddByte(0x29)
                              .GetData();
            CollectionAssert.AreEqual(expected, outputStream.ToArray());
        }