本文整理汇总了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));
}
示例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));
}
示例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'.");
}
示例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.");
}
示例5: CreateEntityResource_ThrowsArgumentNull_ReadContext
public void CreateEntityResource_ThrowsArgumentNull_ReadContext()
{
var deserializer = new ODataEntityDeserializer(_productEdmType, _deserializerProvider);
Assert.ThrowsArgumentNull(
() => deserializer.CreateEntityResource(readContext: null),
"readContext");
}
示例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());
}
示例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());
}