public void Write() { var data = GenerateData(1000); using (var memoryStream = new MemoryStream(data, writable: true)) using (var cachingStream = new CachingStream(memoryStream, Ownership.Owns)) { Assert.IsFalse(cachingStream.CanWrite); Assert.Throws <NotSupportedException>(() => cachingStream.SetLength(2000)); Assert.Throws <NotSupportedException>(() => cachingStream.Write(new byte[1], 0, 1)); Assert.Throws <NotSupportedException>(() => cachingStream.WriteByte(1)); Assert.Throws <NotSupportedException>(() => cachingStream.BeginWrite(new byte[1], 0, 1, null !, null)); Assert.Throws <NotSupportedException>(() => cachingStream.WriteAsync(new byte[1], 0, 1)); } }