コード例 #1
0
 public static void Serialize(JsonWriter writer, TagByteArray array)
 {
     writer.WriteStartArray();
     foreach (sbyte sb in array)
     {
         writer.WriteValue(sb);
     }
     writer.WriteEndArray();
 }
コード例 #2
0
        public override void WritePayload(Stream stream, INamedBinaryTag iTag)
        {
            TagByteArray tag = iTag as TagByteArray;

            byte[] count_b = BitConverter.GetBytes(tag.Count);
            count_b = count_b.ReverseIfLittleEndian();
            stream.Write(count_b, 0, 4);

            foreach (sbyte sb in tag)
            {
                byte b = unchecked ((byte)sb);
                stream.WriteByte(b);
            }
        }
コード例 #3
0
    public void ConstructorWithValueTest()
    {
      // arrange
      TagByteArray tag;
      byte[] value;

      value = new[] { byte.MinValue, byte.MaxValue };

      // act
      tag = new TagByteArray(value);

      // assert
      Assert.IsEmpty(tag.Name);
      CollectionAssert.AreEqual(value, tag.Value);
    }
コード例 #4
0
    public void ConstructorTest()
    {
      // arrange
      TagByteArray tag;
      byte[] expected;

      expected = new byte[0];

      // act
      tag = new TagByteArray();

      // assert
      Assert.IsEmpty(tag.Name);
      CollectionAssert.AreEqual(expected, tag.Value);
    }
コード例 #5
0
        public void Constructor_sets_name()
        {
            // arrange
            TagByteArray target;
            string       expected;
            string       actual;

            expected = "Alphatag";

            // act
            target = new TagByteArray(expected);

            // assert
            actual = target.Name;
            Assert.Equal(expected, actual);
        }
コード例 #6
0
        public void Equals_returns_true_for_matching_tag()
        {
            // arrange
            TagByteArray target;
            TagByteArray other;
            bool         actual;

            target = new TagByteArray("alpha", new byte[] { 2, 4, 8, 16, 32, 64, 128 });
            other  = new TagByteArray("alpha", new byte[] { 2, 4, 8, 16, 32, 64, 128 });

            // act
            actual = target.Equals(other);

            // assert
            Assert.True(actual);
        }
コード例 #7
0
        public void Equals_returns_false_with_different_name()
        {
            // arrange
            TagByteArray target;
            TagByteArray other;
            bool         actual;

            target = new TagByteArray("Alpha", new byte[] { 2, 4, 8, 16, 32, 64, 128 });
            other  = new TagByteArray("Beta", new byte[] { 2, 4, 8, 16, 32, 64, 128 });

            // act
            actual = target.Equals(other);

            // assert
            Assert.IsFalse(actual);
        }
コード例 #8
0
        public void Equals_returns_false_with_different_value()
        {
            // arrange
            TagByteArray target;
            TagByteArray other;
            bool         actual;

            target = new TagByteArray(string.Empty, new byte[] { 2, 4, 8, 16, 32, 64, 128 });
            other  = new TagByteArray(string.Empty, new byte[] { 2, 4, 8, 16, 32, 48, 128 });

            // act
            actual = target.Equals(other);

            // assert
            Assert.False(actual);
        }
コード例 #9
0
        public void Constructor_sets_default_name()
        {
            // arrange
            TagByteArray target;
            string       expected;
            string       actual;

            expected = string.Empty;

            // act
            target = new TagByteArray();

            // assert
            actual = target.Name;
            Assert.Equal(expected, actual);
        }
コード例 #10
0
        public void GetHashCode_returns_different_values_with_different_value()
        {
            // arrange
            TagByteArray target;
            int          actual;
            int          notExpected;

            target = new TagByteArray(string.Empty, new byte[] { 2, 4, 8, 16, 32, 64, 128 });

            notExpected = new TagByteArray(string.Empty, new byte[] { 2, 4, 8, 16, 32, 48, 128 }).GetHashCode();

            // act
            actual = target.GetHashCode();

            // assert
            Assert.NotEqual(notExpected, actual);
        }
