• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Deserialization.ODataEntityDeserializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ODataEntityDeserializer类属于System.Web.Http.OData.Formatter.Deserialization命名空间,在下文中一共展示了ODataEntityDeserializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Read_ThrowsArgumentNull_MessageReader

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


示例2: Read_ThrowsArgument_EntitysetMissing

 public void Read_ThrowsArgument_EntitysetMissing()
 {
     var deserializer = new ODataEntityDeserializer(_deserializerProvider);
     Assert.Throws<SerializationException>(
         () => deserializer.Read(ODataTestUtil.GetMockODataMessageReader(), typeof(Product), new ODataDeserializerContext { Path = new ODataPath() }),
         "The related entity set could not be found from the OData path. The related entity set is required to deserialize the payload.");
 }
开发者ID:normalian,项目名称:aspnetwebstack,代码行数:7,代码来源:ODataEntityDeserializerTests.cs


示例3: Read_ThrowsArgumentNull_ReadContext

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


示例4: Read_ThrowsArgument_ODataPathMissing

 public void Read_ThrowsArgument_ODataPathMissing()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.ThrowsArgument(
         () => deserializer.Read(ODataTestUtil.GetMockODataMessageReader(), new ODataDeserializerContext()),
         "readContext",
         "The operation cannot be completed because no ODataPath is available for the request.");
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:8,代码来源:ODataEntityDeserializerTests.cs


示例5: DefaultODataDeserializerProvider

 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultODataDeserializerProvider"/> class.
 /// </summary>
 public DefaultODataDeserializerProvider()
 {
     _actionPayloadDeserializer = new ODataActionPayloadDeserializer(this);
     _entityDeserializer = new ODataEntityDeserializer(this);
     _feedDeserializer = new ODataFeedDeserializer(this);
     _collectionDeserializer = new ODataCollectionDeserializer(this);
     _complexDeserializer = new ODataComplexTypeDeserializer(this);
 }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:11,代码来源:DefaultODataDeserializerProvider.cs


示例6: Read_Throws_On_UnknownEntityType

        public void Read_Throws_On_UnknownEntityType()
        {
            IEdmEntityType supplierEntityType = EdmTestHelpers.GetModel().FindType("ODataDemo.Supplier") as IEdmEntityType;

            ODataEntityDeserializer deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);

            Assert.Throws<ODataException>(
                () => deserializer.Read(GetODataMessageReader(GetODataMessage(BaselineResource.SuppliersInsertData), _edmModel), _readContext),
                "An entry with type 'ODataDemo.Supplier' was found, but it is not assignable to the expected type 'ODataDemo.Product'. The type specified in the entry must be equal to either the expected type or a derived type.");
        }
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:10,代码来源:ODataEntityDeserializerTests.cs


