public void CreateEntityResource_ThrowsArgumentNull_ReadContext() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); Assert.ThrowsArgumentNull( () => deserializer.CreateEntityResource(_productEdmType, readContext: null), "readContext"); }
public void CreateEntityResource_ThrowsArgument_ModelMissingFromReadContext() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); Assert.ThrowsArgument( () => deserializer.CreateEntityResource(_productEdmType, new ODataDeserializerContext()), "readContext", "The EDM model is missing on the read context. The model is required on the read context to deserialize the payload."); }
public void CreateEntityResource_ThrowsODataException_MappingDoesNotContainEntityType() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); Assert.Throws <ODataException>( () => deserializer.CreateEntityResource(_productEdmType, new ODataDeserializerContext { Model = EdmCoreModel.Instance }), "The provided mapping does not contain an entry for the entity type 'ODataDemo.Product'."); }
public void CreateEntityResource_CreatesT_IfNotPatchMode() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); ODataDeserializerContext readContext = new ODataDeserializerContext { Model = _readContext.Model, ResourceType = typeof(Product) }; Assert.IsType <Product>(deserializer.CreateEntityResource(_productEdmType, readContext)); }
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()); }
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()); }
public void CreateEntityResource_CreatesT_IfNotPatchMode() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); ODataDeserializerContext readContext = new ODataDeserializerContext { Model = _readContext.Model, ResourceType = typeof(Product) }; Assert.IsType<Product>(deserializer.CreateEntityResource(_productEdmType, readContext)); }
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()); }
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()); }
public void CreateEntityResource_ThrowsODataException_MappingDoesNotContainEntityType() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); Assert.Throws<ODataException>( () => deserializer.CreateEntityResource(_productEdmType, new ODataDeserializerContext { Model = EdmCoreModel.Instance }), "The provided mapping does not contain an entry for the entity type 'ODataDemo.Product'."); }
public void CreateEntityResource_ThrowsArgument_ModelMissingFromReadContext() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); Assert.ThrowsArgument( () => deserializer.CreateEntityResource(_productEdmType, new ODataDeserializerContext()), "readContext", "The EDM model is missing on the read context. The model is required on the read context to deserialize the payload."); }
public void CreateEntityResource_ThrowsArgumentNull_ReadContext() { var deserializer = new ODataEntityDeserializer(_deserializerProvider); Assert.ThrowsArgumentNull( () => deserializer.CreateEntityResource(_productEdmType, readContext: null), "readContext"); }