public async Task GetBlobAsync_NonExistentBlob_ThrowsBlobDoesNotExistException()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.GetBlobAsync(containerName, blobName);

            // expects exception
        }
        public async void GetBlobAsync_ExistingBlobByValidStartAndEndRange_DownloadBlobRangeOnly()
        {
            var expectedContent = "Expected blob content";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName, content: expectedContent);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            var response = await client.GetBlobAsync(containerName, blobName, range: new BlobRange(2, 6));
            var data = response.GetDataBytes();

            Assert.AreEqual(expectedContent.Substring(2, 5), Encoding.UTF8.GetString(data));
        }
        public async Task GetBlobAsync_ExistingBlob_DownloadsBlobStream()
        {
            const string expectedContent = "Expected blob content";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName, content: expectedContent);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            var response = await client.GetBlobAsync(containerName, blobName);
            byte[] data;
            using (var stream = response.GetDataStream())
            {
                using (var ms = new MemoryStream())
                {
                    stream.CopyTo(ms);
                    data = ms.ToArray();
                }
            }

            Assert.AreEqual(expectedContent, Encoding.UTF8.GetString(data));
        }
        public async void GetBlobAsync_LeasedBlobGivenInvalidLease_ThrowsArgumentException()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            _util.LeaseBlob(containerName, blobName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.GetBlobAsync(containerName, blobName, null, leaseId: InvalidLeaseId);

            // Throws exception
        }
        public async void GetBlobAsync_LeasedBlobGivenIncorrectLease_ThrowsLeaseIdMismatchWithBlobOperationAzureException()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            _util.LeaseBlob(containerName, blobName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.GetBlobAsync(containerName, blobName, null, leaseId: GetGuidString());

            // Throws exception
        }
        public async void GetBlobAsync_LeasedBlobWithoutLeaseSpecified_GetsBlobWithoutException()
        {
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName);
            _util.LeaseBlob(containerName, blobName);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            await client.GetBlobAsync(containerName, blobName);

            // no exception thrown
        }
        public async Task GetBlobAsync_ExistingBlob_DownloadsBlobBytes()
        {
            const string expectedContent = "Expected blob content";
            var containerName = _util.GenerateSampleContainerName(_runId);
            var blobName = _util.GenerateSampleBlobName(_runId);
            _util.CreateContainer(containerName);
            _util.CreateBlockBlob(containerName, blobName, content: expectedContent);
            IBlobServiceClient client = new BlobServiceClient(AccountSettings);

            var response = await client.GetBlobAsync(containerName, blobName);
            var data = response.GetDataBytes();

            Assert.AreEqual(expectedContent, Encoding.UTF8.GetString(data));
        }