public void SerializeArrays() { // Write data ------------------------------------- var arrayUInt16 = new UInt16[] { 0, 900, 32000 }; _serializer.Writer.WriteUInt16Array(arrayUInt16); AssertBytesWritten(8); var arrayUInt32 = new UInt32[] { 0, 900, 32000 }; _serializer.Writer.WriteUInt32Array(arrayUInt32); AssertBytesWritten(14); var arrayInt16 = new Int16[] { -700, 0, 32000 }; _serializer.Writer.WriteInt16Array(arrayInt16); AssertBytesWritten(8); var arrayInt32 = new Int32[] { -700, 0, 32000 }; _serializer.Writer.WriteInt32Array(arrayInt32); AssertBytesWritten(14); var arrayInt64 = new Int64[] { -700, 0, 32000 }; _serializer.Writer.WriteInt64Array(arrayInt64); AssertBytesWritten(26); _serializer.Writer.WriteUInt16Array(null); AssertBytesWritten(1); _serializer.Writer.WriteUInt32Array(null); AssertBytesWritten(1); _serializer.Writer.WriteInt16Array(null); AssertBytesWritten(1); _serializer.Writer.WriteInt32Array(null); AssertBytesWritten(1); _serializer.Writer.WriteInt64Array(null); AssertBytesWritten(1); // Message end _serializer.Writer.Internal.WriteDataUInt(Bms1Tag.MessageEnd, 0); AssertBytesWritten(1); // Read and verify data ---------------------------------------- _stream.Position = 0; _serializer.Reader.Internal.ReadAttributes(); Assert.IsTrue(arrayUInt16.SequenceEqual(_serializer.Reader.ReadUInt16Array())); Assert.IsTrue(arrayUInt32.SequenceEqual(_serializer.Reader.ReadUInt32Array())); Assert.IsTrue(arrayInt16.SequenceEqual(_serializer.Reader.ReadInt16Array())); Assert.IsTrue(arrayInt32.SequenceEqual(_serializer.Reader.ReadInt32Array())); Assert.IsTrue(arrayInt64.SequenceEqual(_serializer.Reader.ReadInt64Array())); Assert.IsNull(_serializer.Reader.ReadUInt16Array()); Assert.IsNull(_serializer.Reader.ReadUInt32Array()); Assert.IsNull(_serializer.Reader.ReadInt16Array()); Assert.IsNull(_serializer.Reader.ReadInt32Array()); Assert.IsNull(_serializer.Reader.ReadInt64Array()); // Message end Assert.IsTrue(_serializer.Reader.Internal.EndOfBlock); }