コード例 #11
0
        public void ToString_returns_string_version_of_tag()
        {
            // arrange
            TagByteArray target;
            string       expected;
            string       actual;

            expected = "[ByteArray: gamma] (7 items)";

            target = new TagByteArray("gamma", new byte[] { 2, 4, 8, 16, 32, 64, 128 });

            // act
            actual = target.ToString();

            // assert
            Assert.Equal(expected, actual);
        }
コード例 #12
0
        public void Type_returns_correct_value()
        {
            // arrange
            TagByteArray target;
            TagType      expected;
            TagType      actual;

            target = new TagByteArray();

            expected = TagType.ByteArray;

            // act
            actual = target.Type;

            // assert
            Assert.Equal(expected, actual);
        }
コード例 #13
0
    public void ConstructorWithNameAndValueTest()
    {
      // arrange
      TagByteArray tag;
      string name;
      byte[] value;

      name = "creationDate";
      value = new[] { byte.MinValue, byte.MaxValue };

      // act
      tag = new TagByteArray(name, value);

      // assert
      Assert.AreEqual(name, tag.Name);
      CollectionAssert.AreEqual(value, tag.Value);
    }
コード例 #14
0
    public void ConstructorWithNameTest()
    {
      // arrange
      TagByteArray tag;
      string name;
      byte[] expected;

      name = "creationDate";
      expected = new byte[0];

      // act
      tag = new TagByteArray(name);

      // assert
      Assert.AreEqual(name, tag.Name);
      CollectionAssert.AreEqual(expected, tag.Value);
    }
コード例 #15
0
        public void GetHashCode_returns_same_value_for_matching_tags()
        {
            // arrange
            TagByteArray target;
            int          actual;
            int          expected;

            target = new TagByteArray("beta", new byte[] { 2, 4, 8, 16, 32, 64, 128 });

            expected = new TagByteArray("beta", new byte[] { 2, 4, 8, 16, 32, 64, 128 }).GetHashCode();

            // act
            actual = target.GetHashCode();

            // assert
            Assert.Equal(expected, actual);
        }
コード例 #16
0
        public void ToValueString_returns_string_version_of_value()
        {
            // arrange
            TagByteArray target;
            string       expected;
            string       actual;

            expected = "02, 04, 08, 10, 20, 40, 80";

            target = new TagByteArray(string.Empty, new byte[] { 2, 4, 8, 16, 32, 64, 128 });

            // act
            actual = target.ToValueString();

            // assert
            Assert.Equal(expected, actual);
        }
コード例 #17
0
        public void Constructor_sets_value_without_name()
        {
            // arrange
            TagByteArray target;

            byte[] expected;
            byte[] actual;

            expected = new byte[] { 2, 4, 8, 16, 32, 64, 128 };

            // act
            target = new TagByteArray(expected);

            // assert
            actual = target.Value;
            Assert.Equal(expected, actual);
        }
コード例 #18
0
        public void Constructor_sets_default_value()
        {
            // arrange
            TagByteArray target;

            byte[] expected;
            byte[] actual;

            expected = new byte[0];

            // act
            target = new TagByteArray();

            // assert
            actual = target.Value;
            Assert.Equal(expected, actual);
        }
コード例 #19
0
        public override object ParsePayload(Stream stream, INamedBinaryTag iTag)
        {
            TagByteArray tag = iTag as TagByteArray;

            byte[] count_b = new byte[4];
            stream.Read(count_b, 0, 4);
            count_b = count_b.ReverseIfLittleEndian();
            int count = BitConverter.ToInt32(count_b, 0);

            for (int i = 0; i < count; i++)
            {
                byte  b  = stream.ReadSingleByte();
                sbyte sb = unchecked ((sbyte)b);
                tag.Add(sb);
            }

            return(tag.Values);
        }
コード例 #20
0
        public void SetValue_updates_value()
        {
            // arrange
            Tag target;

            byte[] expected;
            byte[] actual;

            target = new TagByteArray();

            expected = new byte[] { 2, 4, 8, 16, 32, 64, 128 };

            // act
            target.SetValue(expected);

            // assert
            actual = ((TagByteArray)target).Value;
            Assert.Equal(expected, actual);
        }
