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


C# ODataEntityDeserializer.CreateEntityResource方法代码示例

本文整理汇总了C#中System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer.CreateEntityResource方法的典型用法代码示例。如果您正苦于以下问题:C# ODataEntityDeserializer.CreateEntityResource方法的具体用法?C# ODataEntityDeserializer.CreateEntityResource怎么用?C# ODataEntityDeserializer.CreateEntityResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Http.OData.Formatter.Deserialization.ODataEntityDeserializer的用法示例。


在下文中一共展示了ODataEntityDeserializer.CreateEntityResource方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateEntityResource_CreatesDeltaOfT_IfPatchMode

        public void CreateEntityResource_CreatesDeltaOfT_IfPatchMode()
        {
            var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                IsPatchMode = true,
                PatchEntityType = typeof(Delta<Product>)
            };

            Assert.IsType<Delta<Product>>(deserializer.CreateEntityResource(readContext));
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:12,代码来源:ODataEntityDeserializerTests.cs

示例2: CreateEntityResource_CreatesT_IfNotPatchMode

        public void CreateEntityResource_CreatesT_IfNotPatchMode()
        {
            var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                IsPatchMode = false
            };

            Assert.IsType<Product>(deserializer.CreateEntityResource(readContext));
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataEntityDeserializerTests.cs

示例3: CreateEntityResource_ThrowsODataException_MappingDoesNotContainEntityType

 public void CreateEntityResource_ThrowsODataException_MappingDoesNotContainEntityType()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.Throws<ODataException>(
         () => deserializer.CreateEntityResource(new ODataDeserializerContext { Model = EdmCoreModel.Instance }),
         "The provided mapping doesn't contain an entry for the entity type 'ODataDemo.Product'.");
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:7,代码来源:ODataEntityDeserializerTests.cs

示例4: CreateEntityResource_ThrowsArgument_ModelMissingFromReadContext

 public void CreateEntityResource_ThrowsArgument_ModelMissingFromReadContext()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.ThrowsArgument(
         () => deserializer.CreateEntityResource(new ODataDeserializerContext()),
         "readContext",
         "The EDM model is missing on the read context. The model is required on the read context to deserialize the payload.");
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:8,代码来源:ODataEntityDeserializerTests.cs

示例5: CreateEntityResource_ThrowsArgumentNull_ReadContext

 public void CreateEntityResource_ThrowsArgumentNull_ReadContext()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.ThrowsArgumentNull(
         () => deserializer.CreateEntityResource(readContext: null),
         "readContext");
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:7,代码来源:ODataEntityDeserializerTests.cs

示例6: CreateEntityResource_CreatesEdmEntityObject_IfTypeLessMode

        public void CreateEntityResource_CreatesEdmEntityObject_IfTypeLessMode()
        {
            // Arrange
            var deserializer = new ODataEntityDeserializer(_deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                ResourceType = typeof(IEdmObject)
            };

            // Act
            var result = deserializer.CreateEntityResource(_productEdmType, readContext);

            // Assert
            EdmEntityObject resource = Assert.IsType<EdmEntityObject>(result);
            Assert.Equal(_productEdmType, resource.GetEdmType(), new EdmTypeReferenceEqualityComparer());
        }
开发者ID:normalian,项目名称:aspnetwebstack,代码行数:17,代码来源:ODataEntityDeserializerTests.cs

示例7: CreateEntityResource_CreatesDeltaWith_ExpectedUpdatableProperties

        public void CreateEntityResource_CreatesDeltaWith_ExpectedUpdatableProperties()
        {
            // Arrange
            var deserializer = new ODataEntityDeserializer(_deserializerProvider);
            ODataDeserializerContext readContext = new ODataDeserializerContext
            {
                Model = _readContext.Model,
                ResourceType = typeof(Delta<Product>)
            };
            var structuralProperties = _productEdmType.StructuralProperties().Select(p => p.Name);

            // Act
            Delta<Product> resource = deserializer.CreateEntityResource(_productEdmType, readContext) as Delta<Product>;

            // Assert
            Assert.NotNull(resource);
            Assert.Equal(structuralProperties, resource.GetUnchangedPropertyNames());
        }
开发者ID:huangw-t,项目名称:aspnetwebstack,代码行数:18,代码来源:ODataEntityDeserializerTests.cs


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