当前位置: 首页>>代码示例>>C#>>正文


C# HttpRequestMessage.GetRoutingConventionsDataStore方法代码示例

本文整理汇总了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);
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:15,代码来源:ODataValueProviderFactoryTest.cs

示例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);
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:21,代码来源:ODataValueProviderFactoryTest.cs

示例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);
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataHttpRequestMessageExtensionsTest.cs

示例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);
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:12,代码来源:ODataHttpRequestMessageExtensionsTest.cs


注:本文中的System.Net.Http.HttpRequestMessage.GetRoutingConventionsDataStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。