public async Task RenameBlobContainerAsync_SourceLeaseFailed()
        {
            // Arrange
            BlobServiceClient   service          = GetServiceClient_SharedKey();
            string              oldContainerName = GetNewContainerName();
            string              newContainerName = GetNewContainerName();
            BlobContainerClient container        = InstrumentClient(service.GetBlobContainerClient(oldContainerName));
            await container.CreateAsync();

            string leaseId = Recording.Random.NewGuid().ToString();

            BlobRequestConditions sourceConditions = new BlobRequestConditions
            {
                LeaseId = leaseId
            };

            // Act
            await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>(
                service.RenameBlobContainerAsync(
                    sourceContainerName: oldContainerName,
                    destinationContainerName: newContainerName,
                    sourceConditions: sourceConditions),
                e => Assert.AreEqual(BlobErrorCode.LeaseNotPresentWithContainerOperation.ToString(), e.ErrorCode));

            // Cleanup
            await container.DeleteAsync();
        }
        public async Task RenameBlobContainerAsync_SourceLease()
        {
            // Arrange
            BlobServiceClient   service          = GetServiceClient_SharedKey();
            string              oldContainerName = GetNewContainerName();
            string              newContainerName = GetNewContainerName();
            BlobContainerClient container        = InstrumentClient(service.GetBlobContainerClient(oldContainerName));
            await container.CreateAsync();

            string leaseId = Recording.Random.NewGuid().ToString();

            BlobLeaseClient leaseClient = InstrumentClient(container.GetBlobLeaseClient(leaseId));
            await leaseClient.AcquireAsync(duration : TimeSpan.FromSeconds(30));

            BlobRequestConditions sourceConditions = new BlobRequestConditions
            {
                LeaseId = leaseId
            };

            // Act
            BlobContainerClient newContainer = await service.RenameBlobContainerAsync(
                sourceContainerName : oldContainerName,
                destinationContainerName : newContainerName,
                sourceConditions : sourceConditions);

            // Assert
            await newContainer.GetPropertiesAsync();

            // Cleanup
            await newContainer.DeleteAsync();
        }
        public async Task RenameBlobContainerAsync_Error()
        {
            // Arrange
            BlobServiceClient service = GetServiceClient_SharedKey();

            // Act
            await TestHelper.AssertExpectedExceptionAsync <RequestFailedException>(
                service.RenameBlobContainerAsync(GetNewContainerName(), GetNewContainerName()),
                e => Assert.AreEqual(BlobErrorCode.ContainerNotFound.ToString(), e.ErrorCode));
        }
        public async Task RenameBlobContainerAsync()
        {
            // Arrange
            BlobServiceClient   service          = GetServiceClient_SharedKey();
            string              oldContainerName = GetNewContainerName();
            string              newContainerName = GetNewContainerName();
            BlobContainerClient container        = InstrumentClient(service.GetBlobContainerClient(oldContainerName));
            await container.CreateAsync();

            // Act
            BlobContainerClient newContainer = await service.RenameBlobContainerAsync(
                sourceContainerName : oldContainerName,
                destinationContainerName : newContainerName);

            // Assert
            await newContainer.GetPropertiesAsync();

            // Cleanup
            await newContainer.DeleteAsync();
        }
        public async Task RenameBlobContainerAsync_AccountSas()
        {
            // Arrange
            BlobServiceClient   service          = GetServiceClient_SharedKey();
            string              oldContainerName = GetNewContainerName();
            string              newContainerName = GetNewContainerName();
            BlobContainerClient container        = InstrumentClient(service.GetBlobContainerClient(oldContainerName));
            await container.CreateAsync();

            SasQueryParameters sasQueryParameters = GetNewAccountSas();

            service = InstrumentClient(new BlobServiceClient(new Uri($"{service.Uri}?{sasQueryParameters}"), GetOptions()));

            // Act
            BlobContainerClient newContainer = await service.RenameBlobContainerAsync(
                sourceContainerName : oldContainerName,
                destinationContainerName : newContainerName);

            // Assert
            await newContainer.GetPropertiesAsync();

            // Cleanup
            await newContainer.DeleteAsync();
        }