-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add UnprocessableEntityResult, UnprocessableEntityObjectResult and ControllerBase.UnprocessableEntity methods #6851
Conversation
4713821
to
a8efc6d
Compare
a8efc6d
to
c059527
Compare
/// <summary> | ||
/// Creates a new <see cref="UnprocessableEntityObjectResult"/> instance. | ||
/// </summary> | ||
/// <param name="error">Contains the errors to be returned to the client.</param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contains the errors
public void UnprocessableEntityObjectResult_ModelState_SetsStatusCodeAndValue() | ||
{ | ||
// Arrange & Act | ||
var result = new UnprocessableEntityObjectResult(new ModelStateDictionary()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe toss in an error in to the MSD so we know it's the type that's being serialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no serialization in the test, and taht's fine. We don't need to overthink it
/// </summary> | ||
/// <returns>The created <see cref="UnprocessableEntityResult"/> for the response.</returns> | ||
[NonAction] | ||
public virtual UnprocessableEntityResult UnprocessableEntity() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public virtual UnprocessableEntityResult UnprocessableEntity() => new UnprocessableEntityResult()
for 💯 points
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are many other methods like this in the same class, it it worth the inconsistency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave this for #6864 😄
/// <summary> | ||
/// Creates an <see cref="UnprocessableEntityObjectResult"/> that produces a <see cref="StatusCodes.Status422UnprocessableEntity"/> response. | ||
/// </summary> | ||
/// <returns>The created <see cref="UnprocessableEntityObjectResult"/> for the response.</returns> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a <param >
Thanks for the PR! |
Closes #6795