Exemplo n.º 1
0
        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));
                }
        }
Exemplo n.º 2
0
        public void CachingStreamFailsToWriteTest()
        {
            using (var sourceStream = TestHelpers.GetResourceStream(ResourceName))
            {
                using (var cachingStream = new CachingStream(sourceStream))
                {
                    byte[] buffer = { 0, 1 };

                    Assert.Throws <NotSupportedException>
                    (
                        () => { cachingStream.Write(buffer, 0, buffer.Length); }
                    );
                }
            }
        }