public void IsKey_configures_when_unset() { var type = new MockType() .Property <int>("Property1"); var typeConfig = new EntityTypeConfiguration(type); var innerConfig = new PrimitivePropertyConfiguration { TypeConfiguration = typeConfig }; var propertyInfo = type.GetProperty("Property1"); var config = new LightweightPropertyConfiguration(propertyInfo, () => innerConfig); var result = config.IsKey(); Assert.Equal(1, typeConfig.KeyProperties.Count()); Assert.Contains(propertyInfo, typeConfig.KeyProperties); Assert.Same(config, result); }
public void IsKey_is_noop_when_set() { var type = new MockType() .Property <int>("Property1") .Property <int>("Property2"); var typeConfig = new EntityTypeConfiguration(type); typeConfig.Key(new[] { type.GetProperty("Property1") }); var innerConfig = new PrimitivePropertyConfiguration { TypeConfiguration = typeConfig }; var propertyInfo = type.GetProperty("Property2"); var config = new LightweightPropertyConfiguration(propertyInfo, () => innerConfig); var result = config.IsKey(); Assert.DoesNotContain(propertyInfo, typeConfig.KeyProperties); Assert.Same(config, result); }
public void IsKey_is_noop_when_set() { var type = new MockType() .Property<int>("Property1") .Property<int>("Property2"); var typeConfig = new EntityTypeConfiguration(type); typeConfig.Key(new[] { type.GetProperty("Property1") }); var innerConfig = new PrimitivePropertyConfiguration { TypeConfiguration = typeConfig }; var propertyInfo = type.GetProperty("Property2"); var config = new LightweightPropertyConfiguration(propertyInfo, () => innerConfig); var result = config.IsKey(); Assert.DoesNotContain(propertyInfo, typeConfig.KeyProperties); Assert.Same(config, result); }
public void IsKey_configures_when_unset() { var type = new MockType() .Property<int>("Property1"); var typeConfig = new EntityTypeConfiguration(type); var innerConfig = new PrimitivePropertyConfiguration { TypeConfiguration = typeConfig }; var propertyInfo = type.GetProperty("Property1"); var config = new LightweightPropertyConfiguration(propertyInfo, () => innerConfig); var result = config.IsKey(); Assert.Equal(1, typeConfig.KeyProperties.Count()); Assert.Contains(propertyInfo, typeConfig.KeyProperties); Assert.Same(config, result); }