public static IfFilterExpression IfPropertyNameContains <TType>( this ConventionExpression conventionExpression, params string[] propertyNames) { return(conventionExpression.IfProperty(p => p.PropertyType == typeof(TType) && propertyNames.Any(propertyName => p.Name.Contains(propertyName)))); }
private static void Names(ConventionExpression cfg) { cfg.IfPropertyNameIs("Name").Use(faker => faker.Name.FullName()); cfg.IfPropertyNameIs("FullName").Use(faker => faker.Name.FullName()); cfg.IfPropertyNameIs("FirstName").Use(faker => faker.Name.FirstName()); cfg.IfPropertyNameIs("LastName").Use(faker => faker.Name.LastName()); }
public static IfFilterExpression IfPropertyIs <TType>( this ConventionExpression conventionExpression, Expression <Func <TType, object> > expression) where TType : class { return(conventionExpression.IfProperty(p => p.DeclaringType == typeof(TType) && p.Name == expression.ToAccessor().Name)); }
public static IfFilterExpression IfPropertyImplements( this ConventionExpression conventionExpression, Type typeImplemented) { return(conventionExpression.IfProperty(p => p.PropertyType.Implements(typeImplemented) || p.PropertyType.ImplementsGenericOf(typeImplemented))); }
public static IfFilterExpression IfPropertyIs <TClass, TProperty>( this ConventionExpression conventionExpression, Expression <Func <TClass, TProperty> > property) { var accessor = property.ToAccessor(); return(conventionExpression.IfProperty(p => p.DeclaringType == accessor.OwnerType && p.PropertyType == accessor.PropertyType)); }
public static ConventionExpression AddEntityFramework(this ConventionExpression cfg) { cfg.IfProperty(p => p.Name.EndsWith("Id")).Ignore(); cfg.IfProperty(p => p.PropertyType.Implements(typeof(Collection <>)) || p.PropertyType.ImplementsGenericOf(typeof(Collection <>))).Ignore(); return(cfg); }
private static void Address(ConventionExpression cfg) { cfg.IfPropertyNameIs("Street").Use(faker => faker.Address.StreetAddress()); cfg.IfPropertyNameIs("Complement").Use(faker => faker.Address.BuildingNumber()); cfg.IfPropertyNameIs("State").Use(faker => faker.Address.State()); cfg.IfPropertyNameIs("City").Use(faker => faker.Address.City()); cfg.IfPropertyNameIs("PostalCode").Use(faker => faker.Address.ZipCode()); }
public static ConventionExpression AddAutoFaker(this ConventionExpression cfg) { Names(cfg); Address(cfg); cfg.Use(f => f.Phone.PhoneNumber()).If(_ => { _.IfPropertyNameIs("Phone"); _.IfPropertyNameIs("PhoneNumber"); }); cfg.IfPropertyNameIs("Email").Use(faker => faker.Internet.Email()); cfg.IfPropertyNameIs("CompanyName").Use(faker => faker.Company.CompanyName()); return(cfg); }
public static IfFilterExpression IfPropertyNameIs( this ConventionExpression conventionExpression, string propertyName) { return(conventionExpression.IfProperty(p => p.Name == propertyName)); }
public static IfFilterExpression IfClassImplements <TType>(this ConventionExpression conventionExpression) { return(conventionExpression.IfClass(t => t.Implements <TType>())); }
public static IfFilterExpression IfClassIs <TType>(this ConventionExpression conventionExpression) { return(conventionExpression.IfClass(t => t == typeof(TType))); }
public static IfFilterExpression IfPropertyImplementsEnumerableOf <TType>( this ConventionExpression conventionExpression) { return(conventionExpression.IfProperty(p => p.PropertyType.ImplementsEnumerableOf <TType>())); }
public static IfFilterExpression IfPropertyTypeIs <TType>(this ConventionExpression conventionExpression) { return(conventionExpression.IfProperty(p => p.PropertyType == typeof(TType))); }
public static IfFilterExpression IfPropertyNameEnds( this ConventionExpression conventionExpression, string propertyNameEnd) { return(conventionExpression.IfProperty(p => p.Name.EndsWith(propertyNameEnd))); }