Example #1
0
        private static VersionedODataPathRouteConstraint NewVersionedODataPathRouteConstraint(HttpRequestMessage request, IEdmModel model, ApiVersion apiVersion, string routePrefix = null)
        {
            var pathHandler        = new DefaultODataPathHandler();
            var conventions        = ODataRoutingConventions.CreateDefault();
            var configuration      = new HttpConfiguration();
            var routingConventions = Enumerable.Empty <IODataRoutingConvention>();
            var constraint         = new VersionedODataPathRouteConstraint(pathHandler, model, "odata", routingConventions, apiVersion);

            configuration.AddApiVersioning();
            configuration.MapVersionedODataRoute("odata", routePrefix, model, apiVersion);
            request.SetConfiguration(configuration);

            return(constraint);
        }
Example #2
0
        public void match_should_always_return_true_for_uri_resolution()
        {
            // arrange
            var request            = new HttpRequestMessage();
            var route              = new Mock <IHttpRoute>().Object;
            var parameterName      = (string)null;
            var values             = new Dictionary <string, object>();
            var routeDirection     = UriGeneration;
            var pathHandler        = new Mock <IODataPathHandler>().Object;
            var model              = new Mock <IEdmModel>().Object;
            var routingConventions = Enumerable.Empty <IODataRoutingConvention>();
            var constraint         = new VersionedODataPathRouteConstraint(pathHandler, model, "odata", routingConventions, Default);

            // act
            var result = constraint.Match(request, route, parameterName, values, routeDirection);

            // assert
            result.Should().BeTrue();
        }