コード例 #1
0
        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 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());
        }
コード例 #3
0
ファイル: HomeController.cs プロジェクト: baronhq/IISManager
        public ActionResult Index()
        {
            AsyncActionInvoker      actionInvoker        = (AsyncActionInvoker)this.ActionInvoker;
            ControllerDescriptor    controllerDescriptor = actionInvoker.GetControllerDescriptor(ControllerContext);
            List <ActionDescriptor> actionDescriptors    = new List <ActionDescriptor>();

            actionDescriptors.Add(controllerDescriptor.FindAction(ControllerContext, "Foo"));
            actionDescriptors.Add(controllerDescriptor.FindAction(ControllerContext, "Bar"));
            actionDescriptors.Add(controllerDescriptor.FindAction(ControllerContext, "Baz"));

            return(View(actionDescriptors));
        }
        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>());
        }
コード例 #5
0
ファイル: HomeController.cs プロジェクト: baronhq/IISManager
        private IEnumerable <ControllerDescriptor> GetControllerDescriptors(params Controller[] controllers)
        {
            controllers = controllers ?? new Controller[0];
            foreach (Controller controller in controllers)
            {
                ControllerContext.Controller = controller;
                SyncActionInvoker  syncActionInvoker  = controller.ActionInvoker as SyncActionInvoker;
                AsyncActionInvoker asyncActionInvoker = controller.ActionInvoker as AsyncActionInvoker;
                if (null != syncActionInvoker)
                {
                    yield return(syncActionInvoker.GetControllerDescriptor(ControllerContext));
                }

                if (null != asyncActionInvoker)
                {
                    yield return(asyncActionInvoker.GetControllerDescriptor(ControllerContext));
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncController"/> class.
 /// </summary>
 public AsyncController()
 {
     ActionInvoker = new AsyncActionInvoker();
 }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncController"/> class.
 /// </summary>
 public AsyncController()
 {
     ActionInvoker = new AsyncActionInvoker();
 }
コード例 #8
0
        public void ReturnAllMethods()
        {
            var sut = new AsyncActionInvoker(new Mock <IProxyFactory>().Object).AllMethods;

            Assert.NotEmpty(sut);
        }
コード例 #9
0
        public void ReturnAllMethods()
        {
            var sut = new AsyncActionInvoker(new Mock<IProxyFactory>().Object).AllMethods;

            Assert.NotEmpty(sut);
        }