public void ReadWrongByteArray() { var bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, }; var memory = new FastMemoryWriter(); memory.WriteByteArray(bytes); memory.SetLength(9); memory.Seek(0, SeekOrigin.Begin); var reader = new FastReader(memory); Assert.Throws <EndOfStreamException>(() => reader.ReadByteArray()); }
public void ReadByteArray() { var bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, }; var memory = new FastMemoryWriter(); memory.WriteByteArray(bytes); memory.Seek(0, SeekOrigin.Begin); var reader = new FastReader(memory); var result = reader.ReadByteArray(); Assert.True(result.SequenceEqual(bytes)); }