コード例 #1
0
        /// <summary>
        /// Verifies the streams data.
        /// </summary>
        /// <param name="expectedStreamValue">The expected stream value.</param>
        /// <param name="response">The stream response.</param>
        /// <returns>The result of stream verification</returns>
        protected bool VerifyStreams(AstoriaQueryStreamValue expectedStreamValue, DataServiceStreamResponse response)
        {
            var expectedBytes = new byte[0];

            if (!expectedStreamValue.IsNull)
            {
                expectedBytes = expectedStreamValue.Value;
            }

            var expectedStream = new MemoryStream(expectedBytes);

            try
            {
                ExceptionUtilities.Assert(response.Stream.CanRead, "Cannot read from the stream");

                return(StreamHelpers.CompareStream(response.Stream, expectedStream));
            }
            finally
            {
                response.Stream.Dispose();
                expectedStream.Dispose();
            }
        }