public void AddValueCondition_overwrites_existing_value_for_a_discriminator()
        {
            var entityMappingConfiguration1 = new EntityMappingConfiguration();
            entityMappingConfiguration1
                .AddValueCondition(
                    new ValueConditionConfiguration(entityMappingConfiguration1, "disc") { Value = 1 });
            entityMappingConfiguration1
                .AddValueCondition(
                    new ValueConditionConfiguration(entityMappingConfiguration1, "disc") { Value = 2 });

            Assert.Equal(2, entityMappingConfiguration1.ValueConditions.First().Value);
        }
        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);
        }
예제 #3
0
        public void AddValueCondition_overwrites_existing_value_for_a_discriminator()
        {
            var entityMappingConfiguration1 = new EntityMappingConfiguration();

            entityMappingConfiguration1
            .AddValueCondition(
                new ValueConditionConfiguration(entityMappingConfiguration1, "disc")
            {
                Value = 1
            });
            entityMappingConfiguration1
            .AddValueCondition(
                new ValueConditionConfiguration(entityMappingConfiguration1, "disc")
            {
                Value = 2
            });

            Assert.Equal(2, entityMappingConfiguration1.ValueConditions.First().Value);
        }