public async Task Download()
        {
            // get 1kb from start
            var chunkInfo = new ChunkInfo(0, 1024);
            var chunk = await Downloader.DownloadChunk(chunkInfo);

            Assert.AreEqual(chunkInfo.Start, chunk.Start);
            Assert.AreEqual(chunkInfo.Length, chunk.Length);
        }
        //[TestMethod]
        public async Task DownloadEnd()
        {
            // get 1kb from near end
            var chunkInfo = new ChunkInfo(RESOURCE_LENGTH, 1024);

            var chunk = await Downloader.DownloadChunk(chunkInfo);
            Assert.AreEqual(chunkInfo.Start, chunk.Start);
            Assert.AreEqual(0, chunk.Length);
        }
Ejemplo n.º 3
0
        public async Task<IChunk> DownloadChunk()
        {
            var chunkInfo = await ChunkSaver.GetNextEmptyChunk(Destination);

            var checkedChunkInfo = new ChunkInfo(
                chunkInfo.Start,
                Math.Min(ChunkLength, chunkInfo.Length)
            );
            var chunk = await ChunkDownloader.DownloadChunk(checkedChunkInfo);
            return chunk;
        }