private ForeignKeyConstraintConfiguration(ForeignKeyConstraintConfiguration source) { DebugCheck.NotNull(source); _dependentProperties.AddRange(source._dependentProperties); _isFullySpecified = source._isFullySpecified; }
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); }
private ForeignKeyConstraintConfiguration(ForeignKeyConstraintConfiguration source) { //Contract.Requires(source != null); _dependentProperties.AddRange(source._dependentProperties); _isFullySpecified = source._isFullySpecified; }
private ForeignKeyConstraintConfiguration(ForeignKeyConstraintConfiguration source) { DebugCheck.NotNull(source); _dependentProperties.AddRange(source._dependentProperties); _isFullySpecified = source._isFullySpecified; }
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 Equals_should_compare_references_or_dependent_key_sequences() { var propertyInfo = new MockPropertyInfo().Object; var constraintConfiguration1 = new ForeignKeyConstraintConfiguration(new[] { propertyInfo }); Assert.True(constraintConfiguration1.Equals(constraintConfiguration1)); var constraintConfiguration2 = new ForeignKeyConstraintConfiguration(new[] { propertyInfo }); Assert.True(constraintConfiguration1.Equals(constraintConfiguration2)); }
public void Equals_should_compare_references_or_dependent_key_sequences() { var propertyInfo = new MockPropertyInfo().Object; var constraintConfiguration1 = new ForeignKeyConstraintConfiguration(new[] { propertyInfo }); Assert.True(constraintConfiguration1.Equals(constraintConfiguration1)); var constraintConfiguration2 = new ForeignKeyConstraintConfiguration(new[] { propertyInfo }); Assert.True(constraintConfiguration1.Equals(constraintConfiguration2)); }
public bool Equals(ForeignKeyConstraintConfiguration other) { if (object.ReferenceEquals((object)null, (object)other)) { return(false); } if (object.ReferenceEquals((object)this, (object)other)) { return(true); } return(other.ToProperties.SequenceEqual <PropertyInfo>(this.ToProperties, (IEqualityComparer <PropertyInfo>) new DynamicEqualityComparer <PropertyInfo>((Func <PropertyInfo, PropertyInfo, bool>)((p1, p2) => p1.IsSameAs(p2))))); }
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); }
/// <inheritdoc /> public bool Equals(ForeignKeyConstraintConfiguration other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.ToProperties .SequenceEqual( ToProperties, new DynamicEqualityComparer <PropertyInfo>((p1, p2) => p1.IsSameAs(p2)))); }
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_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_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_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_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_ensure_consistency_of_constraint_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("SE", "N", DataSpace.CSpace)); var targetEntityType = new EntityType("TE", "N", DataSpace.CSpace); var propertyInfo = new MockPropertyInfo(typeof(int), "P2").Object; var property = new EdmProperty("P2", TypeUsage.Create(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32))); targetEntityType.AddMember(property); property.SetClrPropertyInfo(propertyInfo); associationType.TargetEnd = new AssociationEndMember("T", targetEntityType); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1")); associationType.SetConfiguration(navigationPropertyConfigurationA); var constraint = new ForeignKeyConstraintConfiguration( new[] { propertyInfo }); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2")) { Constraint = constraint }; navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object))); Assert.Equal(constraint, navigationPropertyConfigurationA.Constraint); }
private ForeignKeyConstraintConfiguration(ForeignKeyConstraintConfiguration source) { this._dependentProperties.AddRange((IEnumerable <PropertyInfo>)source._dependentProperties); this._isFullySpecified = source._isFullySpecified; }
public void Configure_should_ensure_consistency_of_constraint_when_already_configured() { var associationType = new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace); associationType.SourceEnd = new AssociationEndMember("S", new EntityType("SE", "N", DataSpace.CSpace)); var targetEntityType = new EntityType("TE", "N", DataSpace.CSpace); var propertyInfo = new MockPropertyInfo(typeof(int), "P2").Object; var property = new EdmProperty("P2", TypeUsage.Create(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32))); targetEntityType.AddMember(property); property.SetClrPropertyInfo(propertyInfo); associationType.TargetEnd = new AssociationEndMember("T", targetEntityType); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N1")); associationType.SetConfiguration(navigationPropertyConfigurationA); var constraint = new ForeignKeyConstraintConfiguration( new[] { propertyInfo }); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo(typeof(AType1), "N2")) { Constraint = constraint }; navigationPropertyConfigurationB.Configure( new NavigationProperty("N", TypeUsage.Create(associationType.TargetEnd.GetEntityType())) { RelationshipType = associationType }, new EdmModel(DataSpace.CSpace), new EntityTypeConfiguration(typeof(object))); Assert.Equal(constraint, navigationPropertyConfigurationA.Constraint); }
public bool Equals(ForeignKeyConstraintConfiguration other) { if (ReferenceEquals(null, other)) { return false; } if (ReferenceEquals(this, other)) { return true; } return other.DependentProperties .SequenceEqual( DependentProperties, new DynamicEqualityComparer<PropertyInfo>((p1, p2) => p1.IsSameAs(p2))); }