コード例 #21
0
        public void Value_can_be_set()
        {
            // arrange
            TagByteArray target;

            byte[] expected;
            byte[] actual;

            expected = new byte[] { 2, 4, 8, 16, 32, 64, 128 };

            target = new TagByteArray();

            // act
            target.Value = expected;

            // assert
            actual = target.Value;
            Assert.Equal(expected, actual);
        }
コード例 #22
0
        /// <summary>
        /// 获取nbt数据从md5和salt
        /// </summary>
        public static byte[] GetMd5NBTByteArray(bool isUseRSA, List <string> md5s, string salt, bool is112)
        {
            TagCompound tagCompound = new TagCompound();
            TagList     tagList     = new TagList();

            foreach (string md5 in md5s)
            {
                string newMd5   = EncryptionUtil.MD5(md5 + salt);
                byte[] md5bytes = Encoding.UTF8.GetBytes(newMd5);
                if (isUseRSA)
                {
                    md5bytes = ASACUtil.RSAEncodeMD5(md5bytes);
                }
                TagByteArray byteArray = new TagByteArray(md5bytes);
                tagList.Add(byteArray);
            }
            tagCompound.Add("md5s", tagList);

            MemoryStream tagCompoundMS = new MemoryStream();

            NBTFile.ToStream(tagCompoundMS, tagCompound, !is112);
            byte[] tagCompoundByteArray = tagCompoundMS.ToArray();
            return(tagCompoundByteArray);
        }
コード例 #23
0
    public void ToStringTest()
    {
      // arrange
      TagByteArray target;
      string expected;
      string actual;
      string name;
      byte[] value;

      name = "tagname";
      value = new[] { byte.MinValue, byte.MaxValue };
      expected = string.Format("[ByteArray: {0}={1} values]", name, value.Length);
      target = new TagByteArray(name, value);

      // act
      actual = target.ToString();

      // assert
      Assert.AreEqual(expected, actual);
    }
コード例 #24
0
    public void NameTest()
    {
      // arrange
      TagByteArray target;
      string expected;

      target = new TagByteArray();
      expected = "newvalue";

      // act
      target.Name = expected;

      // assert
      Assert.AreEqual(expected, target.Name);
    }
コード例 #25
0
            private void _read()
            {
                _type = ((MinecraftNbt.Tag)m_io.ReadU1());
                if (!(IsTagEnd))
                {
                    _name = new TagString(m_io, this, m_root);
                }
                if (!(IsTagEnd))
                {
                    switch (Type)
                    {
                    case MinecraftNbt.Tag.LongArray: {
                        _payload = new TagLongArray(m_io, this, m_root);
                        break;
                    }

                    case MinecraftNbt.Tag.Compound: {
                        _payload = new TagCompound(m_io, this, m_root);
                        break;
                    }

                    case MinecraftNbt.Tag.Double: {
                        _payload = m_io.ReadF8be();
                        break;
                    }

                    case MinecraftNbt.Tag.List: {
                        _payload = new TagList(m_io, this, m_root);
                        break;
                    }

                    case MinecraftNbt.Tag.Float: {
                        _payload = m_io.ReadF4be();
                        break;
                    }

                    case MinecraftNbt.Tag.Short: {
                        _payload = m_io.ReadS2be();
                        break;
                    }

                    case MinecraftNbt.Tag.Int: {
                        _payload = m_io.ReadS4be();
                        break;
                    }

                    case MinecraftNbt.Tag.ByteArray: {
                        _payload = new TagByteArray(m_io, this, m_root);
                        break;
                    }

                    case MinecraftNbt.Tag.Byte: {
                        _payload = m_io.ReadS1();
                        break;
                    }

                    case MinecraftNbt.Tag.IntArray: {
                        _payload = new TagIntArray(m_io, this, m_root);
                        break;
                    }

                    case MinecraftNbt.Tag.String: {
                        _payload = new TagString(m_io, this, m_root);
                        break;
                    }

                    case MinecraftNbt.Tag.Long: {
                        _payload = m_io.ReadS8be();
                        break;
                    }
                    }
                }
            }
