public void Dispose() { var data = GenerateData(1000); using (var memoryStream = new MemoryStream(data, writable: false)) using (var cachingStream = new CachingStream(memoryStream, Ownership.Owns)) { cachingStream.Dispose(); Assert.Throws <ObjectDisposedException>(() => { cachingStream.Flush(); }); Assert.Throws <ObjectDisposedException>(() => { var temp = cachingStream.Length; }); Assert.Throws <ObjectDisposedException>(() => { var temp = cachingStream.Position; }); Assert.Throws <ObjectDisposedException>(() => { cachingStream.Position = 1; }); Assert.Throws <ObjectDisposedException>(() => cachingStream.ReadByte()); Assert.Throws <ObjectDisposedException>(() => cachingStream.Read(new byte[10], 0, 1)); Assert.Throws <ObjectDisposedException>(() => cachingStream.Seek(1, SeekOrigin.Begin)); } }