public void default_builder_yields_no_routes()
        {
            var sut = new RoutingConventions();
            sut.RegisterController<SomeController>();
            var routes = sut.BuildRoutes();
            routes.Should().BeEmpty();

        }
Example #2
0
 public void handles_one_model_in_argument_properly()
 {
     var sut = new RoutingConventions();
     sut.UseOneModelInHandlerConvention();
     sut.RegisterController<ModelFixtureController>();
     var id = 2;
     sut.HomeIs<ModelFixtureController>(f => f.Get(new ModelHandlerInput(){Page = 67}));
     var routes = sut.BuildRoutes();
     var def = routes.Last();
     def.Url.Should().Be("{*catch}");
     def.Defaults["controller"].Should().Be("ModelFixture");
     def.Defaults["action"].Should().Be("Get");
     def.Defaults["page"].Should().Be(67);                       
 }
Example #3
0
 public void handles_argument_list_properly()
 {
     var sut = new RoutingConventions();
     sut.UseHandlerConvention();
     sut.RegisterController<HandlerFixtureController>();
     var id = 2;
     sut.HomeIs<HandlerFixtureController>(f => f.Get(id));
     var routes = sut.BuildRoutes();
     routes.Count().Should().Be(2);
     var def = routes.Last();
     def.Url.Should().Be("{*catch}");
     def.Defaults["controller"].Should().Be("HandlerFixture");
     def.Defaults["action"].Should().Be("Get");
     def.Defaults["page"].Should().Be(2);                       
 }
 public void get_route_is_generated_from_input_model()
 {
     var sut = new RoutingConventions();
     sut.UseOneModelInHandlerConvention();
     sut.RegisterController<ModelFixtureController>();
     
     var routes = sut.BuildRoutes();
     routes.Count().Should().Be(2);
     var def = routes.First();
     def.Url.Should().Be("ModelFixture/{page}/{text}/{optional}");
     def.Defaults["controller"].Should().Be("ModelFixture");
     def.Defaults["action"].Should().Be("Get");
     def.Defaults.ContainsKey("page").Should().BeFalse();
     def.Defaults["text"].Should().Be(UrlParameter.Optional);
     def.Defaults["optional"].Should().Be(UrlParameter.Optional);
 }
 public void post_route_ignores_input_model()
 {
     var sut = new RoutingConventions();
     sut.UseOneModelInHandlerConvention();
     sut.RegisterController<ModelFixtureController>();
     
     var routes = sut.BuildRoutes();
     routes.Count().Should().Be(2);
     var def = routes.Last();
     def.Url.Should().Be("ModelFixture");
     def.Defaults["controller"].Should().Be("ModelFixture");
     def.Defaults["action"].Should().Be("Post");
     def.Defaults.ContainsKey("page").Should().BeFalse();
     def.Defaults.ContainsKey("text").Should().BeFalse();
     def.Defaults.ContainsKey("optional").Should().BeFalse();
     
 }
Example #6
0
        public void route_is_generated_from_input_model()
        {
            var sut = new RoutingConventions();

            sut.Add((IBuildRoutes) new OneModelInHandlerConvention());
            sut.RegisterController <ModelFixtureController>();

            var routes = sut.BuildRoutes();

            routes.Count().Should().Be(1);
            var def = routes.Last();

            def.RouteTemplate.Should().Be("ModelFixture/{page}/{text}/{optional}");
            def.Defaults["controller"].Should().Be("ModelFixture");
            def.Defaults["action"].Should().Be("Get");
            def.Defaults.ContainsKey("page").Should().BeFalse();
            def.Defaults["text"].Should().Be(RouteParameter.Optional);
            def.Defaults["optional"].Should().Be(RouteParameter.Optional);
        }
Example #7
0
        public void handles_argument_list_properly()
        {
            var sut = new RoutingConventions();

            sut.UseHandlerConvention();
            sut.RegisterController <HandlerFixtureController>();
            var id = 2;

            sut.HomeIs <HandlerFixtureController>(f => f.Get(id));
            var routes = sut.BuildRoutes();

            routes.Count().Should().Be(2);
            var def = routes.Last();

            def.Url.Should().Be("{*catch}");
            def.Defaults["controller"].Should().Be("HandlerFixture");
            def.Defaults["action"].Should().Be("Get");
            def.Defaults["page"].Should().Be(2);
        }
Example #8
0
        public void post_route_ignores_input_model()
        {
            var sut = new RoutingConventions();

            sut.UseOneModelInHandlerConvention();
            sut.RegisterController <ModelFixtureController>();

            var routes = sut.BuildRoutes();

            routes.Count().Should().Be(2);
            var def = routes.Last();

            def.Url.Should().Be("ModelFixture");
            def.Defaults["controller"].Should().Be("ModelFixture");
            def.Defaults["action"].Should().Be("Post");
            def.Defaults.ContainsKey("page").Should().BeFalse();
            def.Defaults.ContainsKey("text").Should().BeFalse();
            def.Defaults.ContainsKey("optional").Should().BeFalse();
        }
Example #9
0
        public void handles_one_model_in_argument_properly()
        {
            var sut = new RoutingConventions();

            sut.UseOneModelInHandlerConvention();
            sut.RegisterController <ModelFixtureController>();
            var id = 2;

            sut.HomeIs <ModelFixtureController>(f => f.Get(new ModelHandlerInput()
            {
                Page = 67
            }));
            var routes = sut.BuildRoutes();
            var def    = routes.Last();

            def.Url.Should().Be("{*catch}");
            def.Defaults["controller"].Should().Be("ModelFixture");
            def.Defaults["action"].Should().Be("Get");
            def.Defaults["page"].Should().Be(67);
        }