Esempio n. 1
0
        public void GetVirtualPath_MatchesHttpRoute(string odataPath)
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/vpath/prefix/Customers");
            HttpConfiguration config = new HttpConfiguration(new HttpRouteCollection("http://localhost/vpath"));
            request.SetConfiguration(config);

            IHttpRoute httpRoute = config.Routes.CreateRoute("prefix/{*odataPath}", defaults: null, constraints: null);
            ODataRoute odataRoute = new ODataRoute("prefix", pathConstraint: null);

            // Test that the link generated by ODataRoute matches the one generated by HttpRoute
            Assert.Equal(
                httpRoute.GetVirtualPath(request, new HttpRouteValueDictionary { { "odataPath", odataPath }, { "httproute", true } }).VirtualPath,
                odataRoute.GetVirtualPath(request, new HttpRouteValueDictionary { { "odataPath", odataPath }, { "httproute", true } }).VirtualPath);
        }
Esempio n. 2
0
        public void GetVirtualPath_MatchesHttpRoute(string odataPath)
        {
            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/vpath/prefix/Customers");
            HttpConfiguration  config  = new HttpConfiguration(new HttpRouteCollection("http://localhost/vpath"));

            request.SetConfiguration(config);

            IHttpRoute httpRoute  = config.Routes.CreateRoute("prefix/{*odataPath}", defaults: null, constraints: null);
            ODataRoute odataRoute = new ODataRoute("prefix", pathConstraint: null);

            // Test that the link generated by ODataRoute matches the one generated by HttpRoute
            Assert.Equal(
                httpRoute.GetVirtualPath(request, new HttpRouteValueDictionary {
                { "odataPath", odataPath }, { "httproute", true }
            }).VirtualPath,
                odataRoute.GetVirtualPath(request, new HttpRouteValueDictionary {
                { "odataPath", odataPath }, { "httproute", true }
            }).VirtualPath);
        }
Esempio n. 3
0
        public void GetVirtualPath_CanGenerateDirectLinkIsTrue_IfRoutePrefixIsNull()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage(
                HttpMethod.Get,
                "http://localhost/vpath/prefix/Customers");
            HttpConfiguration config = new HttpConfiguration(new HttpRouteCollection("http://localhost/vpath"));
            request.SetConfiguration(config);
            ODataRoute odataRoute = new ODataRoute(routePrefix: null, pathConstraint: null);

            // Act
            var virtualPathData = odataRoute.GetVirtualPath(
                request,
                new HttpRouteValueDictionary { { "odataPath", "odataPath" }, { "httproute", true } });

            // Assert
            Assert.True(odataRoute.CanGenerateDirectLink);
            Assert.NotNull(virtualPathData);
            Assert.Equal("odataPath", virtualPathData.VirtualPath);
        }
Esempio n. 4
0
        public void GetVirtualPath_CanGenerateDirectLinkIsTrue_IfRoutePrefixIsNull()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage(
                HttpMethod.Get,
                "http://localhost/vpath/prefix/Customers");
            HttpConfiguration config = new HttpConfiguration(new HttpRouteCollection("http://localhost/vpath"));

            request.SetConfiguration(config);
            ODataRoute odataRoute = new ODataRoute(routePrefix: null, pathConstraint: null);

            // Act
            var virtualPathData = odataRoute.GetVirtualPath(
                request,
                new HttpRouteValueDictionary {
                { "odataPath", "odataPath" }, { "httproute", true }
            });

            // Assert
            Assert.True(odataRoute.CanGenerateDirectLink);
            Assert.NotNull(virtualPathData);
            Assert.Equal("odataPath", virtualPathData.VirtualPath);
        }