public void CloseStreamValidation() { byte[] buffer = Encoding.UTF8.GetBytes("some data"); Stream stream = new BinaryData(buffer).ToStream(); stream.Dispose(); Assert.Throws <ObjectDisposedException>(() => stream.Position = -1); Assert.Throws <ObjectDisposedException>(() => stream.Position); Assert.Throws <ObjectDisposedException>(() => stream.Seek(0, SeekOrigin.Begin)); Assert.Throws <ObjectDisposedException>(() => stream.Read(buffer, 0, buffer.Length)); Assert.ThrowsAsync <ObjectDisposedException>(() => stream.ReadAsync(buffer, 0, buffer.Length)); Assert.Throws <ObjectDisposedException>(() => stream.ReadByte()); Assert.Throws <ObjectDisposedException>(() => stream.Length); Assert.False(stream.CanRead); Assert.False(stream.CanSeek); }