AssertNbtBigFile() public static method

public static AssertNbtBigFile ( NbtFile file ) : void
file NbtFile
return void
示例#1
0
 public void PartialReadTest()
 {
     // read the whole thing as one tag
     TestFiles.AssertValueTest(PartialReadTestInternal(new NbtFile(TestFiles.MakeValueTest())));
     TestFiles.AssertNbtSmallFile(PartialReadTestInternal(TestFiles.MakeSmallFile()));
     TestFiles.AssertNbtBigFile(PartialReadTestInternal(new NbtFile(TestFiles.Big)));
 }
示例#2
0
        public void LoadingBigFileZLib()
        {
            var  file   = new NbtFile();
            long length = file.LoadFromFile(TestFiles.BigZLib);

            TestFiles.AssertNbtBigFile(file);
            Assert.AreEqual(length, new FileInfo(TestFiles.BigZLib).Length);
        }
示例#3
0
 public void PartialBatchReadTest()
 {
     // read the whole thing as one tag, in batches of 4 bytes
     // Verifies fix for https://github.com/fragmer/fNbt/issues/26
     TestFiles.AssertValueTest(PartialReadTestInternal(new NbtFile(TestFiles.MakeValueTest()), 4));
     TestFiles.AssertNbtSmallFile(PartialReadTestInternal(TestFiles.MakeSmallFile(), 4));
     TestFiles.AssertNbtBigFile(PartialReadTestInternal(new NbtFile(TestFiles.Big), 4));
 }
示例#4
0
 public void LoadingBigFileStream()
 {
     byte[] fileBytes = File.ReadAllBytes(TestFiles.Big);
     using (var ms = new MemoryStream(fileBytes)) {
         using (var nss = new NonSeekableStream(ms)) {
             var  file   = new NbtFile();
             long length = file.LoadFromStream(nss, NbtCompression.None, NbtVersion.Legacy, null);
             TestFiles.AssertNbtBigFile(file);
             Assert.AreEqual(length, new FileInfo(TestFiles.Big).Length);
         }
     }
 }
示例#5
0
        public void LoadingBigFileBuffer()
        {
            byte[] fileBytes = File.ReadAllBytes(TestFiles.Big);
            var    file      = new NbtFile();

            Assert.Throws <ArgumentNullException>(
                () => file.LoadFromBuffer(null, 0, fileBytes.Length, NbtCompression.AutoDetect, null));

            long length = file.LoadFromBuffer(fileBytes, 0, fileBytes.Length, NbtCompression.AutoDetect, null);

            TestFiles.AssertNbtBigFile(file);
            Assert.AreEqual(length, new FileInfo(TestFiles.Big).Length);
        }
示例#6
0
        public void ReloadNonSeekableStream()
        {
            var loadedFile = new NbtFile(TestFiles.Big);

            using (var ms = new MemoryStream()) {
                using (var nss = new NonSeekableStream(ms)) {
                    long bytesWritten = loadedFile.SaveToStream(nss, NbtCompression.None);
                    ms.Position = 0;
                    Assert.Throws <NotSupportedException>(() => loadedFile.LoadFromStream(nss, NbtCompression.AutoDetect));
                    ms.Position = 0;
                    Assert.Throws <InvalidDataException>(() => loadedFile.LoadFromStream(nss, NbtCompression.ZLib, NbtVersion.Legacy));
                    ms.Position = 0;
                    long bytesRead = loadedFile.LoadFromStream(nss, NbtCompression.None, NbtVersion.Legacy);
                    Assert.AreEqual(bytesWritten, bytesRead);
                    TestFiles.AssertNbtBigFile(loadedFile);
                }
            }
        }
示例#7
0
        void ReloadFileInternal(String fileName, NbtCompression compression, bool bigEndian, bool buffered)
        {
            var loadedFile = new NbtFile(Path.Combine(TestFiles.DirName, fileName))
            {
                BigEndian = bigEndian
            };

            if (!buffered)
            {
                loadedFile.BufferSize = 0;
            }
            long bytesWritten = loadedFile.SaveToFile(Path.Combine(TestDirName, fileName), compression);
            long bytesRead    = loadedFile.LoadFromFile(Path.Combine(TestDirName, fileName), NbtCompression.AutoDetect,
                                                        null);

            Assert.AreEqual(bytesWritten, bytesRead);
            TestFiles.AssertNbtBigFile(loadedFile);
        }