public void PublishMessageWithRuntimePolicyOn(AsyncActionInvoker.EndInvokeActionMethod sut, IAlternateMethodContext context, ActionDescriptor actionDescriptor) { var actionDescriptorMock = new Mock<ActionDescriptor>(); actionDescriptorMock.Setup(a => a.ControllerDescriptor).Returns(new ReflectedControllerDescriptor(typeof(DummyController))); actionDescriptorMock.Setup(a => a.ActionName).Returns("Index"); context.Setup(c => c.ReturnValue).Returns(new ContentResult()); context.Setup(c => c.Proxy).Returns( new ActionInvokerStateMixin { Offset = TimeSpan.Zero, Arguments = new ActionInvoker.InvokeActionMethod.Arguments(new ControllerContext(), actionDescriptor, new Dictionary<string, object>()) }); context.Setup(c => c.Arguments).Returns(new object[] { new ControllerContext(), actionDescriptorMock.Object, new Dictionary<string, object>() }); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(b => b.Publish(It.IsAny<ActionInvoker.InvokeActionMethod.Message>())); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { context.MessageBroker.Publish( new Message(new Arguments(context.Arguments), context.InvocationTarget.GetHashCode(), (bool)context.ReturnValue) .AsTimedMessage(timerResult) .AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget)); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var original = context.ReturnValue as IValueProvider; if (original == null) { return; } var originalUnvalidatedValueProvider = original as IUnvalidatedValueProvider; if (originalUnvalidatedValueProvider != null) { IUnvalidatedValueProvider newUnvalidatedValueProvider; if (AlternateUnvalidatedValueProvider.TryCreate(originalUnvalidatedValueProvider, out newUnvalidatedValueProvider)) { context.ReturnValue = newUnvalidatedValueProvider; return; } } IValueProvider newValueProvider; if (AlternateValidatedValueProvider.TryCreate(original, out newValueProvider)) { context.ReturnValue = newValueProvider; } }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var displayInfo = context.ReturnValue as DisplayInfo; var message = new Message(displayInfo.DisplayMode.DisplayModeId, displayInfo.FilePath); context.MessageBroker.Publish(message); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { context.MessageBroker.Publish(new Message( new Arguments(context.Arguments), context.InvocationTarget, (System.Web.Routing.VirtualPathData)context.ReturnValue) .AsTimedMessage(timerResult) .AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget)); }
public void NewImplementation(IAlternateMethodContext context) { if (context.RuntimePolicyStrategy() == RuntimePolicy.Off) { context.Proceed(); return; } context.Proceed(); var state = (IActionInvokerStateMixin)context.Proxy; var timer = context.TimerStrategy(); var timerResult = timer.Stop(state.Offset); var args = state.Arguments; var actionDescriptor = args.ActionDescriptor; var controllerDescriptor = args.ActionDescriptor.ControllerDescriptor; var actionName = actionDescriptor.ActionName; var actionParams = actionDescriptor.GetParameters().Select(p => p.ParameterType).ToArray(); var message = new ActionInvoker.InvokeActionMethod.Message(context.ReturnValue.GetType()) .AsTimedMessage(timerResult) .AsSourceMessage(controllerDescriptor.ControllerType, controllerDescriptor.ControllerType.GetMethod(actionName, actionParams) ?? controllerDescriptor.ControllerType.GetMethod(actionName + "Async", actionParams)) .AsChildActionMessage(state.Arguments.ControllerContext) .AsActionMessage(state.Arguments.ControllerContext) .AsMvcTimelineMessage(MvcTimelineCategory.Controller); context.MessageBroker.Publish(message); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var args = new Arguments(IsPartial, context.Arguments); var id = Guid.NewGuid(); var output = context.ReturnValue as ViewEngineResult; output = ProxyOutput(output, context, args.ViewName, IsPartial, id); string displayModeId = null; Type displayModeType = null; #if MVC4 var displayMode = args.ControllerContext.DisplayMode; if (displayMode != null) { displayModeId = displayMode.DisplayModeId; displayModeType = displayMode.GetType(); } #endif var message = new Message(id, args.ViewName, args.MasterName, args.UseCache, output.SearchedLocations, context.TargetType, IsPartial, output.View != null, displayModeId, displayModeType) .AsActionMessage(args.ControllerContext) .AsChildActionMessage(args.ControllerContext) .AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget) .AsTimedMessage(timerResult); context.MessageBroker.Publish(message); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var message = new Message((string)context.Arguments[0], (bool)context.ReturnValue, context.TargetType) .AsSourceMessage(context.TargetType, context.MethodInvocationTarget); context.MessageBroker.Publish(message); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var displayInfo = context.Arguments[0] as DisplayInfo; var master = context.ReturnValue as string; var message = new Message(displayInfo.DisplayMode.DisplayModeId, master); context.MessageBroker.Publish(message); }
public void PublishMessageIfRuntimePolicyOn(ControllerFactory.CreateController sut, IAlternateMethodContext context, RequestContext requestContext, string controllerName) { context.Setup(c => c.Arguments).Returns(new object[] { requestContext, controllerName }); sut.NewImplementation(context); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<ControllerFactory.CreateController.Message>())); }
public void ProceedIfRuntimePolicyIsOff(ViewEngine.FindViews sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var args = new Arguments(context.Arguments); var message = new Message(args.Key, context.ReturnValue as ValueProviderResult, context.TargetType) .AsSourceMessage(context.TargetType, context.MethodInvocationTarget); context.MessageBroker.Publish(message); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var args = new Arguments(context.Arguments); var messages = new Message(args.PropertyDescriptor, context.TargetType) .AsSourceMessage(context.TargetType, context.MethodInvocationTarget); context.MessageBroker.Publish(messages); }
public void ProceedIfRuntimePolicyIsOff(ViewEngine.FindViews sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { IModelBinder newModelBinder; if (AlternateModelBinder.TryCreate(context.ReturnValue as IModelBinder, out newModelBinder)) { context.ReturnValue = newModelBinder; } }
public void ProccedAndReturnWithRuntimePolicyOff(ActionInvoker.InvokeActionMethod sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(b => b.Publish(It.IsAny<ActionInvoker.InvokeActionMethod.Message>()), Times.Never()); }
public void ProceedWithOffPolicy(View.Render sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>()), Times.Never()); }
public void ProceedAndReturnWithRuntimePolicyOff(ValueProviderFactory.GetValueProvider sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<object>()), Times.Never()); }
public void PublishMessageWithRuntimePolicyOn(DependencyResolver.GetService sut, IAlternateMethodContext context) { context.Setup(c => c.Arguments).Returns(new object[] { typeof(IController) }); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(b => b.Publish(It.IsAny<DependencyResolver.GetService.Message>())); }
public void ProceedAndReturnWithRuntimePolicyOff(AsyncActionInvoker.BeginInvokeActionMethod sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.Verify(c => c.Proxy, Times.Never()); }
public void ProceedImmediatlyIfRuntimePolicyOff(ControllerFactory.CreateController sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<ControllerFactory.CreateController.Message>()), Times.Never()); }
public void ProceedAndReturnWithRuntimePolicyOff(ModelBinder.BindModel sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny <object>()), Times.Never()); }
public void ProceedWithOffPolicy(View.Render sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.TimerStrategy().Verify(t => t.Time(It.IsAny <Action>()), Times.Never()); }
public void ProceedAndPublishMessageWithRuntimePolicyOn(ModelBinder.BindProperty sut, IAlternateMethodContext context, ControllerContext controllerContext, ModelBindingContext modelBindingContext, PropertyDescriptor propertyDescriptor) { context.Setup(c => c.Arguments).Returns(new object[] { controllerContext, modelBindingContext, propertyDescriptor }); sut.NewImplementation(context); context.TimerStrategy().Verify(c => c.Time(It.IsAny<Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<ModelBinder.BindProperty.Message>())); }
public void ProceedPublishMessageWithRuntimePolicyOn(ModelBinder.BindModel sut, IAlternateMethodContext context, ControllerContext arg1, ModelBindingContext arg2) { context.Setup(c => c.Arguments).Returns(new object[] { arg1, arg2 }); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<ModelBinder.BindModel.Message>())); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var mixin = (IRouteNameMixin)context.Proxy; context.MessageBroker.Publish( new Message(context.Proxy.GetHashCode(), (System.Web.Routing.RouteData)context.ReturnValue, mixin.Name) .AsTimedMessage(timerResult) .AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget)); }
public void PublishMessagesIfRuntimePolicyIsOnAndViewNotFound(ViewEngine.FindViews sut, IAlternateMethodContext context, ControllerContext controllerContext) { context.Setup(c => c.Arguments).Returns(GetArguments(controllerContext)); context.Setup(c => c.TargetType).Returns(typeof(int)); context.Setup(c => c.ReturnValue).Returns(new ViewEngineResult(Enumerable.Empty<string>())); sut.NewImplementation(context); context.MessageBroker.Verify(b => b.Publish(It.IsAny<ViewEngine.FindViews.Message>())); }
public void PublishMessagesWithOnPolicy(View.Render sut, IAlternateMethodContext context, IViewCorrelationMixin mixin, ViewContext viewContext) { context.Setup(c => c.Arguments).Returns(new object[] { viewContext, new StringWriter() }); context.Setup(c => c.Proxy).Returns(mixin); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(b => b.Publish(It.IsAny<View.Render.Message>())); }
public void PublishMessageOnGetServices(DependencyResolver.GetServices sut, IAlternateMethodContext context) { context.Setup(c => c.Arguments).Returns(new object[] { typeof(string) }); context.Setup(c => c.ReturnValue).Returns(Enumerable.Empty<object>()); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(b => b.Publish(It.IsAny<DependencyResolver.GetServices.Message>())); }
public void ProceedWithRuntimePolicyOff(DependencyResolver.GetService sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.Verify(c => c.ReturnValue, Times.Never()); context.Verify(c => c.Arguments, Times.Never()); }
public void ReturnWhenRuntimePolicyIsOff(IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); var impl = new ActionFilter.OnActionExecuting(); impl.NewImplementation(context); context.Verify(c => c.Proceed()); }
public void ProceedAndPublishMessagesWithRuntimePolicyOn(ResultExecutedContext argument, IAlternateMethodContext context) { context.Setup(c => c.Arguments).Returns(new object[] { argument }); var sut = new ResultFilter.OnResultExecuted(); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<ResultFilter.OnResultExecuted.Message>())); }
/// <summary> /// New implementation that is called in-place of the the original method. /// </summary> /// <param name="context">The context.</param> /// <remarks> /// It is up to this method to call the underlying target method. /// </remarks> public void NewImplementation(IAlternateMethodContext context) { TimerResult timerResult; if (!context.TryProceedWithTimer(out timerResult)) { return; } PostImplementation(context, timerResult); }
public void PublishMessagesWithOnPolicy(View.Render sut, IAlternateMethodContext context, IViewCorrelationMixin mixin, ViewContext viewContext) { context.Setup(c => c.Arguments).Returns(new object[] { viewContext, new StringWriter() }); context.Setup(c => c.Proxy).Returns(mixin); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny <Action>())); context.MessageBroker.Verify(b => b.Publish(It.IsAny <View.Render.Message>())); }
public void ProceedWithRuntimePolicyOff(DependencyResolver.GetServices sut, IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.Verify(c => c.Arguments, Times.Never()); context.Verify(c => c.ReturnValue, Times.Never()); }
public void ReturnWhenRuntimePolicyIsOff(IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); var impl = new Route.GetRouteData(typeof(T)); impl.NewImplementation(context); context.Verify(c => c.Proceed()); }
public void ProceedWithTimerWithNullReturnValue(ValueProviderFactory.GetValueProvider sut, IAlternateMethodContext context, ControllerContext arg1) { context.Setup(c => c.Arguments).Returns(new object[] { arg1 }); context.Setup(c => c.ReturnValue).Returns(null); sut.NewImplementation(context); context.TimerStrategy().Verify(c => c.Time(It.IsAny<Action>())); context.Verify(c => c.ReturnValue); }
public void ReturnWhenRuntimePolicyIsOff(IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); var impl = new ActionFilter.OnActionExecuted(); impl.NewImplementation(context); context.Verify(c => c.Proceed()); }
public void ProxyActionInvokerIfControllerFound([Frozen] IProxyFactory proxyFactory, ControllerFactory.CreateController sut, IAlternateMethodContext context, RequestContext requestContext, string controllerName) { context.Setup(c => c.ReturnValue).Returns(new DummyController()); context.Setup(c => c.Arguments).Returns(new object[] { requestContext, controllerName }); proxyFactory.Setup(p => p.IsWrapInterfaceEligible<IActionInvoker>(It.IsAny<Type>())).Returns(true); sut.NewImplementation(context); proxyFactory.Verify(p => p.WrapInterface(It.IsAny<ControllerActionInvoker>(), It.IsAny<IEnumerable<IAlternateMethod>>(), It.IsAny<IEnumerable<object>>())); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var dataBindParameterModel = (DataBindParameterModel)HttpContext.Current.Items["_GlimpseWebFormModelBinding"]; if (dataBindParameterModel != null) { var bindingContext = (ModelBindingContext)context.Arguments[1]; dataBindParameterModel.DataBindParameters.Add(new ModelBindParameter(bindingContext.ModelName, bindingContext.ValueProvider.GetType().Name.Replace("ValueProvider", null), bindingContext.Model)); } }
public void ProceedAndPublishMessagesWithRuntimePolicyOn(IAlternateMethodContext context, AuthorizationContext argument) { context.Setup(c => c.Arguments).Returns(new object[] { argument }); var sut = new AuthorizationFilter.OnAuthorization(); sut.NewImplementation(context); context.TimerStrategy().Verify(c => c.Time(It.IsAny<Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<AuthorizationFilter.OnAuthorization.Message>())); }
public void ReturnWhenRuntimePolicyIsOff(IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); var impl = new RouteConstraint.Match(); impl.NewImplementation(context); context.Verify(c => c.Proceed()); }
public void ProceedAndReturnWithRuntimePolicyOff(IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); var sut = new AuthorizationFilter.OnAuthorization(); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<MessageBase>()), Times.Never()); }
public void PublishMessageOnGetServices(DependencyResolver.GetServices sut, IAlternateMethodContext context) { context.Setup(c => c.Arguments).Returns(new object[] { typeof(string) }); context.Setup(c => c.ReturnValue).Returns(Enumerable.Empty <object>()); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny <Action>())); context.MessageBroker.Verify(b => b.Publish(It.IsAny <DependencyResolver.GetServices.Message>())); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timing) { var mixin = context.Proxy as IViewCorrelationMixin; var args = new Arguments(context.Arguments); var message = new Message(args.ViewContext.ViewData.Model.GetTypeOrNull(), args.ViewContext.ViewData.ModelState.IsValid, args.ViewContext.TempData, args.ViewContext.ViewData, args.ViewContext.ViewData.ModelMetadata, context.TargetType, mixin) .AsActionMessage(args.ViewContext.Controller) .AsTimedMessage(timing) .AsMvcTimelineMessage(MvcTimelineCategory.View); context.MessageBroker.Publish(message); }
public void ProceedAndReturnWithRuntimePolicyOff(IAlternateMethodContext context) { context.Setup(c => c.RuntimePolicyStrategy).Returns(() => RuntimePolicy.Off); var sut = new ResultFilter.OnResultExecuting(); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny <MessageBase>()), Times.Never()); }
public void PublishMessageWhenExecuted([Frozen] IExecutionTimer timer, ActionExecutingContext argument, IAlternateMethodContext context) { context.Setup(c => c.Arguments).Returns(new object[] { argument }); var impl = new ActionFilter.OnActionExecuting(); impl.NewImplementation(context); timer.Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<ActionFilter.OnActionExecuting.Message>())); }
public void ProceedAndPublishMessagesWithRuntimePolicyOn(IAlternateMethodContext context, ExceptionContext argument) { context.Setup(c => c.Arguments).Returns(new object[] { argument }); var sut = new ExceptionFilter.OnException(); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny <Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny <ExceptionFilter.OnException.Message>())); }
public void ProceedAndWarnWithRuntimePolicyOnAndIModelBinder(AlternateType<IModelBinder> alternateModelBinder, IAlternateMethodContext context, Type arg1, IModelBinder returnValue) { context.Setup(c => c.Arguments).Returns(new object[] { arg1 }); context.Setup(c => c.ReturnValue).Returns(returnValue); var sut = new ModelBinderProvider.GetBinder(alternateModelBinder); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.Verify(mb => mb.ReturnValue); }
/// <summary> /// New implementation that is called in-place of the the original method. /// </summary> /// <param name="context">The context.</param> /// <remarks> /// It is up to this method to call the underlying target method. /// </remarks> public void NewImplementation(IAlternateMethodContext context) { TimerResult timerResult; if (!context.TryProceedWithTimer(out timerResult)) { return; } PostImplementation(context, timerResult); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var controller = context.ReturnValue as Controller; var args = new Arguments(context.Arguments); var message = new Message(args.ControllerName, controller) .AsSourceMessage(context.TargetType, context.MethodInvocationTarget); context.MessageBroker.Publish(message); ProxyActionInvoker(controller); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var args = new Arguments(context.Arguments); var message = new Message() .AsTimedMessage(timerResult) .AsSourceMessage(args.ActionResult.GetType(), executedMethod) .AsChildActionMessage(args.ControllerContext) .AsActionMessage(args.ControllerContext) .AsMvcTimelineMessage(MvcTimelineCategory.Controller); context.MessageBroker.Publish(message); }
public void PublishMessageWhenExecuted([Frozen] IExecutionTimer timer, IAlternateMethodContext context) { context.Setup(c => c.Arguments).Returns(new object[] { (System.Web.HttpContextBase)null, new object(), (string)null, (System.Web.Routing.RouteValueDictionary)null, System.Web.Routing.RouteDirection.IncomingRequest }); context.Setup(c => c.ReturnValue).Returns(true); context.Setup(c => c.InvocationTarget).Returns(new System.Web.Routing.Route("Test", null)); var impl = new RouteBase.ProcessConstraint(); impl.NewImplementation(context); timer.Verify(t => t.Time(It.IsAny <Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny <RouteBase.ProcessConstraint.Message>())); }
public void PublishMessageWhenExecuted([Frozen] IExecutionTimer timer, IAlternateMethodContext context, System.Web.Routing.IRouteHandler handler) { context.Setup(c => c.Arguments).Returns(new object[] { (System.Web.HttpContextBase)null, new System.Web.Routing.Route("Test", handler), (string)null, (System.Web.Routing.RouteValueDictionary)null, System.Web.Routing.RouteDirection.IncomingRequest }); context.Setup(c => c.ReturnValue).Returns(true); context.Setup(c => c.InvocationTarget).Returns(new System.Web.Routing.Route("Test", null)); var impl = new RouteConstraint.Match(); impl.NewImplementation(context); timer.Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(mb => mb.Publish(It.IsAny<RouteConstraint.Match.Message>())); }
public void ProceedWithTimerWithIValueProviderReturnValue([Frozen] IProxyFactory proxyFactory, ValueProviderFactory.GetValueProvider sut, IAlternateMethodContext context, ControllerContext arg1, IValueProvider returnValue) { context.Setup(c => c.Arguments).Returns(new object[] { arg1 }); context.Setup(c => c.ReturnValue).Returns(returnValue); proxyFactory.Setup(pf => pf.IsWrapInterfaceEligible<IValueProvider>(typeof(IValueProvider))).Returns(true); proxyFactory.Setup(pf => pf.WrapInterface(It.IsAny<IValueProvider>(), It.IsAny<IEnumerable<IAlternateMethod>>())).Returns(returnValue); sut.NewImplementation(context); context.TimerStrategy().Verify(c => c.Time(It.IsAny<Action>())); context.Verify(c => c.ReturnValue); context.VerifySet(c => c.ReturnValue = It.IsAny<IValueProvider>()); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var authorizationContext = (AuthorizationContext)context.Arguments[0]; var message = new Message() .AsTimedMessage(timerResult) .AsSourceMessage(context.InvocationTarget.GetType(), context.MethodInvocationTarget) .AsActionMessage(authorizationContext.ActionDescriptor) .AsChildActionMessage(authorizationContext.Controller) .AsFilterMessage(FilterCategory.Authorization, authorizationContext.GetTypeOrNull()) .AsMvcTimelineMessage(MvcTimelineCategory.Filter); context.MessageBroker.Publish(message); }
public override void PostImplementation(IAlternateMethodContext context, TimerResult timerResult) { var result = context.ReturnValue as FilterInfo; if (result == null) { return; } Proxy(result.ActionFilters, AlternateActionFilter); Proxy(result.ResultFilters, AlternateResultFilter); Proxy(result.AuthorizationFilters, AlternateAuthorizationFilter); Proxy(result.ExceptionFilters, AlternateExceptionFilter); }
public void ProceedAndWrapResultWithRuntimePolicyOnAndDefaultModelBinder(AlternateType<IModelBinder> alternateModelBinder, IAlternateMethodContext context, Type arg1, DefaultModelBinder returnValue, IModelBinder newModelBinder) { context.Setup(c => c.Arguments).Returns(new object[] { arg1 }); context.Setup(c => c.ReturnValue).Returns(returnValue); alternateModelBinder.Setup(amb => amb.TryCreate(It.IsAny<IModelBinder>(), out newModelBinder, null, null)).Returns(true); var sut = new ModelBinderProvider.GetBinder(alternateModelBinder); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.Verify(mb => mb.ReturnValue); context.Logger.Verify(l => l.Warn(It.IsAny<string>(), context.ReturnValue.GetType()), Times.Never()); context.VerifySet(c => c.ReturnValue = newModelBinder); alternateModelBinder.Verify(amb => amb.TryCreate(It.IsAny<IModelBinder>(), out newModelBinder, null, null)); }
public void StartTimingExecution(AsyncActionInvoker.BeginInvokeActionMethod sut, IAlternateMethodContext context, IActionInvokerStateMixin mixin) { context.Setup(c => c.Proxy).Returns(mixin); context.Setup(c => c.Arguments).Returns(new object[] { new ControllerContext(), new Mock<ActionDescriptor>().Object, new Dictionary<string, object>(), new AsyncCallback(delegate { }), "state" }); sut.NewImplementation(context); context.Verify(c => c.Proceed()); context.Verify(c => c.Proxy); mixin.VerifySet(m => m.Offset = It.IsAny<TimeSpan>()); }
public void PublishMessageWithRuntimePolicyOn(ActionInvoker.InvokeActionMethod sut, IAlternateMethodContext context) { var actionDescriptorMock = new Mock<ActionDescriptor>(); actionDescriptorMock.Setup(a => a.ControllerDescriptor).Returns(new ReflectedControllerDescriptor(typeof(DummyController))); actionDescriptorMock.Setup(a => a.ActionName).Returns("Index"); context.Setup(c => c.ReturnValue).Returns(new ContentResult()); context.Setup(c => c.Arguments).Returns(new object[] { new ControllerContext(), actionDescriptorMock.Object, new Dictionary<string, object>() }); sut.NewImplementation(context); context.TimerStrategy().Verify(t => t.Time(It.IsAny<Action>())); context.MessageBroker.Verify(b => b.Publish(It.IsAny<ActionInvoker.InvokeActionMethod.Message>())); }