public static void UpdateConfiguration(HttpConfiguration configuration) { var controllers = new[] { typeof(ConventionCustomersController), typeof(MetadataController) }; var resolver = new TestAssemblyResolver(new TypesInjectionAssembly(controllers)); configuration.Services.Replace(typeof(IAssembliesResolver), resolver); configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; configuration.Routes.Clear(); configuration.MapODataServiceRoute("unboundFunctionConvention", "odata", UnboundFunctionEdmModel.GetEdmModel()); 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()); var oDataWorkSpace = reader.ReadServiceDocument(); var function1 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetAllConventionCustomers"); Assert.Equal(1, function1.Count()); 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.Equal(0, function2.Count()); var function3 = oDataWorkSpace.FunctionImports.Where(odataResourceCollectionInfo => odataResourceCollectionInfo.Name == "GetConventionCustomerById"); Assert.Equal(0, function3.Count()); }