public void Configure_should_propagate_end_kind_to_keys_when_required() { var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P"); var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object }); var entityType = new EntityType("SE", "N", DataSpace.CSpace); entityType.GetMetadataProperties().SetClrType(typeof(object)); var property1 = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property1); var property = property1; property.Nullable = true; property.SetClrPropertyInfo(mockPropertyInfo); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", entityType); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("TE", "N", DataSpace.CSpace)); associationType.TargetEnd.RelationshipMultiplicity = RelationshipMultiplicity.One; constraintConfiguration.Configure( associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object))); Assert.Equal(1, associationType.Constraint.ToProperties.Count); Assert.Equal(false, property.Nullable); }
public void Configure_should_throw_when_dependent_property_not_found() { var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { new MockPropertyInfo(typeof(int), "P").Object }); var associationType = new EdmAssociationType(); Assert.Equal(Strings.ForeignKeyPropertyNotFound("P", "T"), Assert.Throws<InvalidOperationException>(() => constraintConfiguration.Configure(associationType, new EdmAssociationEnd { EntityType = new EdmEntityType { Name = "T" } }, new EntityTypeConfiguration(typeof(object)))).Message); }
public void Configure_should_add_properties_to_dependent_properties() { var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P"); var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object }); var entityType = new EdmEntityType(); var property = entityType.AddPrimitiveProperty("P"); property.PropertyType.EdmType = EdmPrimitiveType.Int32; property.SetClrPropertyInfo(mockPropertyInfo); var associationType = new EdmAssociationType().Initialize(); associationType.SourceEnd.EntityType = entityType; constraintConfiguration.Configure( associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object))); Assert.Equal(1, associationType.Constraint.DependentProperties.Count); }
public void Configure_should_throw_when_dependent_property_not_found() { var constraintConfiguration = new ForeignKeyConstraintConfiguration( new[] { new MockPropertyInfo(typeof(int), "P").Object }); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); Assert.Equal( Strings.ForeignKeyPropertyNotFound("P", "T"), Assert.Throws <InvalidOperationException>( () => constraintConfiguration.Configure( associationType, new AssociationEndMember( "E", new EntityType("T", "N", DataSpace.CSpace)) , new EntityTypeConfiguration(typeof(object)))).Message); }
public void Configure_should_propagate_end_kind_to_keys_when_required() { var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P"); var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object }); var entityType = new EdmEntityType(); var property = entityType.AddPrimitiveProperty("P"); property.PropertyType.EdmType = EdmPrimitiveType.Int32; property.PropertyType.IsNullable = true; property.SetClrPropertyInfo(mockPropertyInfo); var associationType = new EdmAssociationType().Initialize(); associationType.SourceEnd.EntityType = entityType; associationType.TargetEnd.EndKind = EdmAssociationEndKind.Required; constraintConfiguration.Configure( associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object))); Assert.Equal(1, associationType.Constraint.DependentProperties.Count); Assert.Equal(false, property.PropertyType.IsNullable); }
public void Configure_should_add_properties_to_dependent_properties() { var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P"); var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object }); var entityType = new EntityType("E", "N", DataSpace.CSpace); var property1 = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property1); var property = property1; property.SetClrPropertyInfo(mockPropertyInfo); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", entityType); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); constraintConfiguration.Configure( associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object))); Assert.Equal(1, associationType.Constraint.ToProperties.Count); }
public void Configure_should_add_properties_to_dependent_properties() { var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P"); var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object }); var entityType = new EntityType("E", "N", DataSpace.CSpace); var property1 = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property1); var property = property1; property.SetClrPropertyInfo(mockPropertyInfo); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", entityType); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); constraintConfiguration.Configure( associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object))); Assert.Equal(1, associationType.Constraint.ToProperties.Count); }
public void Configure_should_propagate_end_kind_to_keys_when_required() { var mockPropertyInfo = new MockPropertyInfo(typeof(int), "P"); var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { mockPropertyInfo.Object }); var entityType = new EntityType("E", "N", DataSpace.CSpace); var property1 = EdmProperty.Primitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); entityType.AddMember(property1); var property = property1; property.Nullable = true; property.SetClrPropertyInfo(mockPropertyInfo); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", entityType); associationType.TargetEnd = new AssociationEndMember("T", new EntityType("E", "N", DataSpace.CSpace)); associationType.TargetEnd.RelationshipMultiplicity = RelationshipMultiplicity.One; constraintConfiguration.Configure( associationType, associationType.SourceEnd, new EntityTypeConfiguration(typeof(object))); Assert.Equal(1, associationType.Constraint.ToProperties.Count); Assert.Equal(false, property.Nullable); }
public void Configure_should_throw_when_dependent_property_not_found() { var constraintConfiguration = new ForeignKeyConstraintConfiguration( new[] { new MockPropertyInfo(typeof(int), "P").Object }); var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); var entityType = new EntityType("T", "N", DataSpace.CSpace); entityType.GetMetadataProperties().SetClrType(typeof(object)); Assert.Equal( Strings.ForeignKeyPropertyNotFound("P", "T"), Assert.Throws<InvalidOperationException>( () => constraintConfiguration.Configure( associationType, new AssociationEndMember("E", entityType) , new EntityTypeConfiguration(typeof(object)))).Message); }