示例#1
0
 public void CachingStreamFailsToSetLengthTest()
 {
     using (var sourceStream = TestHelpers.GetResourceStream(ResourceName))
     {
         using (var cachingStream = new CachingStream(sourceStream))
         {
             Assert.Throws <NotSupportedException>
             (
                 () => { cachingStream.SetLength(100); }
             );
         }
     }
 }
        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));
                }
        }