AutoBogus.Conventions allow aliases to be configured, expanding the property name targets associated with a given convention mapping. The following adds AnotherEmail and AlternateEmail property names as candidates for the Email generator:
AutoFaker.Configure(builder =>
{
builder.WithConventions(config =>
{
config.Email.Aliases(new [] { "AnotherEmail", "AlternateEmail" }); // Generates an email value for members named AnotherEmail & AlternateEmail
});
});
Feature Request
Allow Aliases with expression parameter.
Example:
AutoFaker.Configure(builder =>
{
builder.WithConventions(config =>
{
config.Email.Aliases<EntityName>(propName => propName.Contains("Email")); // Generates an email value for members with names containing Email
});
});
Work Around
builder.WithConventions(config =>
{
var emailProps = (from prop in typeof(<EntityType>).GetProperties() where prop.Name.Contains("Email") select prop.Name).ToArray();
config.Email.Aliases(emailProps);
})
I'm unsure how much overhead or complexity is involved with such a feature. However, this is quite useful when dealing with large flattened entities.
AutoBogus.Conventions allow aliases to be configured, expanding the property name targets associated with a given convention mapping. The following adds
AnotherEmail
andAlternateEmail
property names as candidates for the Email generator:Feature Request
Allow Aliases with expression parameter. Example:
Work Around
I'm unsure how much overhead or complexity is involved with such a feature. However, this is quite useful when dealing with large flattened entities.