예제 #1
0
        public void StreamNotDisposed()
        {
            var cache    = CreateCache();
            var fileSize = 10 * 1024 * 1024;

            var stream = new AssertStream(fileSize, 42);

            cache.AddOrUpdateStream(123, stream, CancellationToken.None, null, leaveOpen: true);

            Assert.IsFalse(stream.Closed);
            Assert.IsFalse(stream.Disposed);
        }
예제 #2
0
        public void StreamDisposed()
        {
            var cache    = CreateCache();
            var fileSize = 10 * 1024 * 1024;

            var stream = new AssertStream(fileSize, 42);

            using (var cachedStream = cache.GetStreamOrAddStream(123, _ => stream,
                                                                 CancellationToken.None, null))
            {
                cachedStream.ReadByte();
            }

            Assert.IsTrue(stream.Closed);
            Assert.IsTrue(stream.Disposed);
        }