public void ReadOnEmpty() { var text = "JonnoJ"; var stream = new FastMemoryWriter(); stream.Write(text); stream.Seek(0, System.IO.SeekOrigin.Begin); var result = new byte[stream.Length]; var read = stream.Read(result, 0, result.Length); Assert.Equal(result.Length, read); read = stream.Read(result, 0, result.Length); Assert.Equal(0, read); }
public void Bytes() { var bytes = new byte[] { 10, 10, 11, 12 }; var writer = new FastMemoryWriter(); writer.Write(bytes); writer.Seek(0, SeekOrigin.Begin); var result = new byte[4]; writer.Read(result); Assert.True(bytes.SequenceEqual(result)); }
public void Read() { var text = "JonnoJ"; var textBytes = Encoding.UTF8.GetBytes(text); var stream = new FastMemoryWriter(); stream.Write(text); stream.Seek(0, System.IO.SeekOrigin.Begin); var result = new byte[stream.Length]; stream.Read(result, 0, result.Length); // skip string length Assert.True(textBytes.SequenceEqual(result.Skip(4))); }