Example #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();
        }
Example #2
0
 public static void PutBlobResponse(HttpResponseMessage response, BlobContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, response.ReasonPhrase);
         BlobTestUtils.ETagHeader(response);
         BlobTestUtils.LastModifiedHeader(response);
         BlobTestUtils.ContentChecksumHeader(response);
         BlobTestUtils.RequestIdHeader(response);
         BlobTestUtils.ContentLengthHeader(response, 0);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
     response.Dispose();
 }
Example #3
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();
 }