public void BadRequest_WithNoArgs_ResultHasCorrectValues() { // Act var result = TypedResults.BadRequest(); // Assert Assert.Equal(StatusCodes.Status400BadRequest, result.StatusCode); }
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); }
/// <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);
/// <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);