/// <summary>
        /// Scenario test for changing a lease.
        /// </summary>
        /// <param name="containerName">The name of the container.</param>
        /// <param name="blobName">The name of the blob, if any.</param>
        /// <param name="leaseId">The lease ID.</param>
        /// <param name="proposedLeaseId">The proposed lease ID.</param>
        /// <param name="expectedError">The error status code to expect.</param>
        /// <returns>The lease ID.</returns>
        public async Task <string> ChangeLeaseScenarioTest(string containerName, string blobName, string leaseId, string proposedLeaseId, HttpStatusCode?expectedError)
        {
            // Create and validate the web request
            HttpRequestMessage request = BlobTests.ChangeLeaseRequest(BlobContext, containerName, blobName, proposedLeaseId, AccessCondition.GenerateLeaseCondition(leaseId));

            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, BlobContext))
            {
                BlobTests.ChangeLeaseResponse(response, proposedLeaseId, expectedError);

                return(BlobHttpResponseParsers.GetLeaseId(response));
            }
        }
예제 #2
0
        /// <summary>
        /// Scenario test for changing a lease.
        /// </summary>
        /// <param name="containerName">The name of the container.</param>
        /// <param name="blobName">The name of the blob, if any.</param>
        /// <param name="leaseId">The lease ID.</param>
        /// <param name="proposedLeaseId">The proposed lease ID.</param>
        /// <param name="expectedError">The error status code to expect.</param>
        /// <returns>The lease ID.</returns>
        public string ChangeLeaseScenarioTest(string containerName, string blobName, string leaseId, string proposedLeaseId, HttpStatusCode?expectedError)
        {
            // Create and validate the web request
            HttpWebRequest request = BlobTests.ChangeLeaseRequest(BlobContext, containerName, blobName, proposedLeaseId, AccessCondition.GenerateLeaseCondition(leaseId));

            if (BlobContext.Credentials != null)
            {
                BlobTests.SignRequest(request, BlobContext);
            }

            using (HttpWebResponse response = BlobTestUtils.GetResponse(request, BlobContext))
            {
                BlobTests.ChangeLeaseResponse(response, proposedLeaseId, expectedError);

                return(BlobHttpResponseParsers.GetLeaseId(response));
            }
        }