Example #1
0
        public void ExtendedCloseTest()
        {
            var i = 0;

            using (var str = new ExtendedCloseStream(new MemoryStream(), () => { i++; }))
            {
                Assert.Equal(0, i);
            }

            Assert.Equal(1, i);
        }
        private Stream CreateFile(FileAttributes attributes)
        {
            Stream ret = info.Create();

            if (attributes != FileAttributes.Normal)
            {
                ret = new ExtendedCloseStream(ret, () =>
                {
                    if (Exists())
                    {
                        File.SetAttributes(Path, attributes);
                    }
                });
            }
            return(ret);
        }