本文整理汇总了C#中System.Net.Http.HttpRequestMessage.GetRoutingConventionsDataStore方法的典型用法代码示例。如果您正苦于以下问题:C# HttpRequestMessage.GetRoutingConventionsDataStore方法的具体用法?C# HttpRequestMessage.GetRoutingConventionsDataStore怎么用?C# HttpRequestMessage.GetRoutingConventionsDataStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.HttpRequestMessage
的用法示例。
在下文中一共展示了HttpRequestMessage.GetRoutingConventionsDataStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetValueProvider_ReturnsValueProvider_BackedByRoutingStore
public void GetValueProvider_ReturnsValueProvider_BackedByRoutingStore()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
request.GetRoutingConventionsDataStore()["ID"] = 42;
HttpActionContext actionContext = new HttpActionContext { ControllerContext = new HttpControllerContext { Request = request } };
ODataValueProviderFactory factory = new ODataValueProviderFactory();
// Act
var valueProvider = factory.GetValueProvider(actionContext);
// Assert
Assert.NotNull(valueProvider);
Assert.Equal(42, valueProvider.GetValue("ID").RawValue);
}
示例2: CanModelBindNonStringData
public void CanModelBindNonStringData()
{
// Arrange
HttpServer server = new HttpServer();
MockAssembly assembly = new MockAssembly(typeof(TestController));
server.Configuration.Services.Replace(typeof(IAssembliesResolver), new TestAssemblyResolver(assembly));
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<TestClass>("Test");
server.Configuration.Routes.MapODataRoute("odata", "", builder.GetEdmModel());
HttpClient client = new HttpClient(server);
// Act
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Test");
request.GetRoutingConventionsDataStore()["test"] = new TestClass { Id = 42 };
var response = client.SendAsync(request).Result;
// Assert
TestClass result = response.Content.ReadAsAsync<TestClass>().Result;
Assert.Equal(42, result.Id);
}
示例3: GetRoutingConventionsDataStore_ReturnsSameInstance_IfCalledMultipleTimes
public void GetRoutingConventionsDataStore_ReturnsSameInstance_IfCalledMultipleTimes()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
// Act
IDictionary<string, object> instance1 = request.GetRoutingConventionsDataStore();
IDictionary<string, object> instance2 = request.GetRoutingConventionsDataStore();
// Assert
Assert.NotNull(instance1);
Assert.NotNull(instance2);
Assert.Same(instance1, instance2);
}
示例4: GetRoutingConventionsDataStore_ReturnsEmptyNonNullDictionary
public void GetRoutingConventionsDataStore_ReturnsEmptyNonNullDictionary()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
// Act
IDictionary<string, object> result = request.GetRoutingConventionsDataStore();
// Assert
Assert.NotNull(result);
Assert.Empty(result);
}