コード例 #26
0
ファイル: NbtJsonReader.cs プロジェクト: einsteinsci/nbt-io
 public static void Serialize(JsonWriter writer, TagByteArray array)
 {
     writer.WriteStartArray();
     foreach (sbyte sb in array)
     {
         writer.WriteValue(sb);
     }
     writer.WriteEndArray();
 }
コード例 #27
0
        public void TestLoadComplexNbt()
        {
            Tag tag;

            tag = this.CreateComplexData();

            Assert.IsNotNull(tag);
            Assert.IsInstanceOf <TagCompound>(tag);
            TagCompound level = tag as TagCompound;

            Assert.AreEqual("Level", level.Name);

            TagShort shortTest = level.GetShort("shortTest");

            Assert.IsNotNull(shortTest);
            Assert.AreEqual("shortTest", shortTest.Name);
            Assert.AreEqual(32767, shortTest.Value);

            TagLong longTest = level.GetLong("longTest");

            Assert.IsNotNull(longTest);
            Assert.AreEqual("longTest", longTest.Name);
            Assert.AreEqual(9223372036854775807, longTest.Value);

            TagFloat floatTest = level.GetFloat("floatTest");

            Assert.IsNotNull(floatTest);
            Assert.AreEqual("floatTest", floatTest.Name);
            Assert.AreEqual(0.49823147f, floatTest.Value);

            TagString stringTest = level.GetString("stringTest");

            Assert.IsNotNull(stringTest);
            Assert.AreEqual("stringTest", stringTest.Name);
            Assert.AreEqual("HELLO WORLD THIS IS A TEST STRING едж!", stringTest.Value);

            TagInt intTest = level.GetInt("intTest");

            Assert.IsNotNull(intTest);
            Assert.AreEqual("intTest", intTest.Name);
            Assert.AreEqual(2147483647, intTest.Value);

            TagCompound nestedCompoundTest = level.GetCompound("nested compound test");

            Assert.IsNotNull(nestedCompoundTest);
            Assert.AreEqual("nested compound test", nestedCompoundTest.Name);

            TagCompound ham = nestedCompoundTest.GetCompound("ham");

            Assert.IsNotNull(ham);
            Assert.AreEqual("ham", ham.Name);

            TagString ham_name = ham.GetString("name");

            Assert.IsNotNull(ham_name);
            Assert.AreEqual("name", ham_name.Name);
            Assert.AreEqual("Hampus", ham_name.Value);

            TagFloat ham_value = ham.GetFloat("value");

            Assert.IsNotNull(ham_value);
            Assert.AreEqual("value", ham_value.Name);
            Assert.AreEqual(0.75f, ham_value.Value);

            TagCompound egg = nestedCompoundTest.GetCompound("egg");

            Assert.IsNotNull(egg);
            Assert.AreEqual("egg", egg.Name);

            TagString egg_name = egg.GetString("name");

            Assert.IsNotNull(egg_name);
            Assert.AreEqual("name", egg_name.Name);
            Assert.AreEqual("Eggbert", egg_name.Value);

            TagFloat egg_value = egg.GetFloat("value");

            Assert.IsNotNull(egg_value);
            Assert.AreEqual("value", egg_value.Name);
            Assert.AreEqual(0.5f, egg_value.Value);

            TagByte byteTest = level.GetByte("byteTest");

            Assert.IsNotNull(byteTest);
            Assert.AreEqual("byteTest", byteTest.Name);
            Assert.AreEqual(0x7f, byteTest.Value);

            TagDouble doubleTest = level.GetDouble("doubleTest");

            Assert.IsNotNull(doubleTest);
            Assert.AreEqual("doubleTest", doubleTest.Name);
            Assert.AreEqual(0.4931287132182315, doubleTest.Value);

            TagList listTest_long = level.GetList("listTest (long)");

            Assert.IsNotNull(listTest_long);
            Assert.AreEqual("listTest (long)", listTest_long.Name);
            Assert.IsNotNull(listTest_long.Value);
            Assert.AreEqual(5, listTest_long.Value.Count);
            Assert.AreEqual(11, (listTest_long.Value[0] as TagLong).Value);
            Assert.AreEqual(12, (listTest_long.Value[1] as TagLong).Value);
            Assert.AreEqual(13, (listTest_long.Value[2] as TagLong).Value);
            Assert.AreEqual(14, (listTest_long.Value[3] as TagLong).Value);
            Assert.AreEqual(15, (listTest_long.Value[4] as TagLong).Value);

            TagList listTest_compound = level.GetList("listTest (compound)");

            Assert.IsNotNull(listTest_compound);
            Assert.AreEqual("listTest (compound)", listTest_compound.Name);
            Assert.IsNotNull(listTest_compound.Value);
            Assert.AreEqual(2, listTest_compound.Value.Count);
            TagCompound listTest_compound_tag0 = listTest_compound.Value[0] as TagCompound;

            Assert.IsNotNull(listTest_compound_tag0);
            TagString listTest_compound_tag0_name = listTest_compound_tag0.GetString("name");

            Assert.IsNotNull(listTest_compound_tag0_name);
            Assert.AreEqual("name", listTest_compound_tag0_name.Name);
            Assert.AreEqual("Compound tag #0", listTest_compound_tag0_name.Value);
            TagLong listTest_compound_tag0_createdOn = listTest_compound_tag0.GetLong("created-on");

            Assert.IsNotNull(listTest_compound_tag0_createdOn);
            Assert.AreEqual("created-on", listTest_compound_tag0_createdOn.Name);
            Assert.AreEqual(1264099775885, listTest_compound_tag0_createdOn.Value);

            TagCompound listTest_compound_tag1 = listTest_compound.Value[1] as TagCompound;

            Assert.IsNotNull(listTest_compound_tag1);
            TagString listTest_compound_tag1_name = listTest_compound_tag1.GetString("name");

            Assert.IsNotNull(listTest_compound_tag1_name);
            Assert.AreEqual("name", listTest_compound_tag1_name.Name);
            Assert.AreEqual("Compound tag #1", listTest_compound_tag1_name.Value);
            TagLong listTest_compound_tag1_createdOn = listTest_compound_tag1.GetLong("created-on");

            Assert.IsNotNull(listTest_compound_tag1_createdOn);
            Assert.AreEqual("created-on", listTest_compound_tag1_createdOn.Name);
            Assert.AreEqual(1264099775885, listTest_compound_tag1_createdOn.Value);

            TagByteArray byteArrayTest = level.GetByteArray("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))");

            Assert.IsNotNull(byteArrayTest);
            Assert.AreEqual("byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))", byteArrayTest.Name);
            Assert.IsNotNull(byteArrayTest.Value);
            Assert.AreEqual(1000, byteArrayTest.Value.Length);
        }
