}
}
+ class ReadStringMockStream : Stream
+ {
+ int noc;
+
+ #region implemented abstract members of Stream
+
+ public override void Flush ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override int Read (byte[] buffer, int offset, int count)
+ {
+ switch (noc++) {
+ case 0:
+ buffer [0] = 42; // Length
+ return 2;
+ default:
+ buffer [0] = 0x65;
+ return 1;
+ }
+ }
+
+ public override long Seek (long offset, SeekOrigin origin)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void SetLength (long value)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override void Write (byte[] buffer, int offset, int count)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool CanRead {
+ get {
+ return true;
+ }
+ }
+
+ public override bool CanSeek {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override bool CanWrite {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override long Length {
+ get {
+ throw new NotImplementedException ();
+ }
+ }
+
+ public override long Position {
+ get {
+ throw new NotImplementedException ();
+ }
+ set {
+ throw new NotImplementedException ();
+ }
+ }
+
+ #endregion
+ }
+
+ [Test]
+ public void ReadSting_CustomStream ()
+ {
+ var sr = new BinaryReader (new ReadStringMockStream ());
+ var s = sr.ReadString ();
+ Assert.AreEqual ("eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", s);
+ }
+
[Test]
public void ReadOverrides ()
{