public void Cloning_an_foreign_key_mapping_configuration_clones_its_table_and_column_information()
        {
            var configuration = new ForeignKeyAssociationMappingConfiguration();

            configuration.MapKey("C1");
            configuration.ToTable("T", "S");

            var clone = (ForeignKeyAssociationMappingConfiguration)configuration.Clone();

            Assert.Equal(configuration, clone);

            configuration.MapKey("C2");

            Assert.NotEqual(configuration, clone);
        }
        public void Equals_should_return_true_when_table_names_and_columns_match()
        {
            var independentAssociationMappingConfiguration1
                = new ForeignKeyAssociationMappingConfiguration();
            independentAssociationMappingConfiguration1.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration1.MapKey("Baz");

            var independentAssociationMappingConfiguration2
                = new ForeignKeyAssociationMappingConfiguration();
            independentAssociationMappingConfiguration2.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration2.MapKey("Baz");

            Assert.Equal(independentAssociationMappingConfiguration1, independentAssociationMappingConfiguration2);
        }
        public void Cloning_a_navigation_property_configuration_clones_its_association_mapping_configuration()
        {
            var navProp       = new MockPropertyInfo(typeof(AType1), "P1");
            var configuration = new NavigationPropertyConfiguration(navProp);

            var mappingConfiguration = new ForeignKeyAssociationMappingConfiguration();

            mappingConfiguration.MapKey("C1");
            configuration.AssociationMappingConfiguration = mappingConfiguration;

            var clone = configuration.Clone();

            Assert.NotSame(configuration.AssociationMappingConfiguration, clone.AssociationMappingConfiguration);
            Assert.Equal(configuration.AssociationMappingConfiguration, clone.AssociationMappingConfiguration);
        }
Exemple #4
0
        public void Configure_should_throw_when_annotation_key_name_not_found()
        {
            var database              = new EdmModel(DataSpace.SSpace);
            var dependentTable        = database.AddTable("Source");
            var associationSetMapping = CreateIAMapping(database, dependentTable);

            var configuration = new ForeignKeyAssociationMappingConfiguration();

            configuration.MapKey("K1").HasColumnAnnotation("BadKey", "A1", "V1");

            Assert.Equal(
                Strings.BadKeyNameForAnnotation("BadKey", "A1"),
                Assert.Throws <InvalidOperationException>(
                    () => configuration.Configure(associationSetMapping, database, new MockPropertyInfo())).Message);
        }
        public void Cloning_an_foreign_key_mapping_configuration_clones_its_annotation_information()
        {
            var configuration = new ForeignKeyAssociationMappingConfiguration();

            configuration.MapKey("C1", "C2");
            configuration.HasColumnAnnotation("C1", "A1", "V1");
            configuration.HasColumnAnnotation("C2", "A2", "V2");

            var clone = (ForeignKeyAssociationMappingConfiguration)configuration.Clone();

            Assert.Equal(configuration, clone);

            configuration.HasColumnAnnotation("C2", "A2", "V3");

            Assert.NotEqual(configuration, clone);
        }
        public void Equals_should_return_true_when_table_names_and_columns_match()
        {
            var independentAssociationMappingConfiguration1
                = new ForeignKeyAssociationMappingConfiguration();

            independentAssociationMappingConfiguration1.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration1.MapKey("Baz");

            var independentAssociationMappingConfiguration2
                = new ForeignKeyAssociationMappingConfiguration();

            independentAssociationMappingConfiguration2.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration2.MapKey("Baz");

            Assert.Equal(independentAssociationMappingConfiguration1, independentAssociationMappingConfiguration2);
        }
        public void Equals_should_return_false_when_columns_dont_match()
        {
            var independentAssociationMappingConfiguration1
                = new ForeignKeyAssociationMappingConfiguration();

            independentAssociationMappingConfiguration1.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration1.MapKey("Baz");

            var independentAssociationMappingConfiguration2
                = new ForeignKeyAssociationMappingConfiguration();

            independentAssociationMappingConfiguration2.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration2.MapKey("Bob");

            Assert.NotEqual(independentAssociationMappingConfiguration1, independentAssociationMappingConfiguration2);
        }
