FillAsync() private method

private FillAsync ( ReadAsyncCallback read, byte buffer, int offset, int count, CancellationToken cancellationToken ) : Task
read ReadAsyncCallback
buffer byte
offset int
count int
cancellationToken System.Threading.CancellationToken
return Task
        public async Task FillAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            var readCount = this.ReadFromBuffer(buffer, offset, count);

            offset += readCount;
            count  -= readCount;

            if (count > 0)
            {
                if (count > this.Capacity)
                {
                    this.Compact();
                    await StreamHelper.FillAsync(this.readAsync, buffer, offset, count, cancellationToken);

                    this.previousPosition += count;
                }
                else
                {
                    await this.FillAsync(count, cancellationToken);

                    System.Buffer.BlockCopy(this.GetBuffer(), this.Index, buffer, offset, count);
                    this.Index += count;
                }
            }
        }
 public void ExceptionTest()
 {
     AsyncPump.Run(
         async() =>
     {
         AssertThrow <ArgumentNullException>(() => StreamHelper.Fill(null, new byte[1], 0, 1));
         await AssertThrowAsync <ArgumentNullException>(
             () => StreamHelper.FillAsync(null, new byte[1], 0, 1, CancellationToken.None));
     });
 }