Exemple #1
0
 /// <summary>Creates many anonymous objects.</summary>
 /// <typeparam name="T">The type of objects to create.</typeparam>
 /// <param name="builder">
 /// The builder used to resolve the type request.
 /// </param>
 /// <param name="seed">
 /// An initial value that may or may not be used as input for the
 /// algorithm creating the return value.
 /// </param>
 /// <param name="count">The number of objects to create.</param>
 /// <returns>
 /// A sequence of anonymous objects of type <typeparamref name="T"/>.
 /// </returns>
 /// <remarks>
 /// <para>
 /// The CreateMany implementation always returns a new instance of
 /// <see cref="IEnumerable{T}" />. Even if IEnumerable&lt;T&gt; is
 /// Frozen by the <see cref="FixtureFreezer.Freeze(IFixture)" /> method
 /// or explicitly assigned with the
 /// <see cref="FixtureRegistrar.Inject{T}(IFixture, T)" /> method, the
 /// CreateMany method returns a new, independent instance of
 /// IEnumerable&lt;T&gt;.
 /// </para>
 /// <para>
 /// However, you can change this behavior, for example by applying the
 /// <see cref="MapCreateManyToEnumerable" /> customization.
 /// </para>
 /// </remarks>
 public static IEnumerable <T> CreateMany <T>(
     this ISpecimenBuilder builder,
     T seed,
     int count)
 {
     return(builder.CreateContext().CreateMany(seed, count));
 }
Exemple #2
0
 /// <summary>
 /// Creates an anonymous variable of the requested type.
 /// </summary>
 /// <typeparam name="T">The type of object to create.</typeparam>
 /// <param name="builder">
 /// The builder used to resolve the type request.
 /// </param>
 /// <returns>
 /// An anonymous object of type <typeparamref name="T"/>.
 /// </returns>
 public static T Create <T>(this ISpecimenBuilder builder)
 {
     return(builder.CreateContext().Create <T>());
 }
Exemple #3
0
 internal static object Create(this ISpecimenBuilder composer, Type type)
 {
     return(composer.CreateContext().Resolve(type));
 }
Exemple #4
0
 /// <summary>Creates many anonymous objects.</summary>
 /// <typeparam name="T">The type of objects to create.</typeparam>
 /// <param name="builder">
 /// The builder used to resolve the type request.
 /// </param>
 /// <returns>
 /// A sequence of anonymous object of type <typeparamref name="T"/>.
 /// </returns>
 /// <remarks>
 /// <para>
 /// The CreateMany implementation always returns a new instance of
 /// <see cref="IEnumerable{T}" />. Even if IEnumerable&lt;T&gt; is
 /// Frozen by the <see cref="FixtureFreezer.Freeze(IFixture)" /> method
 /// or explicitly assigned with the
 /// <see cref="FixtureRegistrar.Inject{T}(IFixture, T)" /> method, the
 /// CreateMany method returns a new, independent instance of
 /// IEnumerable&lt;T&gt;.
 /// </para>
 /// <para>
 /// However, you can change this behavior, for example by applying the
 /// <see cref="MapCreateManyToEnumerable" /> customization.
 /// </para>
 /// </remarks>
 public static IEnumerable <T> CreateMany <T>(
     this ISpecimenBuilder builder)
 {
     return(builder.CreateContext().CreateMany <T>());
 }
 public static object Create(this ISpecimenBuilder builder, PropertyInfo property) => builder.CreateContext().Resolve(property);
 public static object Create(this ISpecimenBuilder builder, Type type) => builder.CreateContext().Resolve(type);