本文整理汇总了C#中HttpRouteCollection.MapODataRoute方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRouteCollection.MapODataRoute方法的具体用法?C# HttpRouteCollection.MapODataRoute怎么用?C# HttpRouteCollection.MapODataRoute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRouteCollection
的用法示例。
在下文中一共展示了HttpRouteCollection.MapODataRoute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapODataRoute_Returns_ODataRoute
public void MapODataRoute_Returns_ODataRoute()
{
// Arrange
HttpRouteCollection routes = new HttpRouteCollection();
IEdmModel model = new EdmModel();
// Act
ODataRoute route = routes.MapODataRoute("odata", "odata", model);
// Assert
Assert.NotNull(route);
Assert.Same(model, route.PathRouteConstraint.EdmModel);
Assert.Equal("odata", route.PathRouteConstraint.RouteName);
}
示例2: MapODataRoute_AddsBatchRoute_WhenBatchHandlerIsProvided
public void MapODataRoute_AddsBatchRoute_WhenBatchHandlerIsProvided()
{
HttpRouteCollection routes = new HttpRouteCollection();
IEdmModel model = new EdmModel();
string routeName = "name";
string routePrefix = "prefix";
var batchHandler = new DefaultODataBatchHandler(new HttpServer());
routes.MapODataRoute(routeName, routePrefix, model, batchHandler);
IHttpRoute batchRoute = routes["nameBatch"];
Assert.NotNull(batchRoute);
Assert.Same(batchHandler, batchRoute.Handler);
Assert.Equal("prefix/$batch", batchRoute.RouteTemplate);
}
示例3: MapODataRoute_ConfiguresARoute_WithAnODataRouteConstraint
public void MapODataRoute_ConfiguresARoute_WithAnODataRouteConstraint()
{
HttpRouteCollection routes = new HttpRouteCollection();
IEdmModel model = new EdmModel();
string routeName = "name";
string routePrefix = "prefix";
routes.MapODataRoute(routeName, routePrefix, model);
IHttpRoute odataRoute = routes[routeName];
Assert.Single(routes);
Assert.Equal(routePrefix + "/{*odataPath}", odataRoute.RouteTemplate);
var constraint = Assert.Single(odataRoute.Constraints);
var odataConstraint = Assert.IsType<ODataPathRouteConstraint>(constraint.Value);
Assert.Same(model, odataConstraint.EdmModel);
Assert.IsType<DefaultODataPathHandler>(odataConstraint.PathHandler);
Assert.IsType<List<IODataRoutingConvention>>(odataConstraint.RoutingConventions);
}