Exemple #8
0
        public void Equals_should_return_false_when_annotations_dont_match()
        {
            var independentAssociationMappingConfiguration1 = new ForeignKeyAssociationMappingConfiguration();

            independentAssociationMappingConfiguration1
            .MapKey("Baz", "Biz")
            .HasColumnAnnotation("Baz", "Boz", "Bees")
            .HasColumnAnnotation("Biz", "Buz", "Knees");

            var independentAssociationMappingConfiguration2 = new ForeignKeyAssociationMappingConfiguration();

            independentAssociationMappingConfiguration2
            .MapKey("Baz", "Biz")
            .HasColumnAnnotation("Baz", "Boz", "Cheese")
            .HasColumnAnnotation("Biz", "Buz", "Knees");

            Assert.NotEqual(independentAssociationMappingConfiguration1, independentAssociationMappingConfiguration2);
        }
        public void Configure_should_apply_annotations_to_FK_columns()
        {
            var database = new EdmModel(DataSpace.SSpace);
            var dependentTable = database.AddTable("Source");
            var associationSetMapping = CreateIAMapping(database, dependentTable);

            var configuration = new ForeignKeyAssociationMappingConfiguration();
            configuration.MapKey("K1")
                .HasColumnAnnotation("K1", "A1", "V1")
                .HasColumnAnnotation("K1", "A2", "V2")
                .HasColumnAnnotation("K1", "A1", "V3");

            configuration.Configure(associationSetMapping, database, new MockPropertyInfo());

            var column = dependentTable.Properties.Single(p => p.Name == "K1");

            Assert.Equal("V3", column.Annotations.Single(a => a.Name == XmlConstants.CustomAnnotationPrefix + "A1").Value);
            Assert.Equal("V2", column.Annotations.Single(a => a.Name == XmlConstants.CustomAnnotationPrefix + "A2").Value);
        }
Exemple #10
0
        public void Configure_should_apply_annotations_to_FK_columns()
        {
            var database              = new EdmModel(DataSpace.SSpace);
            var dependentTable        = database.AddTable("Source");
            var associationSetMapping = CreateIAMapping(database, dependentTable);

            var configuration = new ForeignKeyAssociationMappingConfiguration();

            configuration.MapKey("K1")
            .HasColumnAnnotation("K1", "A1", "V1")
            .HasColumnAnnotation("K1", "A2", "V2")
            .HasColumnAnnotation("K1", "A1", "V3");

            configuration.Configure(associationSetMapping, database, new MockPropertyInfo());

            var column = dependentTable.Properties.Single(p => p.Name == "K1");

            Assert.Equal("V3", column.Annotations.Single(a => a.Name == XmlConstants.CustomAnnotationPrefix + "A1").Value);
            Assert.Equal("V2", column.Annotations.Single(a => a.Name == XmlConstants.CustomAnnotationPrefix + "A2").Value);
        }
        public void Equals_should_return_false_when_columns_dont_match()
        {
            var independentAssociationMappingConfiguration1
                = new ForeignKeyAssociationMappingConfiguration();
            independentAssociationMappingConfiguration1.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration1.MapKey("Baz");

            var independentAssociationMappingConfiguration2
                = new ForeignKeyAssociationMappingConfiguration();
            independentAssociationMappingConfiguration2.ToTable("Foo", "Bar");
            independentAssociationMappingConfiguration2.MapKey("Bob");

            Assert.NotEqual(independentAssociationMappingConfiguration1, independentAssociationMappingConfiguration2);
        }
        public void Configure_should_throw_when_annotation_key_name_not_found()
        {
            var database = new EdmModel(DataSpace.SSpace);
            var dependentTable = database.AddTable("Source");
            var associationSetMapping = CreateIAMapping(database, dependentTable);

            var configuration = new ForeignKeyAssociationMappingConfiguration();
            configuration.MapKey("K1").HasColumnAnnotation("BadKey", "A1", "V1");

            Assert.Equal(
                Strings.BadKeyNameForAnnotation("BadKey", "A1"),
                Assert.Throws<InvalidOperationException>(
                    () => configuration.Configure(associationSetMapping, database, new MockPropertyInfo())).Message);

        }
        public void Equals_should_return_false_when_annotations_dont_match()
        {
            var independentAssociationMappingConfiguration1 = new ForeignKeyAssociationMappingConfiguration();
            independentAssociationMappingConfiguration1
                .MapKey("Baz", "Biz")
                .HasColumnAnnotation("Baz", "Boz", "Bees")
                .HasColumnAnnotation("Biz", "Buz", "Knees");

            var independentAssociationMappingConfiguration2 = new ForeignKeyAssociationMappingConfiguration();
            independentAssociationMappingConfiguration2
                .MapKey("Baz", "Biz")
                .HasColumnAnnotation("Baz", "Boz", "Cheese")
                .HasColumnAnnotation("Biz", "Buz", "Knees");

            Assert.NotEqual(independentAssociationMappingConfiguration1, independentAssociationMappingConfiguration2);
        }