public void ViewIO()
        {
            SparseMemoryStream memStream = new SparseMemoryStream();

            memStream.SetLength(1024);

            ThreadSafeStream tss = new ThreadSafeStream(memStream);

            SparseStream altView = tss.OpenView();

            // Check positions are independant
            tss.Position = 100;
            Assert.Equal(0, altView.Position);
            Assert.Equal(100, tss.Position);

            // Check I/O is synchronous
            byte[] buffer = new byte[200];
            tss.WriteByte(99);
            altView.Read(buffer, 0, 200);
            Assert.Equal(99, buffer[100]);

            // Check positions are updated correctly
            Assert.Equal(200, altView.Position);
            Assert.Equal(101, tss.Position);
        }
        public void Extents()
        {
            SparseMemoryStream memStream = new SparseMemoryStream(new SparseMemoryBuffer(1), FileAccess.ReadWrite);

            memStream.SetLength(1024);

            ThreadSafeStream tss = new ThreadSafeStream(memStream);

            SparseStream altView = tss.OpenView();

            tss.Position = 100;
            tss.WriteByte(99);

            List <StreamExtent> extents = new List <StreamExtent>(altView.Extents);

            Assert.Equal(1, extents.Count);
            Assert.Equal(100, extents[0].Start);
            Assert.Equal(1, extents[0].Length);

            extents = new List <StreamExtent>(altView.GetExtentsInRange(10, 300));
            Assert.Equal(1, extents.Count);
            Assert.Equal(100, extents[0].Start);
            Assert.Equal(1, extents[0].Length);
        }