public void Property_throws_when_not_exists() { var type = typeof(AType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); Assert.Equal( Strings.NoSuchProperty("DoesNotExist", type.Name), Assert.Throws <InvalidOperationException>(() => config.Property("DoesNotExist")).Message); Assert.Equal( "propertyInfo", Assert.Throws <ArgumentNullException>(() => config.Property((PropertyInfo)null)).ParamName); }
public void Property_evaluates_preconditions() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration <object>(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws <ArgumentNullException>( () => config.Property <object>(null)); Assert.Equal("propertyExpression", ex.ParamName); }
public void Property_evaluates_preconditions() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws <ArgumentException>( () => config.Property((string)null)); Assert.Equal(Strings.ArgumentIsNullOrWhitespace("propertyName"), ex.Message); }
public void Property_evaluates_preconditions() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration<object>(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws<ArgumentNullException>( () => config.Property<object>(null)); Assert.Equal("propertyExpression", ex.ParamName); }
public void Property_throws_when_indexer() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws <InvalidOperationException>( () => config.Property("Item")); Assert.Equal( Strings.LightweightEntityConfiguration_NonScalarProperty("Item"), ex.Message); }
public void Property_throws_when_nonscalar() { var type = new MockType() .Property <object>("NonScalar"); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws <InvalidOperationException>( () => config.Property("NonScalar")); Assert.Equal( Strings.LightweightEntityConfiguration_NonScalarProperty("NonScalar"), ex.Message); }
public void Property_returns_configuration() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration <LocalEntityType>(type, () => innerConfig, new ModelConfiguration()); var result = config.Property(e => e.Property1); Assert.NotNull(result); Assert.NotNull(result.ClrPropertyInfo); Assert.Equal("Property1", result.ClrPropertyInfo.Name); Assert.Equal(typeof(decimal), result.ClrPropertyInfo.PropertyType); Assert.NotNull(result.Configuration); Assert.IsType <Properties.Primitive.DecimalPropertyConfiguration>(result.Configuration()); }
public void Property_returns_configuration_for_complex_type_properties() { var type = typeof(AType); var innerConfig = new ComplexTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.IsComplexType(); var result = config.Property("Property5"); Assert.NotNull(result); Assert.NotNull(result.ClrPropertyInfo); Assert.Equal("Property5", result.ClrPropertyInfo.Name); Assert.Equal(typeof(decimal), result.ClrPropertyInfo.PropertyType); Assert.NotNull(result.Configuration); Assert.IsType <Properties.Primitive.DecimalPropertyConfiguration>(result.Configuration()); }
public ConventionPrimitivePropertyConfiguration Property <TProperty>(Expression <Func <T, TProperty> > propertyExpression) { Check.NotNull(propertyExpression, "propertyExpression"); return(_configuration.Property(propertyExpression.GetComplexPropertyAccess())); }
public void Property_returns_configuration_for_complex_type_properties() { var type = typeof(AType); var innerConfig = new ComplexTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); config.IsComplexType(); var result = config.Property("Property5"); Assert.NotNull(result); Assert.NotNull(result.ClrPropertyInfo); Assert.Equal("Property5", result.ClrPropertyInfo.Name); Assert.Equal(typeof(decimal), result.ClrPropertyInfo.PropertyType); Assert.NotNull(result.Configuration); Assert.IsType<Properties.Primitive.DecimalPropertyConfiguration>(result.Configuration()); }
public void Property_throws_when_not_exists() { var type = typeof(AType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); Assert.Equal( Strings.NoSuchProperty("DoesNotExist", type.Name), Assert.Throws<InvalidOperationException>(() => config.Property("DoesNotExist")).Message); Assert.Equal( "propertyInfo", Assert.Throws<ArgumentNullException>(() => config.Property((PropertyInfo)null)).ParamName); }
public void Property_throws_when_indexer() { var type = typeof(LocalEntityType); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws<InvalidOperationException>( () => config.Property("Item")); Assert.Equal( Strings.LightweightEntityConfiguration_NonScalarProperty("Item"), ex.Message); }
public void Property_evaluates_preconditions() { var type = new MockType(); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws<ArgumentException>( () => config.Property((string)null)); Assert.Equal(Strings.ArgumentIsNullOrWhitespace("propertyName"), ex.Message); }
public void Property_returns_configuration() { var type = new MockType() .Property<decimal>("Property1"); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var result = config.Property("Property1"); Assert.NotNull(result); Assert.NotNull(result.ClrPropertyInfo); Assert.Equal("Property1", result.ClrPropertyInfo.Name); Assert.Equal(typeof(decimal), result.ClrPropertyInfo.PropertyType); Assert.NotNull(result.Configuration); Assert.IsType<Properties.Primitive.DecimalPropertyConfiguration>(result.Configuration()); }
public void Property_throws_when_nonscalar() { var type = new MockType() .Property<object>("NonScalar"); var innerConfig = new EntityTypeConfiguration(type); var config = new ConventionTypeConfiguration(type, () => innerConfig, new ModelConfiguration()); var ex = Assert.Throws<InvalidOperationException>( () => config.Property("NonScalar")); Assert.Equal( Strings.LightweightEntityConfiguration_NonScalarProperty("NonScalar"), ex.Message); }