From 3770906c3bc3a782abb0cbc1a120d236c0722f92 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 1 Aug 2014 14:12:15 -0700 Subject: [PATCH] Issue #862 Extensibility for action invoker --- .../FilterActionInvoker.cs | 106 ++++-------------- .../IActionInvoker.cs | 2 +- .../Microsoft.AspNet.Mvc.Core.kproj | 3 +- .../MvcRouteHandler.cs | 2 +- .../ReflectedActionInvoker.cs | 84 ++++++++++++++ .../ReflectedActionInvokerProvider.cs | 6 +- .../Microsoft.AspNet.Mvc.Core.Test.kproj | 2 +- .../MvcRouteHandlerTests.cs | 2 +- .../ReflectedActionInvokerTest.cs | 96 ++++++++-------- 9 files changed, 165 insertions(+), 138 deletions(-) create mode 100644 src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs diff --git a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs index 77b59bb781..0c753ff0e3 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FilterActionInvoker.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// 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; @@ -13,11 +13,8 @@ using Microsoft.Framework.DependencyInjection; namespace Microsoft.AspNet.Mvc { - public class ReflectedActionInvoker : IActionInvoker + public abstract class FilterActionInvoker : IActionInvoker { - private readonly ActionContext _actionContext; - private readonly ReflectedActionDescriptor _descriptor; - private readonly IControllerFactory _controllerFactory; private readonly IActionBindingContextProvider _bindingProvider; private readonly INestedProviderManager _filterProvider; @@ -34,31 +31,22 @@ namespace Microsoft.AspNet.Mvc private ResultExecutingContext _resultExecutingContext; private ResultExecutedContext _resultExecutedContext; - public ReflectedActionInvoker([NotNull] ActionContext actionContext, - [NotNull] ReflectedActionDescriptor descriptor, - [NotNull] IControllerFactory controllerFactory, - [NotNull] IActionBindingContextProvider bindingContextProvider, - [NotNull] INestedProviderManager filterProvider) + public FilterActionInvoker( + [NotNull] ActionContext actionContext, + [NotNull] IActionBindingContextProvider bindingContextProvider, + [NotNull] INestedProviderManager filterProvider) { - _actionContext = actionContext; - _descriptor = descriptor; - _controllerFactory = controllerFactory; + ActionContext = actionContext; _bindingProvider = bindingContextProvider; _filterProvider = filterProvider; - - if (descriptor.MethodInfo == null) - { - throw new ArgumentException( - Resources.FormatPropertyOfTypeCannotBeNull("MethodInfo", - typeof(ReflectedActionDescriptor)), - "descriptor"); - } } - public async Task InvokeActionAsync() - { - _actionContext.Controller = _controllerFactory.CreateController(_actionContext); + protected ActionContext ActionContext { get; private set; } + protected abstract Task InvokeActionAsync(ActionExecutingContext actionExecutingContext); + + public virtual async Task InvokeAsync() + { _filters = GetFilters(); _cursor = new FilterCursor(_filters); @@ -69,11 +57,11 @@ namespace Microsoft.AspNet.Mvc // result filters around it. if (_authorizationContext.Result != null) { - await _authorizationContext.Result.ExecuteResultAsync(_actionContext); + await _authorizationContext.Result.ExecuteResultAsync(ActionContext); } else if (_exceptionContext.Result != null) { - await _exceptionContext.Result.ExecuteResultAsync(_actionContext); + await _exceptionContext.Result.ExecuteResultAsync(ActionContext); } else if (_exceptionContext.Exception != null) { @@ -96,41 +84,11 @@ namespace Microsoft.AspNet.Mvc } } - // Marking as internal for Unit Testing purposes. - internal static IActionResult CreateActionResult([NotNull] Type declaredReturnType, object actionReturnValue) - { - // optimize common path - var actionResult = actionReturnValue as IActionResult; - if (actionResult != null) - { - return actionResult; - } - - if (declaredReturnType == typeof(void) || - declaredReturnType == typeof(Task)) - { - return new NoContentResult(); - } - - // Unwrap potential Task types. - var actualReturnType = TypeHelper.GetTaskInnerTypeOrNull(declaredReturnType) ?? declaredReturnType; - if (actionReturnValue == null && typeof(IActionResult).IsAssignableFrom(actualReturnType)) - { - throw new InvalidOperationException( - Resources.FormatActionResult_ActionReturnValueCannotBeNull(actualReturnType)); - } - - return new ObjectResult(actionReturnValue) - { - DeclaredType = actualReturnType - }; - } - private IFilter[] GetFilters() { var filterProviderContext = new FilterProviderContext( - _actionContext, - _descriptor.FilterDescriptors.Select(fd => new FilterItem(fd)).ToList()); + ActionContext, + ActionContext.ActionDescriptor.FilterDescriptors.Select(fd => new FilterItem(fd)).ToList()); _filterProvider.Invoke(filterProviderContext); @@ -183,7 +141,7 @@ namespace Microsoft.AspNet.Mvc // 1) Call the filter (if we have an exception) // 2) No-op (if we don't have an exception) Contract.Assert(_exceptionContext == null); - _exceptionContext = new ExceptionContext(_actionContext, _filters); + _exceptionContext = new ExceptionContext(ActionContext, _filters); try { @@ -218,7 +176,7 @@ namespace Microsoft.AspNet.Mvc { _cursor.SetStage(FilterStage.AuthorizationFilters); - _authorizationContext = new AuthorizationContext(_actionContext, _filters); + _authorizationContext = new AuthorizationContext(ActionContext, _filters); await InvokeAuthorizationFilter(); } @@ -260,16 +218,16 @@ namespace Microsoft.AspNet.Mvc { _cursor.SetStage(FilterStage.ActionFilters); - var arguments = await GetActionArguments(_actionContext.ModelState); - _actionExecutingContext = new ActionExecutingContext(_actionContext, _filters, arguments); + var arguments = await GetActionArguments(ActionContext.ModelState); + _actionExecutingContext = new ActionExecutingContext(ActionContext, _filters, arguments); await InvokeActionMethodFilter(); } internal async Task> GetActionArguments(ModelStateDictionary modelState) { - var actionBindingContext = await _bindingProvider.GetActionBindingContextAsync(_actionContext); - var parameters = _descriptor.Parameters; + var actionBindingContext = await _bindingProvider.GetActionBindingContextAsync(ActionContext); + var parameters = ActionContext.ActionDescriptor.Parameters; var metadataProvider = actionBindingContext.MetadataProvider; var parameterValues = new Dictionary(parameters.Count, StringComparer.Ordinal); @@ -380,7 +338,7 @@ namespace Microsoft.AspNet.Mvc // All action filters have run, execute the action method. _actionExecutedContext = new ActionExecutedContext(_actionExecutingContext, _filters) { - Result = await InvokeActionMethod() + Result = await InvokeActionAsync(_actionExecutingContext), }; } } @@ -395,27 +353,11 @@ namespace Microsoft.AspNet.Mvc return _actionExecutedContext; } - private async Task InvokeActionMethod() - { - _cursor.SetStage(FilterStage.ActionMethod); - - var actionMethodInfo = _descriptor.MethodInfo; - var actionReturnValue = await ReflectedActionExecutor.ExecuteAsync( - actionMethodInfo, - _actionContext.Controller, - _actionExecutingContext.ActionArguments); - - var actionResult = CreateActionResult( - actionMethodInfo.ReturnType, - actionReturnValue); - return actionResult; - } - private async Task InvokeActionResultWithFilters(IActionResult result) { _cursor.SetStage(FilterStage.ResultFilters); - _resultExecutingContext = new ResultExecutingContext(_actionContext, _filters, result); + _resultExecutingContext = new ResultExecutingContext(ActionContext, _filters, result); await InvokeActionResultFilter(); Contract.Assert(_resultExecutingContext != null); diff --git a/src/Microsoft.AspNet.Mvc.Core/IActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/IActionInvoker.cs index edaad6f411..cdab5f9661 100644 --- a/src/Microsoft.AspNet.Mvc.Core/IActionInvoker.cs +++ b/src/Microsoft.AspNet.Mvc.Core/IActionInvoker.cs @@ -7,6 +7,6 @@ namespace Microsoft.AspNet.Mvc { public interface IActionInvoker { - Task InvokeActionAsync(); + Task InvokeAsync(); } } diff --git a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj index befb025512..74a333ce67 100644 --- a/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj +++ b/src/Microsoft.AspNet.Mvc.Core/Microsoft.AspNet.Mvc.Core.kproj @@ -47,6 +47,7 @@ + @@ -286,4 +287,4 @@ - \ No newline at end of file + diff --git a/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs index d248f16fb0..3a35dbfa69 100644 --- a/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs +++ b/src/Microsoft.AspNet.Mvc.Core/MvcRouteHandler.cs @@ -99,7 +99,7 @@ namespace Microsoft.AspNet.Mvc throw ex; } - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); context.IsHandled = true; if (_logger.IsEnabled(TraceType.Information)) diff --git a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs new file mode 100644 index 0000000000..85a385d344 --- /dev/null +++ b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvoker.cs @@ -0,0 +1,84 @@ +// 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; +using System.Threading.Tasks; +using Microsoft.AspNet.Mvc.Core; +using Microsoft.Framework.DependencyInjection; + +namespace Microsoft.AspNet.Mvc +{ + public class ReflectedActionInvoker : FilterActionInvoker + { + private readonly ReflectedActionDescriptor _descriptor; + private readonly IControllerFactory _controllerFactory; + public ReflectedActionInvoker([NotNull] ActionContext actionContext, + [NotNull] IActionBindingContextProvider bindingContextProvider, + [NotNull] INestedProviderManager filterProvider, + [NotNull] IControllerFactory controllerFactory, + [NotNull] ReflectedActionDescriptor descriptor) + : base(actionContext, bindingContextProvider, filterProvider) + { + _descriptor = descriptor; + _controllerFactory = controllerFactory; + + if (descriptor.MethodInfo == null) + { + throw new ArgumentException( + Resources.FormatPropertyOfTypeCannotBeNull("MethodInfo", + typeof(ReflectedActionDescriptor)), + "descriptor"); + } + } + + public override Task InvokeAsync() + { + ActionContext.Controller = _controllerFactory.CreateController(ActionContext); + return base.InvokeAsync(); + } + + protected override async Task InvokeActionAsync(ActionExecutingContext actionExecutingContext) + { + var actionMethodInfo = _descriptor.MethodInfo; + var actionReturnValue = await ReflectedActionExecutor.ExecuteAsync( + actionMethodInfo, + ActionContext.Controller, + actionExecutingContext.ActionArguments); + + var actionResult = CreateActionResult( + actionMethodInfo.ReturnType, + actionReturnValue); + return actionResult; + } + + // Marking as internal for Unit Testing purposes. + internal static IActionResult CreateActionResult([NotNull] Type declaredReturnType, object actionReturnValue) + { + // optimize common path + var actionResult = actionReturnValue as IActionResult; + if (actionResult != null) + { + return actionResult; + } + + if (declaredReturnType == typeof(void) || + declaredReturnType == typeof(Task)) + { + return new NoContentResult(); + } + + // Unwrap potential Task types. + var actualReturnType = TypeHelper.GetTaskInnerTypeOrNull(declaredReturnType) ?? declaredReturnType; + if (actionReturnValue == null && typeof(IActionResult).IsAssignableFrom(actualReturnType)) + { + throw new InvalidOperationException( + Resources.FormatActionResult_ActionReturnValueCannotBeNull(actualReturnType)); + } + + return new ObjectResult(actionReturnValue) + { + DeclaredType = actualReturnType + }; + } + } +} diff --git a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvokerProvider.cs b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvokerProvider.cs index c42754a6a8..596c071335 100644 --- a/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvokerProvider.cs +++ b/src/Microsoft.AspNet.Mvc.Core/ReflectedActionInvokerProvider.cs @@ -34,10 +34,10 @@ namespace Microsoft.AspNet.Mvc { context.Result = new ReflectedActionInvoker( context.ActionContext, - actionDescriptor, - _controllerFactory, _bindingProvider, - _filterProvider); + _filterProvider, + _controllerFactory, + actionDescriptor); } callNext(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj b/test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj index 8040731a17..8c21609ea7 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj +++ b/test/Microsoft.AspNet.Mvc.Core.Test/Microsoft.AspNet.Mvc.Core.Test.kproj @@ -107,7 +107,6 @@ - @@ -115,6 +114,7 @@ + diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs b/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs index 794445bd2d..2ef9808e75 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/MvcRouteHandlerTests.cs @@ -168,7 +168,7 @@ namespace Microsoft.AspNet.Mvc if (invokerFactory == null) { var mockInvoker = new Mock(); - mockInvoker.Setup(i => i.InvokeActionAsync()) + mockInvoker.Setup(i => i.InvokeAsync()) .Returns(Task.FromResult(null)); var mockInvokerFactory = new Mock(); diff --git a/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs b/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs index a1dcec7e7c..4850b3fad1 100644 --- a/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs +++ b/test/Microsoft.AspNet.Mvc.Core.Test/ReflectedActionInvokerTest.cs @@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object, actionThrows: false); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnException(It.IsAny()), Times.Never()); @@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object, actionThrows: false); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify( @@ -91,7 +91,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnException(It.IsAny()), Times.Once()); @@ -124,7 +124,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify( @@ -154,7 +154,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new[] { filter1.Object, filter2.Object }, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter2.Verify( @@ -182,7 +182,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object }, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter2.Verify( @@ -202,7 +202,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object, actionThrows: true); // Act - await Assert.ThrowsAsync(_actionException.GetType(), async () => await invoker.InvokeActionAsync()); + await Assert.ThrowsAsync(_actionException.GetType(), async () => await invoker.InvokeAsync()); // Assert filter.Verify(f => f.OnException(It.IsAny()), Times.Once()); @@ -229,7 +229,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter.Object, resultFilter.Object }, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnException(It.IsAny()), Times.Once()); @@ -246,7 +246,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnAuthorization(It.IsAny()), Times.Once()); @@ -265,7 +265,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify( @@ -290,7 +290,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new[] { filter1.Object, filter2.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify(f => f.OnAuthorization(It.IsAny()), Times.Once()); @@ -317,7 +317,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify( @@ -365,7 +365,7 @@ namespace Microsoft.AspNet.Mvc }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert exceptionFilter.Verify(f => f.OnException(It.IsAny()), Times.Once()); @@ -393,7 +393,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { authorizationFilter.Object, resultFilter.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert authorizationFilter.Verify(f => f.OnAuthorization(It.IsAny()), Times.Once()); @@ -416,7 +416,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -444,7 +444,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify( @@ -490,7 +490,7 @@ namespace Microsoft.AspNet.Mvc }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert actionFilter1.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -546,7 +546,7 @@ namespace Microsoft.AspNet.Mvc }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert actionFilter1.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -601,7 +601,7 @@ namespace Microsoft.AspNet.Mvc }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert actionFilter1.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -641,7 +641,7 @@ namespace Microsoft.AspNet.Mvc // Act & Assert await ExceptionAssert.ThrowsAsync( - async () => await invoker.InvokeActionAsync(), + async () => await invoker.InvokeAsync(), message); } @@ -668,7 +668,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -709,7 +709,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new[] { filter1.Object, filter2.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -751,7 +751,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify( @@ -795,7 +795,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { actionFilter.Object, resultFilter.Object }, actionThrows: true); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert actionFilter.Verify(f => f.OnActionExecuting(It.IsAny()), Times.Once()); @@ -818,7 +818,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify(f => f.OnResultExecuting(It.IsAny()), Times.Once()); @@ -838,7 +838,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter.Verify( @@ -874,7 +874,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object, filter3.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify(f => f.OnResultExecuting(It.IsAny()), Times.Once()); @@ -914,7 +914,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object, filter3.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify(f => f.OnResultExecuting(It.IsAny()), Times.Once()); @@ -956,7 +956,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { filter1.Object, filter2.Object, filter3.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert filter1.Verify(f => f.OnResultExecuting(It.IsAny()), Times.Once()); @@ -994,7 +994,7 @@ namespace Microsoft.AspNet.Mvc // Act & Assert await ExceptionAssert.ThrowsAsync( - async () => await invoker.InvokeActionAsync(), + async () => await invoker.InvokeAsync(), message); } @@ -1021,7 +1021,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await Assert.ThrowsAsync(exception.GetType(), async () => await invoker.InvokeActionAsync()); + await Assert.ThrowsAsync(exception.GetType(), async () => await invoker.InvokeAsync()); // Assert result.Verify(r => r.ExecuteResultAsync(It.IsAny()), Times.Once()); @@ -1064,7 +1064,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert Assert.Equal(exception, context.Exception); @@ -1106,7 +1106,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(filter.Object); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert Assert.Equal(exception, context.Exception); @@ -1150,7 +1150,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { resultFilter1.Object, resultFilter2.Object, resultFilter3.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert Assert.Equal(exception, context.Exception); @@ -1192,7 +1192,7 @@ namespace Microsoft.AspNet.Mvc var invoker = CreateInvoker(new IFilter[] { resultFilter1.Object, resultFilter2.Object, resultFilter3.Object }); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert Assert.Equal(exception, context.Exception); @@ -1319,10 +1319,10 @@ namespace Microsoft.AspNet.Mvc var invoker = new ReflectedActionInvoker( actionContext, - actionDescriptor, - controllerFactory.Object, actionBindingContextProvider.Object, - filterProvider.Object); + filterProvider.Object, + controllerFactory.Object, + actionDescriptor); return invoker; } @@ -1361,10 +1361,10 @@ namespace Microsoft.AspNet.Mvc .Returns(Task.FromResult(bindingContext)); var invoker = new ReflectedActionInvoker(actionContext, - actionDescriptor, - Mock.Of(), actionBindingContextProvider.Object, - Mock.Of>()); + Mock.Of>(), + Mock.Of(), + actionDescriptor); var modelStateDictionary = new ModelStateDictionary(); @@ -1417,10 +1417,10 @@ namespace Microsoft.AspNet.Mvc .Returns(Task.FromResult(bindingContext)); var invoker = new ReflectedActionInvoker(actionContext, - actionDescriptor, - Mock.Of(), actionBindingContextProvider.Object, - Mock.Of>()); + Mock.Of>(), + Mock.Of(), + actionDescriptor); var modelStateDictionary = new ModelStateDictionary(); @@ -1477,13 +1477,13 @@ namespace Microsoft.AspNet.Mvc .Returns(new TestController()); var invoker = new ReflectedActionInvoker(actionContext, - actionDescriptor, - controllerFactory.Object, actionBindingContextProvider.Object, - Mock.Of>()); + Mock.Of>(), + controllerFactory.Object, + actionDescriptor); // Act - await invoker.InvokeActionAsync(); + await invoker.InvokeAsync(); // Assert Assert.Equal(5, context.Object.Items["Result"]);