AssertValueTest() публичный статический Метод

public static AssertValueTest ( NbtFile file ) : void
file NbtFile
Результат 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 ValueTest()
        {
            // write one named tag for every value type, and read it back
            using (var ms = new MemoryStream()) {
                var writer = new NbtWriter(ms, "root");
                Assert.AreEqual(ms, writer.BaseStream);
                {
                    writer.WriteByte("byte", 1);
                    writer.WriteShort("short", 2);
                    writer.WriteInt("int", 3);
                    writer.WriteLong("long", 4L);
                    writer.WriteFloat("float", 5f);
                    writer.WriteDouble("double", 6d);
                    writer.WriteByteArray("byteArray", new byte[] { 10, 11, 12 });
                    writer.WriteIntArray("intArray", new[] { 20, 21, 22 });
                    writer.WriteString("string", "123");
                }
                Assert.IsFalse(writer.IsDone);
                writer.EndCompound();
                Assert.IsTrue(writer.IsDone);
                writer.Finish();

                ms.Position = 0;
                var file = new NbtFile();
                file.LoadFromStream(ms, NbtCompression.None);

                TestFiles.AssertValueTest(file);
            }
        }
Пример #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 ReadAsTagTest3()
        {
            // read values as tags
            byte[] testData = new NbtFile(TestFiles.MakeValueTest()).SaveToBuffer(NbtCompression.None);
            var    reader   = new NbtReader(new MemoryStream(testData));
            var    root     = new NbtCompound("root");

            // skip root
            reader.ReadToFollowing();
            reader.ReadToFollowing();

            while (!reader.IsAtStreamEnd)
            {
                root.Add(reader.ReadAsTag());
            }

            TestFiles.AssertValueTest(new NbtFile(root));
        }
Пример #5
0
 public void ReadAsTagTest2()
 {
     // read the whole thing as one tag
     byte[] testData = new NbtFile(TestFiles.MakeValueTest()).SaveToBuffer(NbtCompression.None);
     {
         var reader = new NbtReader(new MemoryStream(testData));
         var root   = (NbtCompound)reader.ReadAsTag();
         TestFiles.AssertValueTest(new NbtFile(root));
     }
     {
         // Try the same thing but with end tag skipping disabled
         var reader = new NbtReader(new MemoryStream(testData))
         {
             SkipEndTags = false
         };
         var root = (NbtCompound)reader.ReadAsTag();
         TestFiles.AssertValueTest(new NbtFile(root));
     }
 }
Пример #6
0
 public void WriteTagTest()
 {
     using (var ms = new MemoryStream()) {
         var writer = new NbtWriter(ms, "root");
         {
             foreach (NbtTag tag in TestFiles.MakeValueTest().Tags)
             {
                 writer.WriteTag(tag);
             }
             writer.EndCompound();
             Assert.IsTrue(writer.IsDone);
             writer.Finish();
         }
         ms.Position = 0;
         var  file      = new NbtFile();
         long bytesRead = file.LoadFromBuffer(ms.ToArray(), 0, (int)ms.Length, NbtCompression.None);
         Assert.AreEqual(bytesRead, ms.Length);
         TestFiles.AssertValueTest(file);
     }
 }