本文整理汇总了C#中RouteCollection.Single方法的典型用法代码示例。如果您正苦于以下问题:C# RouteCollection.Single方法的具体用法?C# RouteCollection.Single怎么用?C# RouteCollection.Single使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RouteCollection
的用法示例。
在下文中一共展示了RouteCollection.Single方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapMvcAttributeRoutes_CustomConstraintResolver
public void MapMvcAttributeRoutes_CustomConstraintResolver()
{
// Arrange
var controllerTypes = new[] { typeof(FruitConstraintController) };
var routes = new RouteCollection();
// Act
routes.MapMvcAttributeRoutes(controllerTypes, new FruitConstraintResolver());
// Assert
Assert.Equal(1, routes.Count);
Route route = (Route)routes.Single();
Assert.Equal("fruits/{apple}", route.Url);
Assert.IsAssignableFrom<FruitConstraint>(route.Constraints["apple"]);
}
示例2: MapMvcAttributeRoutes_WithPrefixedController
public void MapMvcAttributeRoutes_WithPrefixedController()
{
// Arrange
var controllerTypes = new[] { typeof(PrefixedController) };
var routes = new RouteCollection();
// Act
routes.MapMvcAttributeRoutes(controllerTypes);
// Assert
Assert.Equal(1, routes.Count);
Route route = (Route)routes.Single();
Assert.Equal("prefpref/getme", route.Url);
Assert.Equal("GetMe", route.GetTargetActionMethod().Name);
}
示例3: MapMvcAttributeRoutes_WithPrefixedArea
public void MapMvcAttributeRoutes_WithPrefixedArea()
{
// Arrange
var controllerTypes = new[] { typeof(PrefixedPugetSoundController) };
var routes = new RouteCollection();
// Act
routes.MapMvcAttributeRoutes(controllerTypes);
// Assert
Assert.Equal(1, routes.Count);
Route route = (Route)routes.Single();
Assert.Equal("puget-sound/prefpref/getme", route.Url);
Assert.Equal("PugetSound", route.DataTokens["area"]);
Assert.Equal(false, route.DataTokens["usenamespacefallback"]);
Assert.Equal("GetMe", route.GetTargetActionMethod().Name);
Assert.Equal(typeof(PrefixedPugetSoundController).Namespace, ((string[])route.DataTokens["namespaces"])[0]);
}