public void add_multiple_http_constraints()
        {
            var route = new RouteDefinition("something");
            route.AddHttpMethodConstraint("get");
            route.AddHttpMethodConstraint("POST");

            route.GetHttpMethodConstraints().ShouldHaveTheSameElementsAs("GET", "POST");
        }
        public IRouteDefinition Build(ActionCall call)
        {
            var className = call.HandlerType.Name.ToLower()
                .Replace("endpoints", "")
                .Replace("endpoint", "")
                
                .Replace("controller", "");

            RouteDefinition route = null;
            if (RouteDefinition.VERBS.Any(x => x.EqualsIgnoreCase(call.Method.Name)))
            {
                route = new RouteDefinition(className);
                route.AddHttpMethodConstraint(call.Method.Name.ToUpper());
            }
            else
            {
                route = new RouteDefinition("{0}/{1}".ToFormat(className, call.Method.Name.ToLowerInvariant()));
            }

            if (call.InputType() != null)
            {
                if (call.InputType().CanBeCastTo<ResourcePath>())
                {
                    ResourcePath.AddResourcePathInputs(route);
                }
                else
                {
                    AddBasicRouteInputs(call, route);
                }
            }

            return route;
        }
 public void Configure(BehaviorGraph graph)
 {
     var route = new RouteDefinition("");
     route.AddHttpMethodConstraint("GET");
     var chain = new BehaviorChain { Route = route };
     chain.AddToEnd(new RedirectNode());
     graph.AddChain(chain);
     graph.Services.AddService(this);
 }
        public IRouteDefinition Build(ActionCall call)
        {
            Type viewModelType = call.HandlerType.GetGenericArguments()[0];

            var route = new RouteDefinition(viewModelType.Name.Replace("ViewModel","").ToLower());
            route.ApplyInputType(viewModelType);
            route.AddHttpMethodConstraint("POST");

            return route;
        }
        public IRouteDefinition Build(ActionCall call)
        {
            // Later on we need to put in real plural naming.
            string pattern = call.HandlerType.GetGenericArguments()[0].Name.Replace("ViewModel", "") + "es";

            var route = new RouteDefinition(pattern.ToLower());
            route.ApplyInputType(call.InputType());
            route.AddHttpMethodConstraint("GET");

            return route;
        }
        public void Configure(BehaviorGraph graph)
        {
            if (!graph.Behaviors.Any(x => x.Route != null && x.GetRoutePattern().IsEmpty()))
            {
                var action = ActionCall.For<DefaultHome>(x => x.GoToDiagnostics());
                var continuer = new ContinuationNode();

                var route = new RouteDefinition("");
                route.AddHttpMethodConstraint("GET");
                var chain = new BehaviorChain {Route = route};
                chain.AddToEnd(action);
                chain.AddToEnd(continuer);

                graph.AddChain(chain);
            }
        }
        public IRouteDefinition Build(ActionCall call)
        {
            string pattern = call.HandlerType.GetGenericArguments()[0].Name.Replace("ViewModel", "");

            var route = new RouteDefinition(pattern.ToLower());
            route.Append("{Id}");

            if (call.InputType().Name.StartsWith("Edit`"))
            {
                route.Append("edit");
            }
            else if (call.InputType().Name.StartsWith("Get`"))
            {
                route.Append("view");
            }

            route.ApplyInputType(call.InputType());
            route.AddHttpMethodConstraint("GET");

            return route;
        }
        public void create_route_with_http_constraints()
        {
            var route = new RouteDefinition("something");
            route.AddHttpMethodConstraint("Get");
            route.AddHttpMethodConstraint("POST");

            route.ToRoute().Constraints.Single().Value.ShouldBeOfType<HttpMethodConstraint>()
                .AllowedMethods.ShouldHaveTheSameElementsAs("GET", "POST");
        }
 public void responds_to_get_if_GET_is_explicitly_allowed()
 {
     var route = new RouteDefinition("something");
     route.AddHttpMethodConstraint("Get");
     route.AddHttpMethodConstraint("POST");
     route.RespondsToGet().ShouldBeTrue();
 }
 public void does_not_respond_to_get_if_http_methods_are_explicitly_defined_and_get_is_not_allowed()
 {
     var route = new RouteDefinition("something");
     route.AddHttpMethodConstraint("POST");
     route.RespondsToGet().ShouldBeFalse();
 }