示例#1
0
		public void ReadIntArray_ObjectDisposedException()
		{
			// Arrange
			NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x0B, 0x00, 0x04 };
			byte[] data = new byte[] 
			{ 
				0x61, 0x73, 0x64, 0x66, // "asdf"
				0x00, 0x00, 0x00, 0x04, // size: 4
				0x00, 0x00, 0x30, 0x39, 
				0x00, 0x00, 0x05, 0x39, 
				0x07, 0x5B, 0xCD, 0x15, 
				0x03, 0x4F, 0xB5, 0xE3
			};

			MemoryStream stream = new MemoryStream(data);

			NbtReader reader = new NbtReader(stream);

			stream.Close();

			// Act
			NbtIntArray result = reader.ReadIntArray(tagInfo);
		}
示例#2
0
		public void ReadIntArray_EndOfStreamException()
		{
			// Arrange
			NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x0B, 0x00, 0x04 };
			byte[] data = new byte[] { 0x61, 0x73 };

			MemoryStream stream = new MemoryStream(data);

			NbtReader reader = new NbtReader(stream);

			// Act
			NbtIntArray result = reader.ReadIntArray(tagInfo);
		}
示例#3
0
		public void ReadIntArray_Normal()
		{
			// Arrange
			NbtTagInfo tagInfo = (NbtTagInfo)new byte[] { 0x0B, 0x00, 0x04 };
			byte[] data = new byte[] 
			{ 
				0x61, 0x73, 0x64, 0x66, // "asdf"
				0x00, 0x00, 0x00, 0x04, // size: 4
				0x00, 0x00, 0x30, 0x39, 
				0x00, 0x00, 0x05, 0x39, 
				0x07, 0x5B, 0xCD, 0x15, 
				0x03, 0x4F, 0xB5, 0xE3
			};

			MemoryStream stream = new MemoryStream(data);

			NbtReader reader = new NbtReader(stream);

			NbtTagType expectedTagType = NbtTagType.IntArray;
			string expectedName = "asdf";
			int[] expectedValue = new int[] { 12345, 1337, 123456789, 55555555 };

			// Act
			NbtIntArray result = reader.ReadIntArray(tagInfo);

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