コード例 #1
0
    public void BadRequest_WithNoArgs_ResultHasCorrectValues()
    {
        // Act
        var result = TypedResults.BadRequest();

        // Assert
        Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode);
    }
コード例 #2
0
    public void BadRequest_WithValue_ResultHasCorrectValues()
    {
        // Arrange
        var value = new { };

        // Act
        var result = TypedResults.BadRequest(value);

        // Assert
        Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode);
        Assert.Equal(value, result.Value);
    }
コード例 #3
0
ファイル: Results.cs プロジェクト: fusionshen/AspNetCore
 /// <summary>
 /// Produces a <see cref="StatusCodes.Status400BadRequest"/> response.
 /// </summary>
 /// <param name="error">An error object to be included in the HTTP response body.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 public static IResult BadRequest(object?error = null)
 => error is null?TypedResults.BadRequest() : TypedResults.BadRequest(error);
コード例 #4
0
 /// <summary>
 /// Produces a <see cref="StatusCodes.Status400BadRequest"/> response.
 /// </summary>
 /// <param name="error">An error object to be included in the HTTP response body.</param>
 /// <returns>The created <see cref="IResult"/> for the response.</returns>
 public static IResult BadRequest <TValue>(TValue?error)
 => error is null?TypedResults.BadRequest() : TypedResults.BadRequest(error);