Пример #1
0
        /// <summary>
        /// Creates a configured <see cref="IAutoFaker"/> instance.
        /// </summary>
        /// <param name="configure">A handler to build the faker configuration.</param>
        /// <returns>The configured <see cref="IAutoFaker"/> instance.</returns>
        public static IAutoFaker Create(Action <IAutoGenerateConfigBuilder> configure = null)
        {
            var config  = new AutoConfig(DefaultConfig);
            var builder = new AutoConfigBuilder(config);

            configure?.Invoke(builder);

            return(new AutoFaker(config));
        }
Пример #2
0
        private AutoGenerateContext CreateContext(Action <IAutoGenerateConfigBuilder> configure)
        {
            var config  = new AutoConfig(Config);
            var builder = new AutoConfigBuilder(config);

            configure?.Invoke(builder);

            return(new AutoGenerateContext(config));
        }
Пример #3
0
        /// <summary>
        /// Configures the current faker instance.
        /// </summary>
        /// <param name="configure">A handler to build the faker configuration.</param>
        /// <returns>The current faker instance.</returns>
        public AutoFaker <TType> Configure(Action <IAutoGenerateConfigBuilder> configure)
        {
            var config  = new AutoConfig(AutoFaker.DefaultConfig);
            var builder = new AutoConfigBuilder(config);

            configure?.Invoke(builder);

            Config = config;

            return(this);
        }
Пример #4
0
        private AutoFaker <TType> CreateFaker <TType, TFaker>(Action <IAutoFakerConfigBuilder> configure)
            where TType : class
            where TFaker : AutoFaker <TType>
        {
            // Invoke the config builder
            var config  = new AutoConfig(Config);
            var builder = new AutoConfigBuilder(config);

            configure?.Invoke(builder);

            // Dynamically create the faker instance
            var type  = typeof(TFaker);
            var faker = (AutoFaker <TType>)Activator.CreateInstance(type, builder.Args);

            faker.Config = builder.Config;

            return(faker);
        }
Пример #5
0
        /// <summary>
        /// Configures all faker instances and generate requests.
        /// </summary>
        /// <param name="configure">A handler to build the default faker configuration.</param>
        public static void Configure(Action <IAutoFakerDefaultConfigBuilder> configure)
        {
            var builder = new AutoConfigBuilder(DefaultConfig);

            configure?.Invoke(builder);
        }