public void key_should_a_unique_guid()
        {
            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            var otherConfig = new ControllerActionConfig(method, null, null);

            _config.UniqueID.ShouldNotEqual(otherConfig.UniqueID);
        }
        public ControllerActionDisplay(ControllerActionConfig controllerActionConfig)
        {
            PrimaryUrl = controllerActionConfig.PrimaryUrl;
            ControllerType = StripAllUpToAndIncludingTheLastDot(controllerActionConfig.ControllerType.ToString());
            ActionFunc = controllerActionConfig.ActionDelegate.ToString();
            InputType = ""; // StripAllUpToAndIncludingTheLastDot(controllerActionConfig.InputType.ToString());
            OutputType = "";  //StripAllUpToAndIncludingTheLastDot(controllerActionConfig.OutputType.ToString());

            var actionName = StripAllUpToAndIncludingTheLastDot(ActionFunc);
            var parenLoc = actionName.IndexOf("(");
            if( parenLoc >= 0 )
            {
                actionName = actionName.Substring(0, parenLoc );
            }
            MethodSignature = "public {0} {1}({0} object);".ToFormat(OutputType, actionName, InputType);

            var behaviors = new List<DebugSingleLineDisplay>();
            controllerActionConfig.GetBehaviors().Each(b => behaviors.Add(new DebugSingleLineDisplay(b.ToString())));
            Behaviors = behaviors;

            var otherUrls = new List<DebugSingleLineDisplay>();
            controllerActionConfig.GetOtherUrls().Each(u => otherUrls.Add(new DebugSingleLineDisplay(u)));
            OtherUrls = otherUrls;
            ShowOtherUrls = (OtherUrls.Count != 0);
        }
        public ControllerActionDisplay(ControllerActionConfig controllerActionConfig)
        {
            PrimaryUrl     = controllerActionConfig.PrimaryUrl;
            ControllerType = StripAllUpToAndIncludingTheLastDot(controllerActionConfig.ControllerType.ToString());
            ActionFunc     = controllerActionConfig.ActionDelegate.ToString();
            InputType      = ""; // StripAllUpToAndIncludingTheLastDot(controllerActionConfig.InputType.ToString());
            OutputType     = ""; //StripAllUpToAndIncludingTheLastDot(controllerActionConfig.OutputType.ToString());

            var actionName = StripAllUpToAndIncludingTheLastDot(ActionFunc);
            var parenLoc   = actionName.IndexOf("(");

            if (parenLoc >= 0)
            {
                actionName = actionName.Substring(0, parenLoc);
            }
            MethodSignature = "public {0} {1}({0} object);".ToFormat(OutputType, actionName, InputType);

            var behaviors = new List <DebugSingleLineDisplay>();

            controllerActionConfig.GetBehaviors().Each(b => behaviors.Add(new DebugSingleLineDisplay(b.ToString())));
            Behaviors = behaviors;

            var otherUrls = new List <DebugSingleLineDisplay>();

            controllerActionConfig.GetOtherUrls().Each(u => otherUrls.Add(new DebugSingleLineDisplay(u)));
            OtherUrls     = otherUrls;
            ShowOtherUrls = (OtherUrls.Count != 0);
        }
        public void IsTheSameActionAs_should_compare_other_config_and_return_true_if_they_represent_the_same_action()
        {
            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            var otherConfig = new ControllerActionConfig(method, null, null);

            _config.IsTheSameActionAs(otherConfig).ShouldBeTrue(); ;
        }
        public void Apply(ControllerActionConfig actionConfig)
        {
            if(! actionConfig.GetBehaviors().Any(b=>b == typeof(OutputAsRssOrAtomFeed))) return;

            actionConfig.AddOtherUrl(actionConfig.PrimaryUrl + FubuConventions.DefaultRssExtension);
            actionConfig.AddOtherUrl(actionConfig.PrimaryUrl + FubuConventions.DefaultAtomExtension);
        }
 public void SetUp()
 {
     expectedRssExtension = "__EXPECTED_RSS__";
     expectedAtomExtension = "__EXPECTED_ATOM__";
     fubuConventions = new FubuConventions { DefaultRssExtension = expectedRssExtension, DefaultAtomExtension = expectedAtomExtension};
     convention = new wire_up_RSS_and_ATOM_URLs_if_required {FubuConventions = fubuConventions};
     var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
     config = new ControllerActionConfig(method, null, null);
 }
        public void should_only_apply_if_PageNotFound_controller_Index_action()
        {
            var method = ReflectionHelper.GetMethod<PageNotFoundController>(c => c.Index(null));
            var config = new ControllerActionConfig(method, null, null);

            convention.Apply(config);

            config.PrimaryUrl.ShouldEqual(expectedPrimaryUrl);
        }
        public void SetUp()
        {
            expectedJsonExtension = "__EXPECTED_JSON__";
            fubuConventions = new FubuConventions { DefaultJsonExtension = expectedJsonExtension };
            convention = new wire_up_JSON_URL { FubuConventions = fubuConventions };

            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            config = new ControllerActionConfig(method, null, null);
        }
        public ControllerActionConfig Configure(MethodInfo method)
        {
            var inputType = method.GetParameters()[0].ParameterType;
            var invokerType = typeof (RedirectActionInvoker<,>)
                .MakeGenericType(method.DeclaringType, inputType);

            var methodDelegate = OMIZMOExpressionFrom(method);
            var config = new ControllerActionConfig(method, invokerType, methodDelegate);

            return config;
        }
        public void SetUp()
        {
            _controller = new TestController();
            _behavior = MockRepository.GenerateMock<IControllerActionBehavior>();
            _context = MockRepository.GenerateStub<IControllerConfigContext>();
            _curConfig = _context.CurrentConfig =
                new ControllerActionConfig(
                    typeof (ThunderdomeActionInvoker<TestController, TestInputModel, TestOutputModel>));
            _invoker =

                new ThunderdomeActionInvoker<TestController, TestInputModel, TestOutputModel>(_controller, _behavior, _context);
        }
 public void SetUp()
 {
     _controller = new TestController();
     _behavior = MockRepository.GenerateStub<IControllerActionBehavior>();
     _context = MockRepository.GenerateStub<IControllerConfigContext>();
     _curConfig = _context.CurrentConfig =
         new ControllerActionConfig(typeof (RedirectActionInvoker<TestController, TestInputModel>));
     _curConfig.ActionDelegate = new Action<TestController, TestInputModel>((c, i) => c.RedirectAction(i));
     _expectedUrl = "EXPECTED_URL";
     var conventions = new FubuConventions {PrimaryApplicationUrl = _expectedUrl};
     _invoker = new RedirectActionInvoker<TestController, TestInputModel>(_controller, _behavior, conventions, _context);
     BeforeEach();
 }
        public void should_override_app_default_if_specified()
        {
            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            _config = new ControllerActionConfig(method, null, null);

            _conventions.IsAppDefaultUrl = config => true;

            _fubuConfig = new FubuConfiguration(_conventions);
            _fubuConfig.AddControllerActionConfig(_config);

            _registry = new RouteConfigurer(_fubuConfig, _conventions);
            _registry.Configure();

            ((ActionRouteHandler)_registry.AppDefaultRoute.RouteHandler).Config.ShouldBeTheSameAs(_config);
        }
