本文整理汇总了C#中System.Collections.Generic.EnsureInitialized方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.Generic.EnsureInitialized方法的具体用法?C# System.Collections.Generic.EnsureInitialized怎么用?C# System.Collections.Generic.EnsureInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Generic
的用法示例。
在下文中一共展示了System.Collections.Generic.EnsureInitialized方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttributeRouting_QueryProperty_AfterCallBoundFunction
public async Task AttributeRouting_QueryProperty_AfterCallBoundFunction()
{
// Arrange
const string RequestUri = @"http://localhost/Customers(12)/NS.GetOrder(orderId=4)/Amount";
CustomersModelWithInheritance model = new CustomersModelWithInheritance();
HttpConfiguration config = new[] { typeof(CustomersController) }.GetHttpConfiguration();
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
config.MapODataServiceRoute("odata", "", model.Model);
HttpServer server = new HttpServer(config);
config.EnsureInitialized();
HttpClient client = new HttpClient(server);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, RequestUri);
// Act
HttpResponseMessage response = await client.SendAsync(request);
string responseString = await response.Content.ReadAsStringAsync();
// Assert
Assert.True(response.IsSuccessStatusCode);
Assert.Equal("{\r\n \"@odata.context\":\"http://localhost/$metadata#Edm.Int32\",\"value\":56\r\n}",
responseString);
}
示例2: Controller_DoesNotAppear_InApiDescriptions
public void Controller_DoesNotAppear_InApiDescriptions()
{
var config = new[] { typeof(MetadataController) }.GetHttpConfiguration();
config.Routes.MapHttpRoute("Default", "{controller}/{action}");
config.MapODataServiceRoute(new ODataConventionModelBuilder().GetEdmModel());
config.EnsureInitialized();
var explorer = config.Services.GetApiExplorer();
var apis = explorer.ApiDescriptions.Select(api => api.ActionDescriptor.ControllerDescriptor.ControllerName);
Assert.DoesNotContain("ODataMetadata", apis);
}
示例3: AttributeRoutingConvention_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplate
public void AttributeRoutingConvention_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplate()
{
// Arrange
IEdmModel model = new CustomersModelWithInheritance().Model;
HttpConfiguration configuration = new[] { typeof(TestODataController) }.GetHttpConfiguration();
AttributeRoutingConvention convention = new AttributeRoutingConvention(model, configuration);
// Act & Assert
Assert.DoesNotThrow(() => configuration.EnsureInitialized());
}
示例4: AttributeRoutingConvention_ConfigEnsureInitialized_ThrowsForInvalidPathTemplate
public void AttributeRoutingConvention_ConfigEnsureInitialized_ThrowsForInvalidPathTemplate()
{
// Arrange
IEdmModel model = new EdmModel();
HttpConfiguration configuration = new[] { typeof(TestODataController) }.GetHttpConfiguration();
AttributeRoutingConvention convention = new AttributeRoutingConvention(model, configuration);
// Act & Assert
Assert.Throws<InvalidOperationException>(
() => configuration.EnsureInitialized(),
"The path template 'Customers' on the action 'GetCustomers' in controller 'TestOData' is not a valid OData path template. " +
"The operation import overloads matching 'Customers' are invalid. This is most likely an error in the IEdmModel.");
}
示例5: ODataConventionModelBuilder
public void MapODataServiceRoute_ConfigEnsureInitialized_DoesNotThrowForInvalidPathTemplateWithoutAttributeRouting()
{
// Arrange
var builder = new ODataConventionModelBuilder();
builder.EntitySet<Customer>("Customers").EntityType.Ignore(c => c.Name);
IEdmModel model = builder.GetEdmModel();
HttpConfiguration configuration = new[] { typeof(CustomersController) }.GetHttpConfiguration();
configuration.MapODataServiceRoute(
"RouteName",
"RoutePrefix",
model,
new DefaultODataPathHandler(),
ODataRoutingConventions.CreateDefault());
// Act & Assert
Assert.DoesNotThrow(() => configuration.EnsureInitialized());
}
示例6: MapODataServiceRoute_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplateWithAttributeRouting
public void MapODataServiceRoute_ConfigEnsureInitialized_DoesNotThrowForValidPathTemplateWithAttributeRouting()
{
// Arrange
var builder = new ODataConventionModelBuilder();
builder.EntitySet<Customer>("Customers");
IEdmModel model = builder.GetEdmModel();
HttpConfiguration configuration = new[] { typeof(CustomersController) }.GetHttpConfiguration();
configuration.MapODataServiceRoute(model);
// Act & Assert
Assert.DoesNotThrow(() => configuration.EnsureInitialized());
}