Пример #1
0
        public void Get_Static_Urls_with_one_segment_is_matched_correctly()
        {
            var route  = new Route("GET", "/foo", App);
            var router = new Router();

            router.AddRoute(route);
            var result = router.Resolve(FakeRequest.Get("/foo"));

            Assert.Equal(route, result.Route);
        }
Пример #2
0
        public void Get_Static_Urls_with_dynamic_segment_and_multiple_parameters_is_matched_correctly()
        {
            var route  = new Route("GET", "/foo/{action}-{subaction}", App);
            var router = new Router();

            router.AddRoute(route);
            var result = router.Resolve(FakeRequest.Get("/foo/test-bar"));

            Assert.Equal(route, result.Route);
        }
Пример #3
0
        public void Puts_values_of_parameters_into_parameters_dictionary_if_url_ends_with_static_segment()
        {
            var route  = new Route("GET", "/foo/{action}-{subaction}.html", App);
            var router = new Router();

            router.AddRoute(route);
            var result = router.Resolve(FakeRequest.Get("/foo/do-this.html"));

            Assert.Equal(
                new Dictionary <string, RouteValue> {
                { "action", new RouteValue("do") },
                { "subaction", new RouteValue("this") },
            },
                result.Parameters
                );
        }
        public void ConditionData_is_passed_to_condition_function()
        {
            var    route         = new Route("GET", "/test", App);
            object conditionData = "test data to pass to check method";
            object receivedDataFromCheckMethod = null;

            route.AddCondition(new RouteCondition(
                                   x => {
                receivedDataFromCheckMethod = x.ConditionData;
                return(true);
            },
                                   conditionData)
                               );

            var router = new Router();

            router.AddRoute(route);
            router.Resolve(FakeRequest.Get("/test"));

            Assert.Same(conditionData, receivedDataFromCheckMethod);
        }