public void route_with_path_segments()
        {
            var route = JasperRoute.Build <SpreadHttpActions>(x => x.get_file(null));

            route.Pattern.ShouldBe("file/...");
            route.Segments.Last().ShouldBeOfType <Spread>();
        }
Exemple #2
0
        public void assign_the_handler_type_and_method()
        {
            var route = JasperRoute.Build <SomeEndpoint>(x => x.post_go());

            route.HandlerType.ShouldBe(typeof(SomeEndpoint));
            route.Method.Name.ShouldBe("post_go");
        }
        public void route_with_relative_path()
        {
            var route = JasperRoute.Build <SpreadHttpActions>(x => x.get_folder(null));

            route.Pattern.ShouldBe("folder/...");
            route.Segments.Last().ShouldBeOfType <Spread>();
        }
Exemple #4
0
 public void serviceendpoint()
 {
     JasperRoute.Build <ServiceEndpoint>(x => x.Index()).MethodAndPatternShouldBe("GET", "");
     JasperRoute.Build <ServiceEndpoint>(x => x.Get()).MethodAndPatternShouldBe("GET", "");
     JasperRoute.Build <ServiceEndpoint>(x => x.Put()).MethodAndPatternShouldBe("PUT", "");
     JasperRoute.Build <ServiceEndpoint>(x => x.Delete()).MethodAndPatternShouldBe("DELETE", "");
 }
Exemple #5
0
        public void argument_in_brackets()
        {
            var arg = JasperRoute.ToParameter("{bar}", 3).ShouldBeOfType <RouteArgument>();

            arg.Position.ShouldBe(3);
            arg.Key.ShouldBe("bar");
        }
Exemple #6
0
        public void argument_starting_with_colon()
        {
            var arg = JasperRoute.ToParameter(":foo", 2).ShouldBeOfType <RouteArgument>();

            arg.Position.ShouldBe(2);
            arg.Key.ShouldBe("foo");
        }
Exemple #7
0
        public building_a_route_from_segments_Tests()
        {
            segments = new ISegment[]
            { new Segment("folder", 0), new Segment("folder2", 1), new RouteArgument("name", 2) };


            route = new JasperRoute(segments, HttpVerbs.PUT);
        }
Exemple #8
0
 private static void readType <T>()
 {
     typeof(T).GetMethods().Where(x => x.DeclaringType != typeof(object)).Each(method =>
     {
         var route = JasperRoute.Build(typeof(T), method);
         graph.Register(route);
     });
 }
Exemple #9
0
        public RouteChain(MethodCall action, JasperRoute route)
        {
            Action   = action;
            Route    = route;
            TypeName =
                $"{Action.HandlerType.FullNameInCode().Replace(".", "_")}_{action.Method.Name}_{action.Method.GetParameters().Select(x => x.Name).Join("_")}";

            InputType    = route.InputType;
            ResourceType = action.ReturnVariable?.VariableType;
        }
Exemple #10
0
 public static void MethodAndPatternShouldBe(this JasperRoute route, string method, string pattern)
 {
     route.HttpMethod.ShouldBe(method);
     route.Pattern.ShouldBe(pattern);
 }
 private JasperRoute routeFor(Expression <Action <RouteEndpoints> > expression)
 {
     return(JasperRoute.Build(expression));
 }
Exemple #12
0
        public void picks_up_custom_route_name_from_attribute_if_any()
        {
            var route = JasperRoute.Build <SomeEndpoint>(x => x.get_named());

            route.Name.ShouldBe("Finn");
        }
Exemple #13
0
        public void support_the_one_in_model()
        {
            var route = JasperRoute.Build <SomeEndpoint>(x => x.put_message1(null));

            route.InputType.ShouldBe(typeof(Message1));
        }
Exemple #14
0
        public void assign_the_input_type_if_is_one()
        {
            var route = JasperRoute.Build <SomeEndpoint>(x => x.post_something(null));

            route.InputType.ShouldBe(typeof(Input1));
        }
Exemple #15
0
        public void no_input_type_if_none()
        {
            var route = JasperRoute.Build <SomeEndpoint>(x => x.delete_something(null));

            route.InputType.ShouldBeNull();
        }
Exemple #16
0
 public void use_dash_in_route()
 {
     JasperRoute.Build <DashAndUnderscoreEndpoint>(x => x.get_cool___stuff())
     .Pattern.ShouldBe("cool-stuff");
 }
Exemple #17
0
 public void spread()
 {
     JasperRoute.ToParameter("...", 4).ShouldBeOfType <Spread>()
     .Position.ShouldBe(4);
 }
Exemple #18
0
 public void blank_segment()
 {
     JasperRoute.ToParameter("foo", 0).ShouldBeOfType <Segment>().Path.ShouldBe("foo");
 }
Exemple #19
0
 public RouteChain(MethodCall action) : this(action, JasperRoute.Build(action.HandlerType, action.Method))
 {
 }
Exemple #20
0
 public void use_underscore_in_route()
 {
     JasperRoute.Build <DashAndUnderscoreEndpoint>(x => x.get__text())
     .Pattern.ShouldBe("_text");
 }