Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Add UnprocessableEntityResult, UnprocessableEntityObjectResult and ControllerBase.UnprocessableEntity methods #6851

Merged
merged 4 commits into from
Sep 22, 2017

Conversation

khellang
Copy link
Contributor

Closes #6795

@khellang khellang force-pushed the unprocessable-entity branch from 4713821 to a8efc6d Compare September 19, 2017 07:57
@khellang khellang force-pushed the unprocessable-entity branch from a8efc6d to c059527 Compare September 19, 2017 08:01
/// <summary>
/// Creates a new <see cref="UnprocessableEntityObjectResult"/> instance.
/// </summary>
/// <param name="error">Contains the errors to be returned to the client.</param>
Copy link
Contributor

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());
Copy link
Contributor

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.

Copy link
Member

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()
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a <param >

@pranavkm pranavkm merged commit 97fab87 into aspnet:dev Sep 22, 2017
@pranavkm
Copy link
Contributor

Thanks for the PR!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants