예제 #1
0
        public static void AssertRouteFail(this RouteCollection routes, string url)
        {
            HttpContextBase httpContext = MockHttpContextFactory.Create(url);
            RouteData       result      = routes.GetRouteData(httpContext);

            if (result != null)
            {
                Assert.IsInstanceOfType(result.RouteHandler, typeof(StopRoutingHandler));
            }
        }
예제 #2
0
        public static RouteData AssertRouteMatch(this RouteCollection routes, string url, string controller, object routeProperties = null, string httpMethod = "GET")
        {
            HttpContextBase httpContext = MockHttpContextFactory.Create(url, httpMethod);
            RouteData       result      = routes.GetRouteData(httpContext);

            Assert.IsNotNull(result);
            Assert.AreEqual(controller, result.Values["controller"] as string, true);
            AssertRouteData(result, routeProperties);
            return(result);
        }
예제 #3
0
        public static ViewContext Create(ViewDataDictionary viewData)
        {
            var mock = MockRepository.GenerateMock <ViewContext>();

            mock.Expect(v => v.HttpContext).Return(MockHttpContextFactory.Create());
            mock.Expect(v => v.Controller).Return(MockRepository.GenerateMock <ControllerBase>());
            mock.Expect(v => v.View).Return(MockRepository.GenerateMock <IView>());
            mock.Expect(v => v.ViewData).Return(viewData);
            mock.Expect(v => v.TempData).Return(new TempDataDictionary());
            mock.Expect(v => v.RouteData).Return(new RouteData());
            return(mock);
        }