public static IAutoGenerateConfigBuilder RuleForPropNameOf <TValue>(this IAutoGenerateConfigBuilder builder,
                                                                     string propName,
                                                                     Func <Faker, TValue> generator,
                                                                     StringComparison nameComparison = StringComparison.OrdinalIgnoreCase)
 {
     return(builder.WithOverride(new PropNameGenerator <TValue>(propName, nameComparison, generator)));
 }
Esempio n. 2
0
        /// <summary>
        /// Registers a binder type to use when generating values.
        /// </summary>
        /// <typeparam name="TBinder">The <see cref="IAutoBinder"/> type to use.</typeparam>
        /// <param name="builder">The current configuration builder instance.</param>
        /// <returns>The current configuration builder instance.</returns>
        public static IAutoGenerateConfigBuilder WithBinder <TBinder>(this IAutoGenerateConfigBuilder builder)
            where TBinder : IAutoBinder, new()
        {
            var binder = new TBinder();

            return(builder?.WithBinder(binder));
        }
Esempio n. 3
0
        /// <summary>
        /// Registers an override instance to use when generating values.
        /// </summary>
        /// <typeparam name="TType">The type of instance to override.</typeparam>
        /// <typeparam name="TValue">The member type to override.</typeparam>
        /// <param name="builder">The current configuration builder instance.</param>
        /// <param name="member">The member to override.</param>
        /// <param name="generator">A handler used to generate the override.</param>
        /// <returns>The current configuration builder instance.</returns>
        public static IAutoGenerateConfigBuilder WithOverride <TType, TValue>(this IAutoGenerateConfigBuilder builder, Expression <Func <TType, object> > member, Func <AutoGenerateOverrideContext, TValue> generator)
        {
            var memberName        = GetMemberName(member);
            var generatorOverride = new AutoGeneratorMemberOverride <TType, TValue>(memberName, generator);

            return(builder?.WithOverride(generatorOverride));
        }
        /// <summary>
        /// Registers the conventions overrides.
        /// </summary>
        /// <param name="builder">The current configuration builder instance.</param>
        /// <param name="configure">A handler for configuring the conventions.</param>
        /// <returns>The current configuration builder instance.</returns>
        public static IAutoGenerateConfigBuilder WithConventions(this IAutoGenerateConfigBuilder builder, Action <AutoConventionConfig> configure = null)
        {
            var conventions = CreateConventionsOverride(configure);

            return(builder?.WithOverride(conventions));
        }
 public static IAutoGenerateConfigBuilder RuleForType <TValue>(this IAutoGenerateConfigBuilder builder, Func <Faker, TValue> generator) =>
 builder.WithOverride(new TypeGenerator <TValue>(generator));
Esempio n. 6
0
        /// <summary>
        /// Registers an override instance to use when generating values.
        /// </summary>
        /// <typeparam name="TType">The type of instance to override.</typeparam>
        /// <param name="builder">The current configuration builder instance.</param>
        /// <param name="generator">A handler used to generate the override.</param>
        /// <returns>The current configuration builder instance.</returns>
        public static IAutoGenerateConfigBuilder WithOverride <TType>(this IAutoGenerateConfigBuilder builder, Func <AutoGenerateOverrideContext, TType> generator)
        {
            var generatorOverride = new AutoGeneratorTypeOverride <TType>(generator);

            return(builder?.WithOverride(generatorOverride));
        }
Esempio n. 7
0
        /// <summary>
        /// Registers a type to skip when generating values.
        /// </summary>
        /// <typeparam name="TType">The type to skip.</typeparam>
        /// <param name="builder">The current configuration builder instance.</param>
        /// <returns>The current configuration builder instance.</returns>
        public static IAutoGenerateConfigBuilder WithSkip <TType>(this IAutoGenerateConfigBuilder builder)
        {
            var type = typeof(TType);

            return(builder?.WithSkip(type));
        }
Esempio n. 8
0
        /// <summary>
        /// Registers a member to skip for a given type when generating values.
        /// </summary>
        /// <typeparam name="TType">The parent type containing the member.</typeparam>
        /// <param name="builder">The current configuration builder instance.</param>
        /// <param name="member">The member to skip.</param>
        /// <returns>The current configuration builder instance.</returns>
        public static IAutoGenerateConfigBuilder WithSkip <TType>(this IAutoGenerateConfigBuilder builder, Expression <Func <TType, object> > member)
        {
            var memberName = GetMemberName(member);

            return(builder?.WithSkip <TType>(memberName));
        }