Ejemplo n.º 1
0
        /// <inheritdoc />
        public IAndCreatedTestBuilder WithRouteName(string routeName)
        {
            var createdAtRouteResult = this.GetCreatedResult <CreatedAtRouteResult>("route name");

            RouteActionResultValidator.ValidateRouteName(
                createdAtRouteResult,
                routeName,
                this.ThrowNewCreatedResultAssertionException);

            return(this);
        }
        /// <inheritdoc />
        public IAndRedirectTestBuilder WithRouteName(string routeName)
        {
            var redirectAtRouteResult = this.GetRedirectResult <RedirectToRouteResult>("route name");

            RouteActionResultValidator.ValidateRouteName(
                redirectAtRouteResult,
                routeName,
                this.ThrowNewRedirectResultAssertionException);

            return(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Tests whether the <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/> has specific route name.
        /// </summary>
        /// <param name="baseTestBuilderWithRouteValuesResult">
        /// Instance of <see cref="IBaseTestBuilderWithRouteValuesResult{TRouteValuesResultTestBuilder}"/> type.
        /// </param>
        /// <param name="routeName">Expected route name.</param>
        /// <returns>The same route values <see cref="Microsoft.AspNetCore.Mvc.ActionResult"/> test builder.</returns>
        public static TRouteValuesResultTestBuilder WithRouteName <TRouteValuesResultTestBuilder>(
            this IBaseTestBuilderWithRouteValuesResult <TRouteValuesResultTestBuilder> baseTestBuilderWithRouteValuesResult,
            string routeName)
            where TRouteValuesResultTestBuilder : IBaseTestBuilderWithActionResult
        {
            var actualBuilder = GetActualBuilder(baseTestBuilderWithRouteValuesResult);

            RouteActionResultValidator.ValidateRouteName(
                actualBuilder.TestContext.MethodResult,
                routeName,
                actualBuilder.ThrowNewFailedValidationException);

            return(actualBuilder.ResultTestBuilder);
        }