public void Url_with_controller_only_should_map_to_default_action()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/product").ShouldMapTo <ProductController>(x => x.Index());
            }
            public void Url_with_no_controller_in_route_throws_AssertException()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/NoController/index").ShouldMapTo <HomeController>());
            }
            public void Url_with_controller_action_and_parameter_should_map_to_correct_controller()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/product/details/123").ShouldMapTo <ProductController>();
            }
            public void Resource_route_with_no_parameters_should_be_ignored()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/abc.axd").ShouldBeIgnored();
            }
            public void When_comparing_a_url_with_controller_action_and_parameter_to_wrong_controller_then_throw_AssertException()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/product/details/123").ShouldMapTo <SearchController>());
            }
            public void Url_with_static_action_should_map_to_correct_controller()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/search/string+to+search").ShouldMapTo <SearchController>();
            }
            public void When_comparing_a_url_with_static_action_to_wrong_controller_then_throw_AssertException()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/search/string+to+search").ShouldMapTo <ProductController>());
            }
            public void Url_with_controller_action_and_parameter_should_not_be_ignored()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/product/details/123").ShouldBeIgnored());
            }
            public void Url_with_controller_and_action_and_unexpected_parameter_throws_AssertException()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/product/index/123").ShouldMapTo <ProductController>(x => x.Index()));
            }
示例#10
0
            public void Url_with_controller_and_action_only_should_map_correctly()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/product/index").ShouldMapTo <ProductController>(x => x.Index());
            }
示例#11
0
            public void Url_with_no_matching_route_throws_AssertException()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/product/details/123/456").ShouldMapTo <ProductController>(x => x.Details(123)));
            }
示例#12
0
            public void Url_with_controller_action_and_two_parameters_should_map_to_correct_controller_and_action()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/search/ASP.NET/2").ShouldMapTo <SearchController>(x => x.Result("ASP.NET", 2));
            }
示例#13
0
            public void Url_with_controller_and_action_throws_AssertException_when_action_is_wrong()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/product/delete/123").ShouldMapTo <ProductController>(x => x.Details(123)));
            }
示例#14
0
            public void Url_with_no_action_in_route_throws_AssertException()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/HomeNoAction").ShouldMapTo <HomeController>(x => x.Index()));
            }
示例#15
0
            public void Resource_route_with_pathinfo_should_be_ignored()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/abc.axd/x/y/z").ShouldBeIgnored();
            }
示例#16
0
            public void Url_with_controller_action_and_parameter_throws_AssertException_when_action_expects_a_missing_parameter()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/SearchMissingParam/abc").ShouldMapTo <SearchController>(x => x.Result("abc", 1)));
            }
示例#17
0
            public void Url_with_controller_action_and_missing_optional_parameter_should_map_correctly_to_action_with_nullable_parameter()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/product/list/ASP.NET").ShouldMapTo <ProductController>(x => x.List("ASP.NET", null));
            }
示例#18
0
            public void Url_with_controller_action_and_parameter_throws_AssertException_when_null_parameter_is_expected()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/product/list/ASP.NET/1").ShouldMapTo <ProductController>(x => x.List("ASP.NET", null)));
            }
示例#19
0
            public void Url_with_controller_action_and_parameter_should_map_correctly_when_parameter_is_method_call()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/product/details/123").ShouldMapTo <ProductController>(x => x.Details(MethodReturnsInt(123)));
            }
示例#20
0
            public void Root_url_should_not_be_ignored()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Assert.Throws <AssertException>(() => routes.Url("~/").ShouldBeIgnored());
            }
示例#21
0
            public void Root_url_should_map_to_default_controller()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/").ShouldMapTo <HomeController>();
            }
示例#22
0
            public void Url_with_controller_action_and_parameter_throws_AssertException_when_parameter_is_unsupported_expression()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                Func <int> func = () => 123;

                Assert.Throws <AssertException>(() => routes.Url("~/product/details/123").ShouldMapTo <ProductController>(x => x.Details(func())));
            }
示例#23
0
            public void Url_with_controller_action_and_parameter_should_map_correctly_when_parameter_is_cast_operator()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                long variable123 = 123;

                routes.Url("~/product/details/123").ShouldMapTo <ProductController>(x => x.Details((int)variable123));
            }
