diff --git a/src/Microsoft.AspNet.Mvc.Core/ActionResults/EmptyResult.cs b/src/Microsoft.AspNet.Mvc.Core/ActionResults/EmptyResult.cs index 9bc0f03431..4002180cd9 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ActionResults/EmptyResult.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ActionResults/EmptyResult.cs @@ -1,10 +1,12 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Threading.Tasks; - namespace Microsoft.AspNet.Mvc { + /// + /// Represents an that when executed will + /// do nothing. + /// public class EmptyResult : ActionResult { private static readonly EmptyResult _singleton = new EmptyResult(); @@ -14,9 +16,9 @@ namespace Microsoft.AspNet.Mvc get { return _singleton; } } + /// public override void ExecuteResult([NotNull] ActionContext context) { - context.HttpContext.Response.StatusCode = 204; } } } diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/EmptyResultTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/EmptyResultTests.cs new file mode 100644 index 0000000000..f6cb2d9f2f --- /dev/null +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ActionResults/EmptyResultTests.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.AspNet.Http; +using Microsoft.AspNet.Routing; +using Moq; +using Xunit; + +namespace Microsoft.AspNet.Mvc +{ + public class EmptyResultTests + { + [Fact] + public void EmptyResult_ExecuteResult_IsANoOp() + { + // Arrange + var emptyResult = new EmptyResult(); + + var httpContext = new Mock(MockBehavior.Strict); + var routeData = new RouteData(); + var actionDescriptor = new ActionDescriptor(); + + var context = new ActionContext(httpContext.Object, routeData, actionDescriptor); + + // Act & Assert + Assert.DoesNotThrow(() => emptyResult.ExecuteResult(context)); + } + } +} \ No newline at end of file