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); }
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); }
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); }
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); }