/// <summary> /// Creates a new instance of the class with the specified parameters. /// </summary> /// <param name="data">An array of byte containing the raw data for the </param> /// <param name="size">A VariableIntegerSize indicating the size of the variable integer.</param> /// <param name="data8">A byte indicating the 8-bit value of the variable integer.</param> /// <param name="data16">A short indicating the 16-bit value of the variable integer.</param> /// <param name="data32">An int indicating the 32-bit value of the variable integer.</param> /// <param name="data64">A long indicating the 64-bit value of the variable integer.</param> public VarInt(VariableIntegerSize size, byte data8, short data16, int data32, long data64) { Size = size; AsInt8 = data8; AsInt16 = data16; AsInt32 = data32; AsInt64 = data64; }
private void ParseAndCheckValues(byte[] data, VariableIntegerSize size, byte int8, short int16, int int32, long int64) { VarInt varInt; varInt = VarIntParser.Parse(data); Assert.IsNotNull(varInt); CheckValues(varInt, size, int8, int16, int32, int64); }
private void CheckValues(VarInt source, VariableIntegerSize size, byte int8, short int16, int int32, long int64) { Assert.AreEqual(source.Size, size); Assert.AreEqual(source.AsInt8, int8); Assert.AreEqual(source.AsInt16, int16); Assert.AreEqual(source.AsInt32, int32); Assert.AreEqual(source.AsInt64, int64); }
private void ParseAndCheckValuesAsStream(byte[] data, VariableIntegerSize size, byte int8, short int16, int int32, long int64) { VarInt varInt; using MemoryStream stream = new MemoryStream(data); varInt = VarIntParser.Parse(stream); Assert.IsNotNull(varInt); CheckValues(varInt, size, int8, int16, int32, int64); }