Exemple #1
0
        public void UsesSpecifiedBinder_Property()
        {
            var controller = typeof(FromRouteAttr.SpecifiedBinderPropertyController);

            routes.Clear();
            routes.MapCodeRoutes(controller);

            var httpContextMock = new Mock <HttpContextBase>();

            httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/yes");

            var routeData = routes.GetRouteData(httpContextMock.Object);

            var controllerInstance = new FromRouteAttr.SpecifiedBinderPropertyController {
                ValidateRequest = false
            };

            var requestContext    = new RequestContext(httpContextMock.Object, routeData);
            var controllerContext = new ControllerContext(requestContext, controllerInstance);

            controllerInstance.ValueProvider = new ValueProviderCollection(new IValueProvider[] { new RouteDataValueProvider(controllerContext) });

            ((IController)controllerInstance).Execute(requestContext);

            Assert.IsTrue(controllerInstance.a);
        }
        public void UsesSpecifiedBinder_Property()
        {
            var controller = typeof(FromRouteAttr.SpecifiedBinderPropertyController);

             routes.Clear();
             routes.MapCodeRoutes(controller);

             var httpContextMock = new Mock<HttpContextBase>();
             httpContextMock.Setup(c => c.Request.AppRelativeCurrentExecutionFilePath).Returns("~/yes");

             var routeData = routes.GetRouteData(httpContextMock.Object);

             var controllerInstance = new FromRouteAttr.SpecifiedBinderPropertyController {
            ValidateRequest = false
             };

             var requestContext = new RequestContext(httpContextMock.Object, routeData);
             var controllerContext = new ControllerContext(requestContext, controllerInstance);

             controllerInstance.ValueProvider = new ValueProviderCollection(new IValueProvider[] { new RouteDataValueProvider(controllerContext) });

             ((IController)controllerInstance).Execute(requestContext);

             Assert.IsTrue(controllerInstance.a);
        }