コード例 #1
0
        /// <summary>
        /// Checks a get blob range response for consistency with the given parameters, and closes the response.
        /// </summary>
        /// <param name="response">The HTTP web response to check.</param>
        /// <param name="context">The testing context.</param>
        /// <param name="content">The expected content returned in the response.</param>
        /// <param name="expectedStartRange">The expected start range returned in the response header.</param>
        /// <param name="expectedEndRange">The expected end range returned in the response header.</param>
        /// <param name="expectedTotalBytes">The expected total number of bytes in the blob.</param>
        /// <param name="expectedError">The expected error code, or null if the operation is expected to succeed.</param>
        public static void CheckBlobRangeResponse(
            HttpResponseMessage response,
            BlobContext context,
            byte[] content,
            long expectedStartRange,
            long expectedEndRange,
            long expectedTotalBytes,
            HttpStatusCode?expectedError)
        {
            Assert.IsNotNull(response);
            if (expectedError == null)
            {
                Assert.AreEqual(HttpStatusCode.PartialContent, response.StatusCode);
                Assert.IsNotNull(content);
                BlobTestUtils.LastModifiedHeader(response);
                BlobTestUtils.ContentLengthHeader(response, content.Length);
                BlobTestUtils.ETagHeader(response);
                BlobTestUtils.RequestIdHeader(response);
                BlobTestUtils.Contents(response, content);
                BlobTestUtils.ContentRangeHeader(response, expectedStartRange, expectedEndRange, expectedTotalBytes);
            }
            else
            {
                Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
            }

            response.Dispose();
        }
コード例 #2
0
 public static void GetBlockListResponse(HttpResponseMessage response, BlobContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, response.ReasonPhrase);
         BlobTestUtils.ContentTypeHeader(response, "application/xml");
         BlobTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
 }
コード例 #3
0
 /// <summary>
 /// Validates a response to a break lease operation.
 /// </summary>
 /// <param name="response">The response to validate.</param>
 /// <param name="expectedLeaseTime">The expected remaining lease time.</param>
 /// <param name="errorMargin">The error margin on the expected remaining lease time.</param>
 /// <param name="expectedError">The error status code to expect.</param>
 public static void BreakLeaseResponse(HttpResponseMessage response, int expectedLeaseTime, int errorMargin, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.Accepted, response.StatusCode, response.ReasonPhrase);
         BlobTestUtils.LeaseIdHeader(response, null);
         BlobTestUtils.LeaseTimeHeader(response, expectedLeaseTime, errorMargin);
         BlobTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
 }
コード例 #4
0
 /// <summary>
 /// Validates a response to a release lease operation.
 /// </summary>
 /// <param name="response">The response to validate.</param>
 /// <param name="expectedError">The error status code to expect.</param>
 public static void ReleaseLeaseResponse(HttpResponseMessage response, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, response.ReasonPhrase);
         BlobTestUtils.LeaseIdHeader(response, null);
         BlobTestUtils.LeaseTimeHeader(response, null, null);
         BlobTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
 }
コード例 #5
0
 public static void PutBlockListResponse(HttpResponseMessage response, BlobContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, response.ReasonPhrase);
         BlobTestUtils.ContentChecksumHeader(response);
         BlobTestUtils.RequestIdHeader(response);
         BlobTestUtils.ContentLengthHeader(response, 0);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
     response.Dispose();
 }
コード例 #6
0
 public static void GetBlobResponse(HttpResponseMessage response, BlobContext context, BlobProperties properties, byte[] content, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
         BlobTestUtils.LastModifiedHeader(response);
         BlobTestUtils.ContentLengthHeader(response, content.Length);
         BlobTestUtils.ETagHeader(response);
         BlobTestUtils.RequestIdHeader(response);
         BlobTestUtils.Contents(response, content);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
     response.Dispose();
 }
コード例 #7
0
        /// <summary>
        /// Validates a response to an acquire lease operation.
        /// </summary>
        /// <param name="response">The response to validate.</param>
        /// <param name="expectedLeaseId">The expected lease ID.</param>
        /// <param name="expectedError">The error status code to expect.</param>
        public static void AcquireLeaseResponse(HttpResponseMessage response, string expectedLeaseId, HttpStatusCode?expectedError)
        {
            Assert.IsNotNull(response);
            if (expectedError == null)
            {
                Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, response.ReasonPhrase);

                if (expectedLeaseId != null)
                {
                    BlobTestUtils.LeaseIdHeader(response, expectedLeaseId);
                }
                else
                {
                    BlobTestUtils.LeaseIdHeader(response);
                }

                BlobTestUtils.LeaseTimeHeader(response, null, null);
                BlobTestUtils.RequestIdHeader(response);
            }
            else
            {
                Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
            }
        }