示例#24
0
 public void Url_with_controller_action_and_two_parameters_should_map_to_correct_controller_and_action()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/search/ASP.NET/2").ShouldMapTo<SearchController>(x => x.Result("ASP.NET", 2));
 }
示例#25
0
 public void Url_with_controller_and_action_throws_AssertException_when_action_is_wrong()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/product/delete/123").ShouldMapTo<ProductController>(x => x.Details(123)));
 }
示例#26
0
 public void Url_with_no_action_in_route_throws_AssertException()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/HomeNoAction").ShouldMapTo<HomeController>(x => x.Index()));
 }
示例#27
0
 public void Url_with_controller_only_should_map_to_default_action()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/product").ShouldMapTo<ProductController>(x => x.Index());
 }
示例#28
0
 public void Resource_route_with_pathinfo_should_be_ignored()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/abc.axd/x/y/z").ShouldBeIgnored();
 }
示例#29
0
 public void Url_with_no_matching_route_throws_AssertException()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/product/details/123/456").ShouldMapTo<ProductController>(x => x.Details(123)));
 }
示例#30
0
 public void Url_with_controller_action_and_parameter_should_not_be_ignored()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/product/details/123").ShouldBeIgnored());
 }
示例#31
0
 public void Root_url_should_not_be_ignored()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/").ShouldBeIgnored());
 }
示例#32
0
 public void Url_with_controller_action_and_parameter_should_map_to_correct_controller()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/product/details/123").ShouldMapTo<ProductController>();
 }
示例#33
0
 public void Root_url_should_map_to_default_controller()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/").ShouldMapTo<HomeController>();
 }
示例#34
0
 public void Url_with_no_controller_in_route_throws_AssertException()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/NoController/index").ShouldMapTo<HomeController>());
 }
示例#35
0
 public void Url_with_static_action_should_map_to_correct_controller()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/search/string+to+search").ShouldMapTo<SearchController>();
 }
示例#36
0
 public void Url_with_controller_and_action_only_should_map_correctly()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/product/index").ShouldMapTo<ProductController>(x => x.Index());
 }
示例#37
0
 public void When_comparing_a_url_with_controller_action_and_parameter_to_wrong_controller_then_throw_AssertException()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/product/details/123").ShouldMapTo<SearchController>());
 }
示例#38
0
 public void When_comparing_a_url_with_static_action_to_wrong_controller_then_throw_AssertException()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/search/string+to+search").ShouldMapTo<ProductController>());
 }
示例#39
0
 public void Url_with_controller_action_and_parameter_throws_AssertException_when_null_parameter_is_expected()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/product/list/ASP.NET/1").ShouldMapTo<ProductController>(x => x.List("ASP.NET", null)));
 }
示例#40
0
 public void Url_with_controller_and_action_and_unexpected_parameter_throws_AssertException()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/product/index/123").ShouldMapTo<ProductController>(x => x.Index()));
 }
示例#41
0
 public void Url_with_controller_action_and_parameter_throws_AssertException_when_action_expects_a_missing_parameter()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/SearchMissingParam/abc").ShouldMapTo<SearchController>(x => x.Result("abc", 1)));
 }
示例#42
0
 public void Url_with_controller_action_and_parameter_throws_AssertException_when_parameter_is_unsupported_expression()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Func<int> func = () => 123;
     Assert.Throws<AssertException>(() => routes.Url("~/product/details/123").ShouldMapTo<ProductController>(x => x.Details(func())));
 }
示例#43
0
 public void Url_with_controller_action_and_parameter_should_map_correctly_when_parameter_is_method_call()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/product/details/123").ShouldMapTo<ProductController>(x => x.Details(MethodReturnsInt(123)));
 }
示例#44
0
 public void Resource_route_with_no_parameters_should_be_ignored()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/abc.axd").ShouldBeIgnored();
 }
示例#45
0
 public void Url_with_controller_action_and_parameter_should_map_correctly_to_action_with_nullable_parameter()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/product/list/ASP.NET/3").ShouldMapTo<ProductController>(x => x.List("ASP.NET", 3));
 }
示例#46
0
 public void Url_with_controller_action_and_parameter_should_map_correctly_when_parameter_is_variable()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     int variable123 = 123;
     routes.Url("~/product/details/123").ShouldMapTo<ProductController>(x => x.Details(variable123));
 }