Ejemplo n.º 1
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());
            }
Ejemplo n.º 2
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>());
            }
Ejemplo n.º 3
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>();
            }
Ejemplo n.º 4
0
            public void Resource_route_with_no_parameters_should_be_ignored()
            {
                RouteCollection routes = new RouteCollection();

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/abc.axd").ShouldBeIgnored();
            }
Ejemplo n.º 5
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>());
            }
Ejemplo n.º 6
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>();
            }
Ejemplo n.º 7
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>());
            }
Ejemplo n.º 8
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());
            }
Ejemplo n.º 9
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()));
            }
Ejemplo n.º 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());
            }
Ejemplo n.º 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)));
            }
Ejemplo n.º 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));
            }
Ejemplo n.º 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)));
            }
Ejemplo n.º 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()));
            }
Ejemplo n.º 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();
            }
Ejemplo n.º 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)));
            }
Ejemplo n.º 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));
            }
Ejemplo n.º 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)));
            }
Ejemplo n.º 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)));
            }
Ejemplo n.º 20
0
            public void Root_url_should_not_be_ignored()
            {
                RouteCollection routes = new RouteCollection();

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

                RouteConfig.RegisterRoutes(routes);
                routes.Url("~/").ShouldMapTo <HomeController>();
            }
Ejemplo n.º 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())));
            }
Ejemplo n.º 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));
            }
Ejemplo n.º 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));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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()));
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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();
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 31
0
 public void Root_url_should_not_be_ignored()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     Assert.Throws<AssertException>(() => routes.Url("~/").ShouldBeIgnored());
 }
Ejemplo n.º 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>();
 }
Ejemplo n.º 33
0
 public void Root_url_should_map_to_default_controller()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/").ShouldMapTo<HomeController>();
 }
Ejemplo n.º 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>());
 }
Ejemplo n.º 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>();
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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>());
 }
Ejemplo n.º 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>());
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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()));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 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())));
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 44
0
 public void Resource_route_with_no_parameters_should_be_ignored()
 {
     RouteCollection routes = new RouteCollection();
     RouteConfig.RegisterRoutes(routes);
     routes.Url("~/abc.axd").ShouldBeIgnored();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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));
 }