protected override void UpdateConfiguration(WebRouteConfiguration configuration) { var controllers = new[] { typeof(ConventionCustomersController), typeof(MetadataController) }; configuration.AddControllers(controllers); configuration.Routes.Clear(); configuration.Count().Filter().OrderBy().Expand().MaxTop(null).Select(); ODataConventionModelBuilder builder = configuration.CreateConventionModelBuilder(); configuration.MapODataServiceRoute("unboundFunctionConvention", "odata", UnboundFunctionEdmModel.GetEdmModel(builder)); configuration.EnsureInitialized(); }
public async Task ServiceDocumentTest(string format) { // Act var requestUri = string.Format("{0}/odata?$format={1}", BaseAddress, format); var response = await Client.GetAsync(requestUri); var stream = await response.Content.ReadAsStreamAsync(); //Assert var oDataMessageReaderSettings = new ODataMessageReaderSettings(); IODataResponseMessage message = new ODataMessageWrapper(stream, response.Content.Headers); var reader = new ODataMessageReader(message, oDataMessageReaderSettings, UnboundFunctionEdmModel.GetEdmModel(new ODataConventionModelBuilder())); var oDataWorkSpace = reader.ReadServiceDocument(); var function1 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetAllConventionCustomers"); Assert.Single(function1); var function2 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetConventionOrderByCustomerIdAndOrderName"); // ODL spec says: // The edm:FunctionImport for a parameterless function MAY include the IncludeInServiceDocument attribute // whose Boolean value indicates whether the function import is advertised in the service document. // So the below 2 FunctionImports are not displayed in ServiceDocument. Assert.Empty(function2); var function3 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetConventionCustomerById"); Assert.Empty(function3); }