本文整理汇总了C#中RouteCollection.Url方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.Url方法的具体用法?C# RouteCollection.Url怎么用?C# RouteCollection.Url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.Url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Url_with_no_matching_route_throws_AssertException
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)));
}
示例2: Resource_route_with_pathinfo_should_be_ignored
public void Resource_route_with_pathinfo_should_be_ignored()
{
RouteCollection routes = new RouteCollection();
RouteConfig.RegisterRoutes(routes);
routes.Url("~/abc.axd/x/y/z").ShouldBeIgnored();
}
示例3: Url_with_controller_action_and_parameter_should_map_correctly_when_parameter_is_method_call
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)));
}
示例4: Url_with_no_action_in_route_throws_AssertException
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()));
}
示例5: Url_with_no_controller_in_route_throws_AssertException
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>());
}
示例6: RouteCollection
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>());
}
示例7: Url_with_controller_action_and_two_parameters_should_map_to_correct_controller_and_action
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));
}
示例8: Root_url_should_map_to_default_controller
public void Root_url_should_map_to_default_controller()
{
RouteCollection routes = new RouteCollection();
RouteConfig.RegisterRoutes(routes);
routes.Url("~/").ShouldMapTo<HomeController>();
}
示例9: Url_with_controller_action_and_parameter_throws_AssertException_when_null_parameter_is_expected
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)));
}
示例10: Resource_route_with_no_parameters_should_be_ignored
public void Resource_route_with_no_parameters_should_be_ignored()
{
RouteCollection routes = new RouteCollection();
RouteConfig.RegisterRoutes(routes);
routes.Url("~/abc.axd").ShouldBeIgnored();
}
示例11: Url_with_controller_action_and_parameter_should_map_correctly_when_parameter_is_variable
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));
}
示例12: Root_url_should_not_be_ignored
public void Root_url_should_not_be_ignored()
{
RouteCollection routes = new RouteCollection();
RouteConfig.RegisterRoutes(routes);
Assert.Throws<AssertException>(() => routes.Url("~/").ShouldBeIgnored());
}
示例13: Url_with_controller_and_action_and_unexpected_parameter_throws_AssertException
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()));
}
示例14: Url_with_controller_action_and_parameter_should_not_be_ignored
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());
}
示例15: Url_with_controller_and_action_only_should_map_correctly
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());
}