public void When_the_controller_matches_the_current_route_values_the_section_menu_item_is_selected_method_should_return_true()
        {
            var actionSectionMenuItem = new ActionSectionMenuItem(null, "MyAction", "MyController");
            var httpContext = new MockHttpContext(new MockHttpRequest(), new MockResponseBase());
            var routeData = new RouteData();
            routeData.Values.Add("controller", "MyController");

            var controllerContext = new ControllerContext {RequestContext = new RequestContext(httpContext, routeData), HttpContext = httpContext};

            var viewModel = actionSectionMenuItem.GetViewModel(controllerContext);

            viewModel.Selected.ShouldBeTrue();
        }
        public void Setup()
        {
            form = new NameValueCollection();
            columns = new ListColumns();
            listViewModel = new ListViewModel {Columns = columns};
            httpContext = new MockHttpContext();
            ((MockHttpRequest)httpContext.Request).SetForm(form);

            controllerContext = new ControllerContext();
            controllerContext.HttpContext = httpContext;

            ValueProviderFactories.Factories
                .ReplaceWith<HttpFileCollectionValueProviderFactory>(ctx => ctx.HttpContext.Request.Form)
                .ReplaceWith<FormValueProviderFactory>(ctx => ctx.HttpContext.Request.Form)
                .ReplaceWith<QueryStringValueProviderFactory>(ctx => ctx.HttpContext.Request.QueryString);

            bindingContext = new ModelBindingContext
                                 {
                                     ModelMetadata = ModelMetadata.FromLambdaExpression(parameter => parameter, new ViewDataDictionary<ListViewModel>(listViewModel))
                                 };

            binder = new ListViewModelBinder();
        }
        public void Setup()
        {
            listItemType = typeof(TestListItem);
            queryString = new NameValueCollection();
            viewEngine = new MockViewEngine();

            ValueProviderFactories.Factories
                .ReplaceWith<HttpFileCollectionValueProviderFactory>(ctx => ctx.HttpContext.Request.Form)
                .ReplaceWith<FormValueProviderFactory>(ctx => ctx.HttpContext.Request.Form)
                .ReplaceWith<QueryStringValueProviderFactory>(ctx => ctx.HttpContext.Request.QueryString);

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(viewEngine);

            httpContext = new MockHttpContext();
            ((MockHttpRequest)httpContext.Request).SetQueryString(queryString);
            routeData = new RouteData();
            routeData.Values.Add("action", "Index");

            controllerContext = new ControllerContext(httpContext, routeData, new TestController());
        }
        private static ControllerContext GetControllerContext(object routeValues, object dataTokens)
        {
            var routeData = new RouteData();
            var values = new RouteValueDictionary(routeValues);
            var tokens = new RouteValueDictionary(dataTokens);

            foreach(var token in tokens)
                routeData.DataTokens.Add(token.Key, token.Value);

            foreach(var value in values)
                routeData.Values.Add(value.Key, value.Value);

            var mockHttpContext = new MockHttpContext();
            return new ControllerContext
                       {
                           RequestContext = new RequestContext(mockHttpContext, routeData),
                           HttpContext = mockHttpContext
                       };
        }