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);
        }
        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);
        }
Ejemplo n.º 3
0
        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);
        }
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
 public static void MapODataRoute(this HttpRouteCollection routes, IEdmModel model)
 {
     routes.MapODataRoute("IgnoredRouteName", null, model);
 }