本文整理匯總了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);
}