public void Stream()
        {
            var array = new byte[] { 1, 2, 3 };

            using (var stream = new MemoryStream(array))
            {
                Assert.False(FileStreamReadLightUp.IsFileStream(stream));

                using (var provider = new StreamMemoryBlockProvider(stream, 0, array.Length, isFileStream: false, leaveOpen: true))
                {
                    using (var block = provider.GetMemoryBlock())
                    {
                        Assert.IsType <NativeHeapMemoryBlock>(block);
                        Assert.Equal(3, block.Size);
                        AssertEx.Equal(array, block.GetContent());
                    }

                    Assert.Equal(3, stream.Position);

                    using (var block = provider.GetMemoryBlock(1, 2))
                    {
                        Assert.IsType <NativeHeapMemoryBlock>(block);
                        Assert.Equal(2, block.Size);
                        AssertEx.Equal(new byte[] { 2, 3 }, block.GetContent());
                    }

                    Assert.Equal(3, stream.Position);
                }

                using (var provider = new StreamMemoryBlockProvider(stream, 0, array.Length, isFileStream: false, leaveOpen: false))
                {
                    using (var block = provider.GetMemoryBlock())
                    {
                        Assert.IsType <NativeHeapMemoryBlock>(block);
                        Assert.Equal(3, block.Size);
                        AssertEx.Equal(array, block.GetContent());
                    }

                    Assert.Equal(3, stream.Position);
                }

                Assert.Throws <ObjectDisposedException>(() => stream.Position);
            }
        }
        public unsafe void ByteArray()
        {
            var array = ImmutableArray.Create(new byte[] { 1, 2, 3 });

            using (var provider = new ByteArrayMemoryProvider(array))
            {
                using (var block = provider.GetMemoryBlock())
                {
                    Assert.Equal(3, block.Size);
                    AssertEx.Equal(provider.Pointer, block.Pointer);
                    AssertEx.Equal(array, block.GetContent());
                }

                using (var block = provider.GetMemoryBlock(1, 2))
                {
                    AssertEx.Equal(provider.Pointer + 1, block.Pointer);
                    Assert.Equal(2, block.Size);
                    AssertEx.Equal(new byte[] { 2, 3 }, block.GetContent());
                }
            }
        }
        public unsafe void External()
        {
            var array = new byte[] { 1, 2, 3 };

            fixed(byte *arrayPtr = array)
            {
                using (var provider = new ExternalMemoryBlockProvider(arrayPtr, array.Length))
                {
                    using (var block = provider.GetMemoryBlock())
                    {
                        Assert.Equal(3, block.Size);
                        AssertEx.Equal(provider.Pointer, block.Pointer);
                        AssertEx.Equal(array, block.GetContent());
                    }

                    using (var block = provider.GetMemoryBlock(1, 2))
                    {
                        AssertEx.Equal(provider.Pointer + 1, block.Pointer);
                        Assert.Equal(2, block.Size);
                        AssertEx.Equal(new byte[] { 2, 3 }, block.GetContent());
                    }
                }
            }
        }