/// <summary>
 /// Tests whether action result has the same status code as the provided HttpStatusCode.
 /// </summary>
 /// <param name="statusCode"><see cref="HttpStatusCode"/> enumeration.</param>
 protected void ValidateStatusCode(HttpStatusCode statusCode)
 {
     HttpStatusCodeValidator.ValidateHttpStatusCode(
         this.ActionResult,
         statusCode,
         this.ThrowNewFailedValidationException);
 }
 /// <summary>
 /// Tests whether action result has the same status code as the provided HttpStatusCode.
 /// </summary>
 /// <param name="statusCode"><see cref="HttpStatusCode"/> enumeration.</param>
 protected void ValidateStatusCode(HttpStatusCode statusCode)
 {
     HttpStatusCodeValidator.ValidateHttpStatusCode(
         this.TestContext.MethodResult,
         statusCode,
         this.ThrowNewFailedValidationException);
 }
        /// <inheritdoc />
        public IAndHttpResponseTestBuilder WithStatusCode(HttpStatusCode statusCode)
        {
            HttpStatusCodeValidator.ValidateHttpStatusCode(
                statusCode,
                this.httpResponse.StatusCode,
                this.ThrowNewHttpResponseAssertionException);

            return(this);
        }
        /// <inheritdoc />
        public IAndViewTestBuilder WithStatusCode(HttpStatusCode statusCode)
        {
            HttpStatusCodeValidator.ValidateHttpStatusCode(
                this.TestContext.MethodResult,
                statusCode,
                this.ThrowNewViewResultAssertionException);

            return(this);
        }
        /// <inheritdoc />
        public IAndContentTestBuilder WithStatusCode(HttpStatusCode statusCode)
        {
            HttpStatusCodeValidator.ValidateHttpStatusCode(
                statusCode,
                this.ActionResult.StatusCode,
                this.ThrowNewContentResultAssertionException);

            return(this);
        }
        /// <inheritdoc />
        public IAndStatusCodeTestBuilder StatusCode(HttpStatusCode statusCode)
        {
            HttpStatusCodeValidator.ValidateHttpStatusCode(
                this.ActionResult,
                statusCode,
                this.ThrowNewStatusCodeResultAssertionException);

            return(this.GetStatusCodeTestBuilder());
        }
        /// <inheritdoc />
        public IAndJsonTestBuilder WithStatusCode(HttpStatusCode statusCode)
        {
            HttpStatusCodeValidator.ValidateHttpStatusCode(
                statusCode,
                this.GetJsonResult().StatusCode,
                this.ThrowNewJsonResultAssertionException);

            return(this);
        }
示例#8
0
        /// <summary>
        /// Tests whether the <see cref="Microsoft.AspNetCore.Mvc.Infrastructure.IStatusCodeActionResult"/>
        /// has the same status code as the provided <see cref="System.Net.HttpStatusCode"/>.
        /// </summary>
        /// <param name="baseTestBuilderWithStatusCodeResult">
        /// Instance of <see cref="IBaseTestBuilderWithStatusCodeResult{TStatusCodeResultTestBuilder}"/> type.
        /// </param>
        /// <param name="statusCode"><see cref="System.Net.HttpStatusCode"/> enumeration.</param>
        /// <returns>The same <see cref="Microsoft.AspNetCore.Mvc.Infrastructure.IStatusCodeActionResult"/> test builder.</returns>
        public static TStatusCodeResultTestBuilder WithStatusCode <TStatusCodeResultTestBuilder>(
            this IBaseTestBuilderWithStatusCodeResult <TStatusCodeResultTestBuilder> baseTestBuilderWithStatusCodeResult,
            SystemHttpStatusCode statusCode)
            where TStatusCodeResultTestBuilder : IBaseTestBuilderWithActionResult
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithStatusCodeResult);

            HttpStatusCodeValidator.ValidateHttpStatusCode(
                actualBuilder.TestContext.MethodResult,
                statusCode,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.ResultTestBuilder);
        }