/// <inheritdoc />
        public IAndViewTestBuilder WithViewEngine(IViewEngine viewEngine)
        {
            var actualViewEngine = this.viewResult.ViewEngine;

            if (viewEngine != actualViewEngine)
            {
                throw ViewViewComponentResultAssertionException
                      .ForViewEngineEquality(this.TestContext.ExceptionMessagePrefix);
            }

            return(this);
        }
Esempio n. 2
0
        /// <summary>
        /// Tests whether <see cref="Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult"/>
        /// has the same <see cref="IViewEngine"/> as the provided one.
        /// </summary>
        /// <param name="viewTestBuilder">
        /// Instance of <see cref="IViewTestBuilder"/> type.
        /// </param>
        /// <param name="viewEngine">View engine of type <see cref="IViewEngine"/>.</param>
        /// <returns>The same <see cref="IAndViewTestBuilder"/>.</returns>
        public static IAndViewTestBuilder WithViewEngine(
            this IViewTestBuilder viewTestBuilder,
            IViewEngine viewEngine)
        {
            var actualBuilder = GetActualBuilder(viewTestBuilder);

            var actualViewEngine = actualBuilder.ViewResult.ViewEngine;

            if (viewEngine != actualViewEngine)
            {
                throw ViewViewComponentResultAssertionException
                      .ForViewEngineEquality(actualBuilder.TestContext.ExceptionMessagePrefix);
            }

            return(actualBuilder);
        }