public void ByteRangesTests() { var fullRange = BytesRangeUtils.Full(); var outer = BytesRangeUtils.Make(0, 100); var inner = BytesRangeUtils.Make(10, 90); var innerInside = BytesRangeUtils.Make(50, 60); var innerRightSideOverlap = BytesRangeUtils.Make(50, 95); var innerLeftSideOverlap = BytesRangeUtils.Make(5, 15); Assert.That(outer.Contains(inner)); var localizedRightOverlap = innerRightSideOverlap.LocalizeTo(inner); var localizedLeftOverlap = innerLeftSideOverlap.LocalizeTo(inner); Assert.That(localizedRightOverlap, Is.EqualTo(BytesRangeUtils.Make(40, -1))); Assert.That(localizedLeftOverlap, Is.EqualTo(BytesRangeUtils.Make(0, 5))); var localizedFull = fullRange.LocalizeTo(inner); Assert.That(localizedFull, Is.EqualTo(BytesRangeUtils.Full())); var localizedInner = innerInside.LocalizeTo(inner); Assert.That(localizedInner, Is.EqualTo(BytesRangeUtils.Make(40, 50))); }
public void ChunksCalculations_WithFullRange() { BytesRange range = BytesRangeUtils.Full(); var chunksRange = range.Chunkify(_chunksData); Assert.That(chunksRange.Start, Is.EqualTo(0)); Assert.That(chunksRange.End, Is.EqualTo(-1)); Assert.That(chunksRange.Contains(range)); }
public void JobQueuing_WithFullRange() { BytesRange range = BytesRangeUtils.Full(); var jobs = ChunkedHttpDownloader.BuildDownloadJobQueue(_url, 0, range, DataSize, _chunksData).ToList(); int expectedJobCount = (int)(DataSize / PartSize) + 1; Assert.That(jobs.Count, Is.EqualTo(expectedJobCount)); var firstJob = jobs[0]; Assert.That(firstJob.Range.Start, Is.EqualTo(0)); Assert.That(firstJob.Range.End, Is.EqualTo(-1)); var lastJob = jobs[expectedJobCount - 1]; Assert.That(lastJob.Range.Start, Is.EqualTo(0)); Assert.That(lastJob.Range.End, Is.EqualTo(-1)); }