示例#1
0
        //static void ReadCallback(IAsyncResult result)
        //{
        //    HttpResponseMessage response = ((System.Threading.Tasks.Task<HttpResponseMessage>)(result)).Result;
        //    setRequestAsyncStream = response.Content.ReadAsStreamAsync().Result;
        //    setRequestAsyncSem.Set();
        //}


        #endregion

        #region Response Validation

        /// <summary>
        /// Tests for a content range header in an HTTP response.
        /// </summary>
        /// <param name="response">The HTTP response.</param>
        /// <param name="expectedStart">The expected beginning of the range.</param>
        /// <param name="expectedEnd">The expected end of the range.</param>
        /// <param name="expectedTotal">The expected total number of bytes in the range.</param>
        public static void ContentRangeHeader(HttpResponseMessage response, long expectedStart, long expectedEnd, long expectedTotal)
        {
            Assert.IsNotNull(response);
            Assert.IsNotNull(HttpResponseParsers.GetContentRange(response));
            string expectedRange = string.Format("bytes {0}-{1}/{2}", expectedStart, expectedEnd, expectedTotal);

            Assert.AreEqual(expectedRange, HttpResponseParsers.GetContentRange(response));
        }
示例#2
0
 public static void ContentRangeHeader(HttpResponseMessage response, FileRange expectedValue)
 {
     Assert.IsNotNull(response);
     Assert.IsNotNull(HttpResponseParsers.GetContentRange(response));
     Assert.AreEqual(expectedValue.ToString(), HttpResponseParsers.GetContentRange(response));
 }