Example #1
0
        public async Task LargeDownloadVerifyRangeSizeRestrictions()
        {
            string             inputFileName  = Path.GetTempFileName();
            string             outputFileName = Path.GetTempFileName();
            CloudBlobContainer container      = GetRandomContainerReference();

            try
            {
                await container.CreateAsync();

                CloudBlockBlob blob = container.GetBlockBlobReference("largeblob1");
                await blob.UploadTextAsync("Tent");

                try
                {
                    await blob.DownloadToFileParallelAsync(outputFileName, FileMode.Create, 16, 16 *Constants.MB + 3, CancellationToken.None);

                    Assert.Fail("Expected a failure");
                }
                catch (ArgumentException) {}

                try
                {
                    await blob.DownloadToFileParallelAsync(outputFileName, FileMode.Create, 16, 2 *Constants.MB, CancellationToken.None);

                    Assert.Fail("Expected a failure");
                }
                catch (ArgumentOutOfRangeException) {}

                try
                {
                    BlobRequestOptions options = new BlobRequestOptions();
                    options.UseTransactionalMD5 = true;
                    await blob.DownloadToFileParallelAsync(outputFileName, FileMode.Create, 16, 16 *Constants.MB, 0, null, null, options, null, CancellationToken.None);

                    Assert.Fail("Expected a failure");
                }
                catch (ArgumentException) {}
                blob.Delete();
            }
            finally
            {
                container.DeleteIfExists();

                File.Delete(inputFileName);
                File.Delete(outputFileName);
            }
        }