/// <summary>
 /// Validates whether file result has the provided content type.
 /// </summary>
 /// <param name="contentType">Content type as string.</param>
 protected void ValidateContentType(string contentType)
 {
     ContentTypeValidator.ValidateContentType(
         this.ActionResult,
         contentType,
         this.ThrowNewFileResultAssertionException);
 }
        /// <inheritdoc />
        public IAndViewTestBuilder WithContentType(string contentType)
        {
            ContentTypeValidator.ValidateContentType(
                this.TestContext.MethodResult,
                contentType,
                this.ThrowNewViewResultAssertionException);

            return(this);
        }
        /// <inheritdoc />
        public IAndContentTestBuilder WithContentType(string contentType)
        {
            ContentTypeValidator.ValidateContentType(
                contentType,
                this.ActionResult.ContentType,
                this.ThrowNewContentResultAssertionException);

            return(this);
        }
        /// <inheritdoc />
        public IAndJsonTestBuilder WithContentType(string contentType)
        {
            ContentTypeValidator.ValidateContentType(
                contentType,
                this.GetJsonResult().ContentType,
                this.ThrowNewJsonResultAssertionException);

            return(this);
        }
예제 #5
0
        /// <summary>
        /// Tests whether the <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/>
        /// has the same content type as the provided string.
        /// </summary>
        /// <param name="baseTestBuilderWithContentTypeResult">
        /// Instance of <see cref="IBaseTestBuilderWithContentTypeResult{TContentTypeResultTestBuilder}"/> type.
        /// </param>
        /// <param name="contentType">Content type as string.</param>
        /// <returns>The same content type <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/> test builder.</returns>
        public static TContentTypeResultTestBuilder WithContentType <TContentTypeResultTestBuilder>(
            this IBaseTestBuilderWithContentTypeResult <TContentTypeResultTestBuilder> baseTestBuilderWithContentTypeResult,
            string contentType)
            where TContentTypeResultTestBuilder : IBaseTestBuilderWithActionResult
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithContentTypeResult);

            ContentTypeValidator.ValidateContentType(
                actualBuilder.TestContext.MethodResult,
                contentType,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.ResultTestBuilder);
        }