/// <summary> /// Tests whether the action result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponentResult"/> /// with the same view component type and arguments as the provided ones. /// </summary> /// <typeparam name="TActionResult">Type of the action result.</typeparam> /// <param name="shouldReturnTestBuilder">Instance of <see cref="IShouldReturnTestBuilder{TActionResult}"/> type.</param> /// <param name="componentType">Expected view component type.</param> /// <param name="arguments">Expected view component arguments.</param> /// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns> public static IAndTestBuilder ViewComponent <TActionResult>( this IShouldReturnTestBuilder <TActionResult> shouldReturnTestBuilder, Type componentType, object arguments) => shouldReturnTestBuilder .ViewComponent(viewComponent => viewComponent .OfType(componentType) .ContainingArguments(arguments));
/// <summary> /// Tests whether the action result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponentResult"/> /// with the same view component name and arguments as the provided ones. /// </summary> /// <typeparam name="TActionResult">Type of the action result.</typeparam> /// <param name="shouldReturnTestBuilder">Instance of <see cref="IShouldReturnTestBuilder{TActionResult}"/> type.</param> /// <param name="componentName">Expected view component name.</param> /// <param name="arguments">Expected view component arguments.</param> /// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns> public static IAndTestBuilder ViewComponent <TActionResult>( this IShouldReturnTestBuilder <TActionResult> shouldReturnTestBuilder, string componentName, object arguments) => shouldReturnTestBuilder .ViewComponent(viewComponent => viewComponent .WithName(componentName) .ContainingArguments(arguments));
/// <summary> /// Tests whether the action result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponentResult"/> /// with the same view component name as the provided one. /// </summary> /// <typeparam name="TActionResult">Type of the action result.</typeparam> /// <param name="shouldReturnTestBuilder">Instance of <see cref="IShouldReturnTestBuilder{TActionResult}"/> type.</param> /// <param name="componentName">Expected view component name.</param> /// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns> public static IAndTestBuilder ViewComponent <TActionResult>( this IShouldReturnTestBuilder <TActionResult> shouldReturnTestBuilder, string componentName) => shouldReturnTestBuilder .ViewComponent(viewComponent => viewComponent .WithName(componentName));
/// <summary> /// Tests whether the action result is <see cref="Microsoft.AspNetCore.Mvc.ViewComponentResult"/> /// with the same view component type as the provided one. /// </summary> /// <typeparam name="TActionResult">Type of the action result.</typeparam> /// <param name="shouldReturnTestBuilder">Instance of <see cref="IShouldReturnTestBuilder{TActionResult}"/> type.</param> /// <param name="componentType">Expected view component type.</param> /// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns> public static IAndTestBuilder ViewComponent <TActionResult>( this IShouldReturnTestBuilder <TActionResult> shouldReturnTestBuilder, Type componentType) => shouldReturnTestBuilder .ViewComponent(viewComponent => viewComponent .OfType(componentType));
/// <summary> /// Tests whether the action result is <see cref="ViewComponentResult"/>. /// </summary> /// <typeparam name="TActionResult">Type of action result type.</typeparam> /// <param name="builder">Instance of <see cref="IShouldReturnTestBuilder{TActionResult}"/> type.</param> /// <returns>Test builder of <see cref="IAndTestBuilder"/> type.</returns> public static IAndTestBuilder ViewComponent <TActionResult>( this IShouldReturnTestBuilder <TActionResult> builder) => builder.ViewComponent(null);