Ejemplo n.º 1
0
    public void AcceptedAtRoute_WithNoArgs_ResultHasCorrectValues()
    {
        // Act
        var result = TypedResults.AcceptedAtRoute();

        // Assert
        Assert.Equal(StatusCodes.Status202Accepted, result.StatusCode);
        Assert.Null(result.RouteName);
        Assert.NotNull(result.RouteValues);
    }
Ejemplo n.º 2
0
    public void AcceptedAtRoute_WithRouteNameAndRouteValues_ResultHasCorrectValues()
    {
        // Arrange
        var routeName   = "routeName";
        var routeValues = new { foo = 123 };

        // Act
        var result = TypedResults.AcceptedAtRoute(routeName, routeValues);

        // Assert
        Assert.Equal(StatusCodes.Status202Accepted, result.StatusCode);
        Assert.Equal(routeName, result.RouteName);
        Assert.Equal(new RouteValueDictionary(routeValues), result.RouteValues);
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Produces a <see cref="StatusCodes.Status202Accepted"/> response.
 /// </summary>
 /// <param name="routeName">The name of the route to use for generating the URL.</param>
 /// <param name="routeValues">The route data to use for generating the URL.</param>
 /// <param name="value">The optional content value to format in the response body.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 public static IResult AcceptedAtRoute(string?routeName = null, object?routeValues = null, object?value = null)
 => value is null?TypedResults.AcceptedAtRoute(routeName, routeValues) : TypedResults.AcceptedAtRoute(value, routeName, routeValues);
Ejemplo n.º 4
0
    /// <summary>
    /// Produces a <see cref="StatusCodes.Status202Accepted"/> response.
    /// </summary>
    /// <param name="routeName">The name of the route to use for generating the URL.</param>
    /// <param name="routeValues">The route data to use for generating the URL.</param>
    /// <param name="value">The optional content value to format in the response body.</param>
    /// <returns>The created <see cref="IResult"/> for the response.</returns>
#pragma warning disable RS0026 // Do not add multiple public overloads with optional parameters
    public static IResult AcceptedAtRoute <TValue>(string?routeName = null, object?routeValues = null, TValue?value = default)
#pragma warning restore RS0026 // Do not add multiple public overloads with optional parameters
    => value is null?TypedResults.AcceptedAtRoute(routeName, routeValues) : TypedResults.AcceptedAtRoute(value, routeName, routeValues);