コード例 #1
0
        /// <summary>
        /// Asserts that the response content type is of the MIME-type 'text/html'.
        /// </summary>
        /// <param name="response">The <see cref="ClientResponse"/> that the assert should be made on.</param>
        /// <param name="assertions">Additional assertions on the CQ object.</param>
        /// <returns>The CQ object.</returns>
        public static CQ ShouldBeHtml(this ClientResponse response, Action<CQ> assertions = null)
        {
            response.ShouldHaveContentType("text/html");

            CQ document;

            try
            {
                document = response.AsCsQuery();
            }
            catch (Exception exception)
            {
                throw AssertException.Create(response, "Failed to convert response body into a CQ object.", exception);
            }

            assertions.TryInvoke(document);

            return document;
        }
コード例 #2
0
        /// <summary>
        /// Asserts that the response content type is of the MIME-type 'text/html'.
        /// </summary>
        /// <param name="response">The <see cref="BrowserResponse"/> that the assert should be made on.</param>
        /// <param name="assertions">Additional assertions on the CQ object.</param>
        /// <returns>The CQ object.</returns>
        public static CQ ShouldBeHtml(this BrowserResponse response, Action<CQ> assertions = null)
        {
            response.AssertStatusCode(HttpStatusCode.OK);
            response.AssertContentType("text/html");

            CQ document;

            try
            {
                document = response.AsCsQuery();
            }
            catch (Exception exception)
            {
                throw new AssertException("Failed to convert response body into a CQ object.", exception);
            }

            assertions.TryInvoke(document);

            return document;
        }