示例7: ReadFromStreamAsync

        public void ReadFromStreamAsync()
        {
            ODataEntityDeserializer deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
            Product product = deserializer.Read(GetODataMessageReader(GetODataMessage(BaselineResource.ProductInsertData), _edmModel), _readContext) as Product;

            Assert.Equal(product.ID, 0);
            Assert.Equal(product.Rating, 4);
            Assert.Equal(product.Price, 2.5m);
            Assert.Equal(product.ReleaseDate, new DateTime(1992, 1, 1, 0, 0, 0));
            Assert.Null(product.DiscontinuedDate);
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataEntityDeserializerTests.cs


示例8: ReadFromStreamAsync

        private void ReadFromStreamAsync(string content, bool json)
        {
            ODataEntityDeserializer deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
            Product product = deserializer.Read(GetODataMessageReader(GetODataMessage(content, json), _edmModel),
                _readContext) as Product;

            Assert.Equal(product.ID, 0);
            Assert.Equal(product.Rating, 4);
            Assert.Equal(product.Price, 2.5m);
            Assert.Equal(product.ReleaseDate, new DateTime(1992, 1, 1, 0, 0, 0));
            Assert.Null(product.DiscontinuedDate);
        }
开发者ID:naulizzang,项目名称:aspnetwebstack,代码行数:12,代码来源:ODataEntityDeserializerTests.cs


示例9: Read_PatchMode

        public void Read_PatchMode()
        {
            IEdmEntityType supplierEntityType = EdmTestHelpers.GetModel().FindType("ODataDemo.Supplier") as IEdmEntityType;
            _readContext.IsPatchMode = true;

            ODataEntityDeserializer deserializer = new ODataEntityDeserializer(_supplierEdmType, _deserializerProvider);
            Delta<Supplier> supplier = deserializer.Read(GetODataMessageReader(GetODataMessage(BaselineResource.SuppliersPatchData), _edmModel), _readContext) as Delta<Supplier>;

            Assert.NotNull(supplier);
            Assert.Equal(supplier.GetChangedPropertyNames(), new string[] { "Name", "Address" });

            Assert.Equal((supplier as dynamic).Name, "Supplier Name");
            Assert.Equal("Supplier City", (supplier as dynamic).Address.City);
            Assert.Equal("123456", (supplier as dynamic).Address.ZipCode);
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:15,代码来源:ODataEntityDeserializerTests.cs


示例10: ReadFromStreamAsync_ComplexTypeAndInlineData

        public void ReadFromStreamAsync_ComplexTypeAndInlineData()
        {
            IEdmEntityType supplierEntityType = EdmTestHelpers.GetModel().FindType("ODataDemo.Supplier") as IEdmEntityType;

            ODataEntityDeserializer deserializer = new ODataEntityDeserializer(_supplierEdmType, _deserializerProvider);
            Supplier supplier = deserializer.Read(GetODataMessageReader(GetODataMessage(BaselineResource.SuppliersInsertData), _edmModel), _readContext) as Supplier;

            Assert.Equal(supplier.Name, "Supplier Name");

            Assert.NotNull(supplier.Products);
            Assert.Equal(6, supplier.Products.Count);
            Assert.Equal("soda", supplier.Products.ToList()[1].Name);

            Assert.NotNull(supplier.Address);
            Assert.Equal("Supplier City", supplier.Address.City);
            Assert.Equal("123456", supplier.Address.ZipCode);
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:17,代码来源:ODataEntityDeserializerTests.cs


示例11: ReadEntry_ThrowsSerializationException_TypeCannotBeDeserialized

        public void ReadEntry_ThrowsSerializationException_TypeCannotBeDeserialized()
        {
            Mock<ODataDeserializerProvider> deserializerProvider = new Mock<ODataDeserializerProvider>();
            deserializerProvider.Setup(d => d.GetEdmTypeDeserializer(It.IsAny<IEdmTypeReference>())).Returns<ODataEdmTypeDeserializer>(null);
            var deserializer = new ODataEntityDeserializer(_productEdmType, deserializerProvider.Object);
            ODataEntryWithNavigationLinks entry = new ODataEntryWithNavigationLinks(new ODataEntry { TypeName = _supplierEdmType.FullName() });

            Assert.Throws<SerializationException>(
                () => deserializer.ReadEntry(entry, _readContext),
                "'ODataDemo.Supplier' cannot be deserialized using the ODataMediaTypeFormatter.");
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataEntityDeserializerTests.cs


示例12: 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


示例13: ReadEntry_DispatchesToRightDeserializer_IfEntityTypeNameIsDifferent

        public void ReadEntry_DispatchesToRightDeserializer_IfEntityTypeNameIsDifferent()
        {
            // Arrange
            Mock<ODataEdmTypeDeserializer> supplierDeserializer = new Mock<ODataEdmTypeDeserializer>(_supplierEdmType, ODataPayloadKind.Entry);
            Mock<ODataDeserializerProvider> deserializerProvider = new Mock<ODataDeserializerProvider>();
            var deserializer = new ODataEntityDeserializer(_productEdmType, deserializerProvider.Object);
            ODataEntryWithNavigationLinks entry = new ODataEntryWithNavigationLinks(new ODataEntry { TypeName = _supplierEdmType.FullName() });

            deserializerProvider.Setup(d => d.GetEdmTypeDeserializer(It.IsAny<IEdmTypeReference>())).Returns(supplierDeserializer.Object);
            supplierDeserializer.Setup(d => d.ReadInline(entry, _readContext)).Returns(42).Verifiable();

            // Act
            object result = deserializer.ReadEntry(entry, _readContext);

            // Assert
            Assert.Equal(42, result);
            supplierDeserializer.Verify();
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:18,代码来源:ODataEntityDeserializerTests.cs


示例14: Read_ThrowsOnUnknownEntityType

        private void Read_ThrowsOnUnknownEntityType(string content, bool json, string expectedMessage)
        {
            IEdmEntityType supplierEntityType =
                EdmTestHelpers.GetModel().FindType("ODataDemo.Supplier") as IEdmEntityType;

            ODataEntityDeserializer deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);

            Assert.Throws<ODataException>(() => deserializer.Read(GetODataMessageReader(GetODataMessage(content, json),
                _edmModel), _readContext), expectedMessage);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:10,代码来源:ODataEntityDeserializerTests.cs


示例15: 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


示例16: ApplyNavigationProperty_ThrowsArgumentNull_NavigationLinkWrapper

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


示例17: Ctor_SetsProperty_EntityType

 public void Ctor_SetsProperty_EntityType()
 {
     var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
     Assert.Equal(_productEdmType, deserializer.EntityType);
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:5,代码来源:ODataEntityDeserializerTests.cs


示例18: ApplyStructuralProperties_ThrowsArgumentNull_entryWrapper

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


示例19: ApplyStructuralProperty_ThrowsArgumentNull_StructuralProperty

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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap