public void Cloning_an_entity_mapping_configuration_works_when_no_properties_have_been_set()
        {
            var configuration = new EntityMappingConfiguration();

            var clone = configuration.Clone();

            Assert.Null(clone.Properties);
        }
        public void Cloning_an_entity_mapping_configuration_clones_its_table_property_condition_and_annotation_information()
        {
            var configuration = new EntityMappingConfiguration();

            var propertyInfo1 = new MockPropertyInfo(typeof(int), "P1");

            configuration.Properties = new List <PropertyPath>
            {
                new PropertyPath(propertyInfo1)
            };

            configuration.TableName = new DatabaseName("T", "S");

            configuration.AddValueCondition(new ValueConditionConfiguration(configuration, "D"));
            configuration.AddNullabilityCondition(new NotNullConditionConfiguration(configuration, new PropertyPath(propertyInfo1)));

            configuration.MapInheritedProperties = true;

            configuration.SetAnnotation("A1", "V1");

            var clone = configuration.Clone();

            Assert.True(clone.Properties.Any(p => p[0].Name == "P1"));

            Assert.Equal("T", clone.TableName.Name);
            Assert.Equal("S", clone.TableName.Schema);

            Assert.True(clone.ValueConditions.Any(c => c.Discriminator == "D"));
            Assert.True(clone.NullabilityConditions.Any(c => c.PropertyPath[0].Name == "P1"));

            Assert.Equal("A1", clone.Annotations.Single().Key);
            Assert.Equal("V1", clone.Annotations.Single().Value);

            configuration.AddValueCondition(new ValueConditionConfiguration(configuration, "D2"));
            configuration.AddNullabilityCondition(
                new NotNullConditionConfiguration(
                    configuration,
                    new PropertyPath(new MockPropertyInfo(typeof(int), "P2"))));
            configuration.SetAnnotation("A2", "V2");

            Assert.False(clone.ValueConditions.Any(c => c.Discriminator == "D2"));
            Assert.False(clone.NullabilityConditions.Any(c => c.PropertyPath[0].Name == "P2"));

            Assert.True(clone.MapInheritedProperties);

            Assert.Equal("A1", clone.Annotations.Single().Key);
            Assert.Equal("V1", clone.Annotations.Single().Value);
        }