public void Can_get_and_set_configuration_facet() { var associationType = new EdmAssociationType().Initialize(); associationType.SetConfiguration(42); Assert.Equal(42, associationType.GetConfiguration()); }
public void Configure_should_not_validate_consistency_of_dependent_end_when_both_false() { var associationType = new EdmAssociationType().Initialize(); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()); associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()); navigationPropertyConfigurationB.Configure( new EdmNavigationProperty { Association = associationType }, new EdmModel(), new EntityTypeConfiguration(typeof(object))); }
public void Configure_should_validate_consistency_of_mapping_when_already_configured() { var associationType = new EdmAssociationType().Initialize(); var manyToManyAssociationMappingConfiguration1 = new ManyToManyAssociationMappingConfiguration(); manyToManyAssociationMappingConfiguration1.ToTable("A"); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()) { AssociationMappingConfiguration = manyToManyAssociationMappingConfiguration1 }; associationType.SetConfiguration(navigationPropertyConfigurationA); var manyToManyAssociationMappingConfiguration2 = new ManyToManyAssociationMappingConfiguration(); manyToManyAssociationMappingConfiguration1.ToTable("B"); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()) { AssociationMappingConfiguration = manyToManyAssociationMappingConfiguration2 }; Assert.Equal(Strings.ConflictingMapping("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => navigationPropertyConfigurationB.Configure( new EdmNavigationProperty { Association = associationType }, new EdmModel(), new EntityTypeConfiguration(typeof(object)))).Message); }
public void Configure_should_validate_consistency_of_constraint_when_already_configured() { var associationType = new EdmAssociationType().Initialize(); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()) { Constraint = new ForeignKeyConstraintConfiguration(new[] { new MockPropertyInfo(typeof(int), "P1").Object }) }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()) { Constraint = new ForeignKeyConstraintConfiguration(new[] { new MockPropertyInfo(typeof(int), "P2").Object }) }; Assert.Equal(Strings.ConflictingConstraint("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => navigationPropertyConfigurationB.Configure( new EdmNavigationProperty { Association = associationType }, new EdmModel(), new EntityTypeConfiguration(typeof(object)))).Message); }
public void Configure_should_validate_consistency_of_delete_action_when_already_configured() { var associationType = new EdmAssociationType().Initialize(); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(new MockPropertyInfo()) { DeleteAction = EdmOperationAction.None }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()) { DeleteAction = EdmOperationAction.Cascade }; Assert.Equal(Strings.ConflictingCascadeDeleteOperation("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => navigationPropertyConfigurationB.Configure( new EdmNavigationProperty { Association = associationType }, new EdmModel(), new EntityTypeConfiguration(typeof(object)))).Message); }
public void Configure_should_validate_consistency_of_inverse_end_kind_when_already_configured() { var associationType = new EdmAssociationType().Initialize(); var mockPropertyInfo = new MockPropertyInfo(); var navigationPropertyConfigurationA = new NavigationPropertyConfiguration(mockPropertyInfo) { EndKind = EdmAssociationEndKind.Optional }; associationType.SetConfiguration(navigationPropertyConfigurationA); var navigationPropertyConfigurationB = new NavigationPropertyConfiguration(new MockPropertyInfo()) { InverseEndKind = EdmAssociationEndKind.Many, InverseNavigationProperty = mockPropertyInfo }; Assert.Equal(Strings.ConflictingMultiplicities("P", typeof(object)), Assert.Throws<InvalidOperationException>(() => navigationPropertyConfigurationB.Configure( new EdmNavigationProperty { Association = associationType }, new EdmModel(), new EntityTypeConfiguration(typeof(object)))).Message); }