Example #13
0
        public void SetUp()
        {
            _root = "fake";
            _actionUrl = "test/someaction";
            _controllerUrl = "test";
            UrlContext.Stub(_root);

            _conventions = new FubuConventions();
            _config = new FubuConfiguration(_conventions);

            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            var actionConfig = new ControllerActionConfig(method, null, null);

            actionConfig.PrimaryUrl = _actionUrl;

            _config.AddControllerActionConfig(actionConfig);
        }
 public void Configure()
 {
     var notFoundAction =
         new ControllerActionConfig(typeof(PureBehaviorActionInvoker<object, object>))
         {
             PrimaryUrl = ALL_HANDLER_URL,
             ActionName = "NotFoundHandler",
             ControllerType = typeof(RedirectToNotFoundUrl),
             ActionMethod = ReflectionHelper.GetMethod<RedirectToNotFoundUrl>(i => i.Invoke<object, object>(i, null)),
             ActionDelegate = new Action<object>(i => { })
         };
     _config.AddControllerActionConfig(notFoundAction);
     notFoundAction.RemoveAllOtherUrls();
     notFoundAction.RemoveAllBehaviors();
     notFoundAction.AddBehavior<execute_the_result>();
     notFoundAction.AddBehavior<RedirectToNotFoundUrl>();
 }
        public void SetUp()
        {
            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            _config = new ControllerActionConfig(method, null, null);

            method = ReflectionHelper.GetMethod<TestController>(c => c.AnotherAction(null));
            _otherConfig = new ControllerActionConfig(method, null, null);

            _config.PrimaryUrl = "test/someaction";
            _otherConfig.PrimaryUrl = "test/anotheraction";

            _conventions = new FubuConventions();
            _fubuConfig = new FubuConfiguration(_conventions);
            _fubuConfig.AddControllerActionConfig(_config);
            _fubuConfig.AddControllerActionConfig(_otherConfig);
            _registry = new RouteConfigurer(_fubuConfig, _conventions);
            _registry.Configure();
        }
        public void Configure()
        {
            if (!_conventions.DebugMode()) return;

            var debugAction =
                new ControllerActionConfig(typeof(PureBehaviorActionInvoker<object, object>))
                {
                    PrimaryUrl = DEBUG_URL,
                    ActionName = DEBUG_URL,
                    ControllerType = typeof(OutputDebugInformation),
                    ActionMethod = ReflectionHelper.GetMethod<OutputDebugInformation>(i => i.Invoke<object, object>(i, null)),
                    ActionDelegate = new Action<object>(i => { })
                };
            _config.AddControllerActionConfig(debugAction);
            debugAction.RemoveAllOtherUrls();
            debugAction.RemoveAllBehaviors();
            debugAction.AddBehavior<execute_the_result>();
            debugAction.AddBehavior<OutputDebugInformation>();
        }
Example #17
0
 public void Apply(ControllerActionConfig actionConfig)
 {
     actionConfig.AddOtherUrl(actionConfig.PrimaryUrl + FubuConventions.DefaultJsonExtension);
 }
Example #18
0
 public ActionHttpHandler(ControllerActionConfig config, IDictionary<string, object> requestData)
 {
     _config = config;
     _requestData = requestData;
 }
        public void the_first_action_should_be_the_system_default()
        {
            var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
            _config = new ControllerActionConfig(method, null, null);

            _fubuConfig = new FubuConfiguration(_conventions);
            _fubuConfig.AddControllerActionConfig(_config);

            _registry = new RouteConfigurer(_fubuConfig, _conventions);
            _registry.Configure();

            ((ActionRouteHandler)_registry.AppDefaultRoute.RouteHandler).Config.ShouldBeTheSameAs(_config);
        }
Example #20
0
 public ActionRouteHandler(ControllerActionConfig config)
 {
     GetRequestDataFromContext = context => new AggregateDictionary(context.HttpContext.Request, context.RouteData);
     Config = config;
 }
 public void SetUp()
 {
     var method = ReflectionHelper.GetMethod<TestController>(c => c.SomeAction(null));
     _config = new ControllerActionConfig(method, null, null);
 }