示例#1
0
		public void ReadByteArray_ObjectDisposedException()
		{
			// Arrange
			NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x07, 0x00, 0x04 };
			byte[] data = new byte[] { 0x61, 0x73, 0x64, 0x66, 0x00, 0x00, 0x00, 0x04, 0x6A, 0x6B, 0x6C, 0x3B };

			MemoryStream stream = new MemoryStream(data);

			NbtReader reader = new NbtReader(stream);

			stream.Close();

			// Act
			NbtByteArray result = reader.ReadByteArray(tagInfo);
		}
示例#2
0
		public void ReadByteArray_EndOfStreamException()
		{
			// Arrange
			NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x07, 0x00, 0x04 };
			byte[] data = new byte[] { 0x61, 0x73 };

			MemoryStream stream = new MemoryStream(data);

			NbtReader reader = new NbtReader(stream);

			// Act
			NbtByteArray result = reader.ReadByteArray(tagInfo);
		}
示例#3
0
		public void ReadByteArray_Normal()
		{
			// Arrange
			NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x07, 0x00, 0x04 };
			byte[] data = new byte[] { 0x61, 0x73, 0x64, 0x66, 0x00, 0x00, 0x00, 0x04, 0x6A, 0x6B, 0x6C, 0x3B };

			MemoryStream stream = new MemoryStream(data);

			NbtReader reader = new NbtReader(stream);

			NbtTagType expectedTagType = NbtTagType.ByteArray;
			string expectedName = "asdf";
			byte[] expectedValue = new byte[] { 0x6A, 0x6B, 0x6C, 0x3B };

			// Act
			NbtByteArray result = reader.ReadByteArray(tagInfo);

			// Assert
			Assert.AreEqual(expectedName, result.Name);
			Assert.AreEqual(expectedTagType, result.Type);
			CollectionAssert.AreEquivalent(expectedValue, result.Value);
		}