public virtual void Load(NbtReader reader, INbtContainerNode parent) { Parent = parent; if (parent == null || parent.Type != NbtType.List) { reader.ReadType(); // Skip type byte Name = reader.ReadString(); } }
public void ReadString_EndOfStreamException() { // Arrange NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x08, 0x00, 0x04 }; byte[] data = new byte[] { 0x61, 0x73 }; MemoryStream stream = new MemoryStream(data); NbtReader reader = new NbtReader(stream); // Act NbtString result = reader.ReadString(tagInfo); }
public void ReadString_Normal() { // Arrange NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x08, 0x00, 0x04 }; byte[] data = new byte[] { 0x61, 0x73, 0x64, 0x66, 0x00, 0x04, 0x6A, 0x6B, 0x6C, 0x3B }; MemoryStream stream = new MemoryStream(data); NbtReader reader = new NbtReader(stream); NbtTagType expectedTagType = NbtTagType.String; string expectedName = "asdf"; string expectedValue = "jkl;"; // Act NbtString result = reader.ReadString(tagInfo); // Assert Assert.AreEqual(expectedName, result.Name); Assert.AreEqual(expectedTagType, result.Type); Assert.AreEqual(expectedValue, result.Value); }
public void ReadString_ObjectDisposedException() { // Arrange NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x08, 0x00, 0x04 }; byte[] data = new byte[] { 0x61, 0x73, 0x64, 0x66, 0x00, 0x04, 0x6A, 0x6B, 0x6C, 0x3B }; MemoryStream stream = new MemoryStream(data); NbtReader reader = new NbtReader(stream); stream.Close(); // Act NbtString result = reader.ReadString(tagInfo); }
public override void Load(NbtReader reader, INbtContainerNode parent) { base.Load(reader, parent); Value = reader.ReadString(); }