Example #1
0
        public void default_should_include_namespace_class_and_method_for_all_http_methods()
        {
            var route = RegexUrlPolicy.Create().CreateRoute <GetHandler>(x => x.Execute());

            route.AllowedHttpMethods.ShouldBeEmpty();
            route.Pattern.ShouldEqual("web/handlers/gethandler/execute");
        }
Example #2
0
        public void should_ignore_entire_class_name()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreClassName())
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/handlers/execute");
        }
Example #3
0
        public void should_ignore_type_namespace()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreNamespace <IgnoreIncludeTests>())
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/handlers/gethandler/execute");
        }
Example #4
0
        public void should_ignore_multiple_custom_regex_method_names()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreMethodNames("^.*?e", "u.*$"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/handlers/gethandler/c");
        }
Example #5
0
        public void should_ignore_custom_namespace()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreNamespaces("Web.Handlers"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("gethandler/execute");
        }
Example #6
0
        public void should_ignore_multiple_custom_regex_namespaces()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreNamespaces("H.*?d", "ers"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/l/gethandler/execute");
        }
Example #7
0
        public void should_ignore_custom_method_name()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreMethodNames("cute"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/handlers/gethandler/exe");
        }
Example #8
0
        public void should_ignore_current_assembly_namespace_of_generic_type()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreAssemblyNamespace <IgnoreIncludeTests>())
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/handlers/gethandler/execute");
        }
Example #9
0
        public void should_ignore_multiple_custom_regex_class_names()
        {
            var route = RegexUrlPolicy.Create(x => x.IgnoreClassNames("H.*?d", "l.*$"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.Pattern.ShouldEqual("web/handlers/get/execute");
        }
Example #10
0
        public void should_constrain_to_get_by_method_name()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainMethodToGet("Execute"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("GET");
        }
Example #11
0
        public void should_constrain_to_post_by_class_name_ending_with()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainClassToPostEndingWith("PostHandler"))
                        .CreateRoute <UserPostHandler>(x => x.Execute());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("POST");
        }
Example #12
0
        public void should_constrain_to_update_by_class_name()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainClassToUpdate("Update"))
                        .CreateRoute <UpdateHandler>(x => x.ExecuteUpdate());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("UPDATE");
        }
Example #13
0
        public void should_constrain_to_put_by_class_name()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainClassToPut("Put"))
                        .CreateRoute <PutHandler>(x => x.ExecutePut());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("PUT");
        }
Example #14
0
        public void should_constrain_to_delete_by_namespace()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainNamespaceToDelete("Web"))
                        .CreateRoute <GetHandler>(x => x.Execute());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("DELETE");
        }
Example #15
0
        public void should_constrain_to_delete_by_method_name_starting_with()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainMethodToDelete("Delete"))
                        .CreateRoute <DeleteHandler>(x => x.ExecuteDelete());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("DELETE");
        }
Example #16
0
        public void should_constrain_to_post_by_method_name_starting_with()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainMethodToPost("Execute"))
                        .CreateRoute <PostHandler>(x => x.Execute());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("POST");
        }
Example #17
0
        public void should_constrain_to_get_by_class_name_starting_with()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainClassToGetStartingWith("Get"))
                        .CreateRoute <GetUserHandler>(x => x.Execute());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("GET");
        }
Example #18
0
        public void should_constrain_to_delete_by_class_name_ending_with()
        {
            var route = RegexUrlPolicy.Create(x => x.ConstrainClassToDeleteEndingWith("DeleteHandler"))
                        .CreateRoute <UserDeleteHandler>(x => x.Execute());

            route.AllowedHttpMethods.Count.ShouldEqual(1);
            route.AllowedHttpMethods.ShouldContain("DELETE");
        }
Example #19
0
        public Conventions()
        {
            Actions
            .FindBy(x => x
                    .IncludeTypeNamesSuffixed("Handler")
                    .IncludeMethodsPrefixed("Execute")
                    .Applies.ToAssemblyContainingType(GetType()));

            Routes
            .OverrideFolders()
            .UrlPolicy(RegexUrlPolicy.Create(
                           x => x.IgnoreAssemblyNamespace(GetType())
                           .IgnoreClassName()
                           .IgnoreMethodNames("Execute")
                           .ConstrainClassToGetEndingWith("GetHandler")
                           .ConstrainClassToPostEndingWith("PostHandler")
                           .ConstrainClassToPutEndingWith("PutHandler")
                           .ConstrainClassToDeleteEndingWith("DeleteHandler")
                           .ConstrainClassToUpdateEndingWith("UpdateHandler")));

            Import <FubuBender>(x => x
                                .Bindings(y => y.BindCookies().BindFiles())
                                .Configure(y => y.UseJsonCamelCaseNaming()));
        }
Example #20
0
 public void should_include_url_parameters()
 {
     RegexUrlPolicy.Create().CreateRoute <GetByIdAndNameHandler>(x => x.Execute_Id_Name(null))
     .Pattern.ShouldEqual("web/handlers/getbyidandnamehandler/execute/{Id}/{Name}");
 }
Example #21
0
 public void should_include_namespace_url_parameters()
 {
     RegexUrlPolicy.Create().CreateRoute <WidgetGetHandler>(x => x.Execute_Id(null))
     .Pattern.ShouldEqual("web/handlers/{Name}/widgetgethandler/execute/{Id}");
 }