Пример #1
0
        /// <summary>
        /// Creates an anonymous object, potentially using the supplied seed as additional
        /// information when creating the object.
        /// </summary>
        /// <typeparam name="T">The type of object to create.</typeparam>
        /// <param name="seed">
        /// Any data that adds additional information when creating the anonymous object.
        /// </param>
        /// <param name="composer">The composer used to resolve the type request.</param>
        /// <returns>An anonymous object.</returns>
        public static T CreateAnonymous <T>(this ISpecimenBuilderComposer composer, T seed)
        {
            if (composer == null)
            {
                throw new ArgumentNullException("composer");
            }

            return(composer.Compose().CreateContext().CreateAnonymous(seed));
        }
Пример #2
0
        /// <summary>
        /// Creates many anonymous objects.
        /// </summary>
        /// <typeparam name="T">The type of objects to create.</typeparam>
        /// <param name="composer">The composer 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>
        /// </remarks>
        public static IEnumerable <T> CreateMany <T>(this ISpecimenBuilderComposer composer, T seed, int count)
        {
            if (composer == null)
            {
                throw new ArgumentNullException("composer");
            }

            return(composer.Compose().CreateContext().CreateMany(seed, count));
        }
Пример #3
0
 internal static object CreateAnonymous(this ISpecimenBuilderComposer composer, Type type)
 {
     return(composer.Compose().CreateContext().Resolve(type));
 }
 internal static object CreateAnonymous(this ISpecimenBuilderComposer composer, object request)
 {
     return(new SpecimenContext(composer.Compose()).Resolve(request));
 }