Exemple #1
0
        [TestCase(256 * Constants.KB)] // multi-report case
        public async Task DownloadContent(int size)
        {
            await using DisposingContainer test = await BlobsClientBuilder.GetTestContainerAsync();

            // Arrange
            var          data     = GetRandomBuffer(size);
            TestProgress progress = new TestProgress();
            var          client   = test.Container.GetBlobClient(BlobsClientBuilder.GetNewBlobName());
            await client.UploadAsync(BinaryData.FromBytes(data));

            // Act
            var result = await client.DownloadContentAsync(progressHandler : progress);

            // Assert
            Assert.AreNotEqual(0, progress.List.Count);
            Assert.AreEqual(size, progress.List.Max());
            Assert.IsTrue(Enumerable.SequenceEqual(data, result.Value.Content.ToArray()));
        }
Exemple #2
0
        public async Task DownloadContentRange(int offset, int length)
        {
            await using DisposingContainer test = await BlobsClientBuilder.GetTestContainerAsync();

            // Arrange
            const int    size     = 8 * Constants.KB;
            var          data     = GetRandomBuffer(size);
            TestProgress progress = new TestProgress();
            var          client   = test.Container.GetBlobClient(BlobsClientBuilder.GetNewBlobName());
            await client.UploadAsync(BinaryData.FromBytes(data));

            // Act
            var result = await client.DownloadContentAsync(
                progressHandler : progress,
                range : new HttpRange(offset, length));

            // Assert
            Assert.AreNotEqual(0, progress.List.Count);
            Assert.AreEqual(length, progress.List.Max());
            Assert.IsTrue(new ReadOnlySpan <byte>(data, offset, length).SequenceEqual(result.Value.Content.ToArray()));
        }