public void ExtensionResolver_Works_UnqualifiedNameTemplate() { // Arrange IEdmModel model = GetEdmModel(); HttpConfiguration config = new[] { typeof(ParserExtenstionCustomers2Controller) }.GetHttpConfiguration(); config.EnableUnqualifiedNameCall(true); config.MapODataServiceRoute("odata", "odata", model); HttpClient client = new HttpClient(new HttpServer(config)); // Act HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Get, "http://localhost/odata/ParserExtenstionCustomers2/GetCustomerTitleById(id=32)"); HttpResponseMessage response = client.SendAsync(request).Result; // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("GetCustomerTitleById/32", (response.Content as ObjectContent<string>).Value); }
private static HttpConfiguration GetConfiguration(bool caseInsensitive, bool unqualifiedNameCall) { IEdmModel model = ODataRoutingModel.GetModel(); HttpConfiguration config = new[] { typeof(MetadataController), typeof(ProductsController), typeof(RoutingCustomersController), }.GetHttpConfiguration(); config.EnableCaseInsensitive(caseInsensitive); config.EnableUnqualifiedNameCall(unqualifiedNameCall); config.MapODataServiceRoute("odata", "odata", model); return config; }
public void DefaultResolver_DoesnotWorks_UnqualifiedNameTemplate() { // Arrange IEdmModel model = GetEdmModel(); HttpConfiguration config = new[] { typeof(ParserExtenstionCustomers2Controller) }.GetHttpConfiguration(); config.EnableUnqualifiedNameCall(false); config.MapODataServiceRoute("odata", "odata", model); HttpClient client = new HttpClient(new HttpServer(config)); // Act HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Get, "http://localhost/odata/ParserExtenstionCustomers2"); // Assert Assert.Throws<InvalidOperationException>(() => client.SendAsync(request).Result); }