コード例 #28
0
    public void TypeTest()
    {
      // arrange
      TagType expected;
      TagType actual;

      expected = TagType.ByteArray;

      // act
      actual = new TagByteArray().Type;

      // assert
      Assert.AreEqual(expected, actual);
    }
コード例 #29
0
    public void ValueTest()
    {
      // arrange
      TagByteArray target;
      byte[] expected;

      target = new TagByteArray();
      expected = new[] { byte.MinValue, byte.MaxValue };

      // act
      target.Value = expected;

      // assert
      CollectionAssert.AreEqual(expected, target.Value);
    }
コード例 #30
0
        public void TestAnvilRegion()
        {
            string     filename = this.AnvilRegionFileName;
            FileStream input    = File.OpenRead(filename);

            int[]  locations = new int[1024];
            byte[] buffer    = new byte[4096];
            input.Read(buffer, 0, 4096);
            for (int i = 0; i < 1024; i++)
            {
                locations[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            int[] timestamps = new int[1024];
            input.Read(buffer, 0, 4096);
            for (int i = 0; i < 1024; i++)
            {
                timestamps[i] = BitConverter.ToInt32(buffer, i * 4);
            }

            input.Read(buffer, 0, 4);
            if (BitConverter.IsLittleEndian)
            {
                BitHelper.SwapBytes(buffer, 0, 4);
            }
            int sizeOfChunkData = BitConverter.ToInt32(buffer, 0) - 1;

            int compressionType = input.ReadByte();

            buffer = new byte[sizeOfChunkData];
            input.Read(buffer, 0, sizeOfChunkData);

            Stream inputStream = null;

            if (compressionType == 1)
            {
                inputStream = new GZipStream(new MemoryStream(buffer), CompressionMode.Decompress);
            }
            else if (compressionType == 2)
            {
                inputStream = new DeflateStream(new MemoryStream(buffer, 2, buffer.Length - 6), CompressionMode.Decompress);
            }

            TagReader reader;

            reader = new BinaryTagReader(inputStream);
            TagCompound tag    = (TagCompound)reader.ReadTag();
            string      strTag = tag.ToString();

            Assert.IsNotNull(tag);

            Assert.AreEqual(TagType.Compound, tag.GetTag("Level").Type);
            TagCompound levelTag = tag.GetCompound("Level");

            Tag aTag = levelTag.GetTag("Entities");

            Assert.AreEqual(TagType.List, aTag.Type);
            TagList entitiesTag = aTag as TagList;

            Assert.AreEqual(0, entitiesTag.Value.Count);

            aTag = levelTag.GetTag("Biomes");
            Assert.AreEqual(TagType.ByteArray, aTag.Type);
            TagByteArray biomesTag = aTag as TagByteArray;

            Assert.AreEqual(256, biomesTag.Value.Length);

            aTag = levelTag.GetTag("LastUpdate");
            Assert.AreEqual(TagType.Long, aTag.Type);
            TagLong lastUpdateTag = aTag as TagLong;

            Assert.AreEqual(2861877, lastUpdateTag.Value);

            aTag = levelTag.GetTag("xPos");
            Assert.AreEqual(TagType.Int, aTag.Type);
            TagInt xPosTag = aTag as TagInt;

            Assert.AreEqual(10, xPosTag.Value);

            aTag = levelTag.GetTag("zPos");
            Assert.AreEqual(TagType.Int, aTag.Type);
            TagInt zPosTag = aTag as TagInt;

            Assert.AreEqual(0, zPosTag.Value);

            aTag = levelTag.GetTag("TileEntities");
            Assert.AreEqual(TagType.List, aTag.Type);
            TagList tileEntitiesTag = aTag as TagList;

            Assert.AreEqual(0, tileEntitiesTag.Value.Count);

            aTag = levelTag.GetTag("TerrainPopulated");
            Assert.AreEqual(TagType.Byte, aTag.Type);
            TagByte terrainPopulatedTag = aTag as TagByte;

            Assert.AreEqual(1, terrainPopulatedTag.Value);

            aTag = levelTag.GetTag("HeightMap");
            Assert.AreEqual(TagType.IntArray, aTag.Type);
            TagIntArray heightmapTag = aTag as TagIntArray;

            Assert.AreEqual(256, heightmapTag.Value.Length);

            aTag = levelTag.GetTag("Sections");
            Assert.AreEqual(TagType.List, aTag.Type);
            TagList sectionsTag = aTag as TagList;

            Assert.AreEqual(4, sectionsTag.Value.Count);

            TagCompound section_0 = sectionsTag.Value[0] as TagCompound;

            Assert.IsNotNull(section_0);
            TagByteArray section_0_data = section_0.GetByteArray("Data");

            Assert.IsNotNull(section_0_data);
            Assert.AreEqual(2048, section_0_data.Value.Length);
            TagByteArray section_0_skyLight = section_0.GetByteArray("SkyLight");

            Assert.IsNotNull(section_0_skyLight);
            Assert.AreEqual(2048, section_0_skyLight.Value.Length);
            TagByteArray section_0_blockLight = section_0.GetByteArray("BlockLight");

            Assert.IsNotNull(section_0_blockLight);
            Assert.AreEqual(2048, section_0_blockLight.Value.Length);
            TagByte section_0_y = section_0.GetByte("Y");

            Assert.IsNotNull(section_0_y);
            Assert.AreEqual(0, section_0_y.Value);
            TagByteArray section_0_blocks = section_0.GetByteArray("Blocks");

            Assert.IsNotNull(section_0_blocks);
            Assert.AreEqual(4096, section_0_blocks.Value.Length);

            TagCompound section_1 = sectionsTag.Value[1] as TagCompound;

            Assert.IsNotNull(section_1);
            TagByteArray section_1_data = section_1.GetByteArray("Data");

            Assert.IsNotNull(section_1_data);
            Assert.AreEqual(2048, section_1_data.Value.Length);
            TagByteArray section_1_skyLight = section_1.GetByteArray("SkyLight");

            Assert.IsNotNull(section_1_skyLight);
            Assert.AreEqual(2048, section_1_skyLight.Value.Length);
            TagByteArray section_1_blockLight = section_1.GetByteArray("BlockLight");

            Assert.IsNotNull(section_1_blockLight);
            Assert.AreEqual(2048, section_1_blockLight.Value.Length);
            TagByte section_1_y = section_1.GetByte("Y");

            Assert.IsNotNull(section_1_y);
            Assert.AreEqual(1, section_1_y.Value);
            TagByteArray section_1_blocks = section_1.GetByteArray("Blocks");

            Assert.IsNotNull(section_1_blocks);
            Assert.AreEqual(4096, section_1_blocks.Value.Length);

            TagCompound section_2 = sectionsTag.Value[2] as TagCompound;

            Assert.IsNotNull(section_2);
            TagByteArray section_2_data = section_2.GetByteArray("Data");

            Assert.IsNotNull(section_2_data);
            Assert.AreEqual(2048, section_2_data.Value.Length);
            TagByteArray section_2_skyLight = section_2.GetByteArray("SkyLight");

            Assert.IsNotNull(section_2_skyLight);
            Assert.AreEqual(2048, section_2_skyLight.Value.Length);
            TagByteArray section_2_blockLight = section_2.GetByteArray("BlockLight");

            Assert.IsNotNull(section_2_blockLight);
            Assert.AreEqual(2048, section_2_blockLight.Value.Length);
            TagByte section_2_y = section_2.GetByte("Y");

            Assert.IsNotNull(section_2_y);
            Assert.AreEqual(2, section_2_y.Value);
            TagByteArray section_2_blocks = section_2.GetByteArray("Blocks");

            Assert.IsNotNull(section_2_blocks);
            Assert.AreEqual(4096, section_2_blocks.Value.Length);

            TagCompound section_3 = sectionsTag.Value[3] as TagCompound;

            Assert.IsNotNull(section_3);
            TagByteArray section_3_data = section_3.GetByteArray("Data");

            Assert.IsNotNull(section_3_data);
            Assert.AreEqual(2048, section_3_data.Value.Length);
            TagByteArray section_3_skyLight = section_3.GetByteArray("SkyLight");

            Assert.IsNotNull(section_3_skyLight);
            Assert.AreEqual(2048, section_3_skyLight.Value.Length);
            TagByteArray section_3_blockLight = section_3.GetByteArray("BlockLight");

            Assert.IsNotNull(section_3_blockLight);
            Assert.AreEqual(2048, section_3_blockLight.Value.Length);
            TagByte section_3_y = section_3.GetByte("Y");

            Assert.IsNotNull(section_3_y);
            Assert.AreEqual(3, section_3_y.Value);
            TagByteArray section_3_blocks = section_3.GetByteArray("Blocks");

            Assert.IsNotNull(section_3_blocks);
            Assert.AreEqual(4096, section_3_blocks.Value.Length);
        }
コード例 #31
0
    public void ToValueStringTest()
    {
      // arrange
      ITag target;
      string expected;
      string actual;
      byte[] value;

      value = new[]
              {
                byte.MinValue,
                byte.MaxValue
              };
      expected = "00, FF";
      target = new TagByteArray(value);

      // act
      actual = target.ToValueString();

      // assert
      Assert.AreEqual(expected, actual);
    }