Exemple #1
0
        private static ControllerContext RetrieveTestControllerContext(bool isMobileDevice, string browser)
        {
            var fakeHttpContext = MvcMockHelpers.FakeHttpContext();

            var httpBrowserCapabilities = new Mock <HttpBrowserCapabilitiesBase>();

            httpBrowserCapabilities.Setup(p => p.IsMobileDevice)
            .Returns(isMobileDevice);
            httpBrowserCapabilities.Setup(p => p.Browser)
            .Returns(browser);
            MvcMockHelpers.SetHttpBrowserCapabilities(fakeHttpContext.Request, httpBrowserCapabilities.Object);

            var fakeController = new Mock <ControllerBase>();
            var testRouteData  = new RouteData();

            testRouteData.Values.Add("controller", "TestController");

            return(new ControllerContext(fakeHttpContext, testRouteData, fakeController.Object));
        }