Beispiel #1
0
        public static MockController <TController> When(params object[] ctorArgs)
        {
            var dispatcher = Pleasure.Mock <IDispatcher>();

            IoCFactory.Instance.StubTryResolve(dispatcher.Object);

            var controller = (TController)Activator.CreateInstance(typeof(TController), ctorArgs.ToArray());
            var res        = new MockController <TController>(controller, dispatcher);

            res.httpContext.SetupGet(r => r.Request.Headers).Returns(new NameValueCollection {
                { "X-Requested-With", "XMLHttpRequest" }
            });

            return(res);
        }
Beispiel #2
0
        public static MockController <TController> When(params object[] ctorArgs)
        {
            var dispatcher = Pleasure.Mock <IDispatcher>();
            var listCtors  = new List <object> {
                dispatcher.Object
            };

            if (ctorArgs.Length > 0)
            {
                listCtors.AddRange(ctorArgs);
            }

            var controller = (TController)Activator.CreateInstance(typeof(TController), listCtors.ToArray());
            var res        = new MockController <TController>(controller, dispatcher);

            res.httpContext.SetupGet(r => r.Request.Headers).Returns(new NameValueCollection {
                { "X-Requested-With", "XMLHttpRequest" }
            });

            return(res);
        }