public void GetPropertyValue_ThrowsInvalidOperation_IfEdmObjectIsNull() { EntityInstanceContext instanceContext = new EntityInstanceContext(); Assert.Throws <InvalidOperationException>( () => instanceContext.GetPropertyValue("SomeProperty"), "The property 'EdmObject' of EntityInstanceContext cannot be null."); }
public void GetPropertyValue_ThrowsInvalidOperation_IfPropertyIsNotFound() { IEdmEntityTypeReference entityType = new EdmEntityTypeReference(new EdmEntityType("NS", "Name"), isNullable: false); Mock<IEdmStructuredObject> edmObject = new Mock<IEdmStructuredObject>(); edmObject.Setup(o => o.GetEdmType()).Returns(entityType); EntityInstanceContext instanceContext = new EntityInstanceContext(_serializerContext, entityType, edmObject.Object); Assert.Throws<InvalidOperationException>( () => instanceContext.GetPropertyValue("NotPresentProperty"), "The EDM instance of type '[NS.Name Nullable=False]' is missing the property 'NotPresentProperty'."); }
public void GetPropertyValue_ThrowsInvalidOperation_IfPropertyIsNotFound() { IEdmEntityTypeReference entityType = new EdmEntityTypeReference(new EdmEntityType("NS", "Name"), isNullable: false); Mock <IEdmStructuredObject> edmObject = new Mock <IEdmStructuredObject>(); edmObject.Setup(o => o.GetEdmType()).Returns(entityType); EntityInstanceContext instanceContext = new EntityInstanceContext(_serializerContext, entityType, edmObject.Object); Assert.Throws <InvalidOperationException>( () => instanceContext.GetPropertyValue("NotPresentProperty"), "The EDM instance of type '[NS.Name Nullable=False]' is missing the property 'NotPresentProperty'."); }
private static EntityTagHeaderValue CreateETag( EntityInstanceContext entityInstanceContext, IETagHandler handler) { IEnumerable <IEdmStructuralProperty> concurrencyProperties = entityInstanceContext.EntityType.GetConcurrencyProperties().OrderBy(c => c.Name); IDictionary <string, object> properties = new Dictionary <string, object>(); foreach (IEdmStructuralProperty etagProperty in concurrencyProperties) { properties.Add(etagProperty.Name, entityInstanceContext.GetPropertyValue(etagProperty.Name)); } EntityTagHeaderValue etagHeaderValue = handler.CreateETag(properties); return(etagHeaderValue); }
public void GetPropertyValue_ThrowsInvalidOperation_IfEdmObjectGetEdmTypeReturnsNull() { // Arrange object outObject = null; Mock <IEdmEntityObject> mock = new Mock <IEdmEntityObject>(); mock.Setup(o => o.TryGetPropertyValue(It.IsAny <string>(), out outObject)).Returns(false).Verifiable(); mock.Setup(o => o.GetEdmType()).Returns <IEdmRowTypeReference>(null).Verifiable(); EntityInstanceContext context = new EntityInstanceContext(); context.EdmObject = mock.Object; // Act & Assert Assert.Throws <InvalidOperationException>(() => context.GetPropertyValue("SomeProperty"), exceptionMessage: "The EDM type of the object of type 'Castle.Proxies.IEdmEntityObjectProxy' is null. " + "The EDM type of an IEdmObject cannot be null."); mock.Verify(); }
public void GetPropertyValue_ThrowsInvalidOperation_IfEdmObjectIsNull() { EntityInstanceContext instanceContext = new EntityInstanceContext(); Assert.Throws<InvalidOperationException>( () => instanceContext.GetPropertyValue("SomeProperty"), "The property 'EdmObject' of EntityInstanceContext cannot be null."); }
private static EntityTagHeaderValue CreateETag( EntityInstanceContext entityInstanceContext, IETagHandler handler) { IEnumerable<IEdmStructuralProperty> concurrencyProperties = entityInstanceContext.EntityType.GetConcurrencyProperties().OrderBy(c => c.Name); IDictionary<string, object> properties = new Dictionary<string, object>(); foreach (IEdmStructuralProperty etagProperty in concurrencyProperties) { properties.Add(etagProperty.Name, entityInstanceContext.GetPropertyValue(etagProperty.Name)); } EntityTagHeaderValue etagHeaderValue = handler.CreateETag(properties); return etagHeaderValue; }
public void GetPropertyValue_ThrowsInvalidOperation_IfEdmObjectGetEdmTypeReturnsNull() { // Arrange object outObject = null; Mock<IEdmEntityObject> mock = new Mock<IEdmEntityObject>(); mock.Setup(o => o.TryGetPropertyValue(It.IsAny<string>(), out outObject)).Returns(false).Verifiable(); mock.Setup(o => o.GetEdmType()).Returns<IEdmRowTypeReference>(null).Verifiable(); EntityInstanceContext context = new EntityInstanceContext(); context.EdmObject = mock.Object; // Act & Assert Assert.Throws<InvalidOperationException>(() => context.GetPropertyValue("SomeProperty"), exceptionMessage: "The EDM type of the object of type 'Castle.Proxies.IEdmEntityObjectProxy' is null. " + "The EDM type of an IEdmObject cannot be null."); mock.Verify(); }