Exemplo n.º 1
0
        /// <summary>
        /// Checks a get file 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 file.</param>
        /// <param name="expectedError">The expected error code, or null if the operation is expected to succeed.</param>
        public static void CheckFileRangeResponse(
            HttpWebResponse response,
            FileContext 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);
                FileTestUtils.LastModifiedHeader(response);
                FileTestUtils.ContentLengthHeader(response, content.Length);
                FileTestUtils.ETagHeader(response);
                FileTestUtils.RequestIdHeader(response);
                FileTestUtils.Contents(response, content);
                FileTestUtils.ContentRangeHeader(response, expectedStartRange, expectedEndRange, expectedTotalBytes);
            }
            else
            {
                Assert.AreEqual(expectedError, response.StatusCode, response.StatusDescription);
            }

            response.Close();
        }
Exemplo n.º 2
0
 public static void PutFileResponse(HttpWebResponse response, FileContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.Created, response.StatusCode, response.StatusDescription);
         FileTestUtils.ETagHeader(response);
         FileTestUtils.LastModifiedHeader(response);
         FileTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.StatusDescription);
     }
     response.Close();
 }
Exemplo n.º 3
0
 public static void WriteRangeResponse(HttpResponseMessage response, FileContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
         FileTestUtils.LastModifiedHeader(response);
         FileTestUtils.ETagHeader(response);
         FileTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
     response.Dispose();
 }