* Add NoContent Factory to Controller

This commit is contained in:
ryanbrandenburg 2015-11-12 10:27:03 -08:00
parent ed46885586
commit b8d58133c3
2 changed files with 24 additions and 0 deletions

View File

@ -508,6 +508,17 @@ namespace Microsoft.AspNet.Mvc
return result;
}
/// <summary>
/// Creates a <see cref="NoContentResult"/> object that produces an empty No Content (204) response.
/// </summary>
/// <returns>The created <see cref="NoContentResult"/> object for the response.</returns>
[NonAction]
public virtual NoContentResult NoContent()
{
return new NoContentResult();
}
/// <summary>
/// Creates a <see cref="JsonResult"/> object that serializes the specified <paramref name="data"/> object
/// to JSON.

View File

@ -1055,6 +1055,19 @@ namespace Microsoft.AspNet.Mvc.Test
Assert.Same(model, actualViewResult.ViewData.Model);
}
[Fact]
public void Controller_NoContent()
{
// Arrange
var controller = new TestableController();
// Act
var result = controller.NoContent();
// Assert
Assert.Equal(StatusCodes.Status204NoContent, result.StatusCode);
}
[Fact]
public void Controller_Content_WithParameterContentString_SetsResultContent()
{