public async Task BeginRead_CanReadAfterLength()
        {
            // Arrange
            var originalText = "This is the whole text.";
            var range        = new RangeItemHeaderValue(0L, null);
            var data         = new byte[25];
            var callback     = new AsyncCallback(_ => { });
            var userState    = new object();

            using (var innerStream = new MemoryStream())
                using (var writer = new StreamWriter(innerStream))
                {
                    await writer.WriteAsync(originalText);

                    await writer.FlushAsync();

                    using (var rangeStream = new ByteRangeStream(innerStream, range))
                    {
                        rangeStream.Position = 50L;

                        // Act
                        var result = rangeStream.BeginRead(data, 0, data.Length, callback, userState);
                        var read   = rangeStream.EndRead(result);

                        // Assert
                        Assert.Equal(0, read);
                    }
                }
        }
        public void BeginRead_ReadsEffectiveLengthBytes(
            int from,
            int to,
            int innerLength,
            int effectiveLength
            )
        {
            // Arrange
            var mockInnerStream = new Mock <Stream>();

            mockInnerStream.Setup(s => s.CanSeek).Returns(true);
            mockInnerStream.Setup(s => s.Length).Returns(innerLength);
            var range     = new RangeItemHeaderValue(from, to);
            var data      = new byte[25];
            var offset    = 5;
            var callback  = new AsyncCallback(_ => { });
            var userState = new object();

            using (var rangeStream = new ByteRangeStream(mockInnerStream.Object, range))
            {
                // Act
                var result = rangeStream.BeginRead(data, offset, data.Length, callback, userState);
                rangeStream.EndRead(result);

                // Assert
                mockInnerStream.Verify(
                    s => s.BeginRead(data, offset, effectiveLength, callback, userState),
                    Times.Once()
                    );
                Assert.Equal(effectiveLength, rangeStream.Position);
            }
        }