Пример #1
0
        /// <summary>
        /// Creates a random <see langword="IEnumerable{T}"/> sequence of objects of the specified type.
        /// </summary>
        /// <typeparam name="T">The type of objects to create.</typeparam>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="minimumLength">The minimum length of the sequence.</param>
        /// <param name="maximumLength">The maximum length of the sequence.</param>
        /// <returns>A random <see langword="IEnumerable{T}"/> sequence of the specified type of objects.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="maximumLength"/> is less than <paramref name="minimumLength"/>.</exception>
        public static IEnumerable <T> AnyEnumerable <T>(this IAnonymousData anon, int minimumLength, int maximumLength)
        {
            Argument.NotNull(anon, nameof(anon));
            Argument.InRange(maximumLength, minimumLength, int.MaxValue, nameof(maximumLength), "The maximum length must be greater than the minimum length.");

            return(anon.AnyEnumerable(typeof(T), minimumLength, maximumLength).Cast <T>());
        }
Пример #2
0
        /// <summary>
        /// Creates a random <see langword="IEnumerable"/> sequence of 0 to 20 objects of the specified type.
        /// </summary>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="type">The type of objects to create.</param>
        /// <returns>A random <see langword="IEnumerable"/> sequence of the specified type of objects.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> or <paramref name="type"/> is <c>null</c>.</exception>
        public static IEnumerable AnyEnumerable(this IAnonymousData anon, Type type)
        {
            Argument.NotNull(anon, nameof(anon));
            Argument.NotNull(type, nameof(type));

            return(anon.AnyEnumerable(type, 0, 20));
        }
Пример #3
0
        /// <summary>
        /// Creates a random <see langword="IEnumerable"/> sequence of 0 to 20 objects of the specified type.
        /// </summary>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="type">The type of objects to create.</param>
        /// <returns>A random <see langword="IEnumerable"/> sequence of the specified type of objects.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> or <paramref name="type"/> is <c>null</c>.</exception>
        public static IEnumerable AnyEnumerable(this IAnonymousData anon, Type type)
        {
            Argument.NotNull(anon, nameof(anon));
            Argument.NotNull(type, nameof(type));

            return(anon.AnyEnumerable(type, anon.GetMinimumItemCount(), anon.GetMaximumItemCount()));
        }
Пример #4
0
        /// <summary>
        /// Creates an anonymous sequence of items.
        /// </summary>
        /// <param name="anon">The anonymous data provider to use when creating items.</param>
        /// <returns>An <see cref="IEnumerable{T}"/> sequence of new items.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception>
        /// <exception cref="AnonymousDataException">The specified type could not be created.</exception>
        internal static IEnumerable <T> AnyEnumerable(IAnonymousData anon)
        {
            Argument.NotNull(anon, nameof(anon));

            return(anon.AnyEnumerable <T>());
        }
Пример #5
0
        /// <summary>
        /// Creates a random <see langword="IEnumerable{T}"/> sequence of 0 to 20 objects of the specified type.
        /// </summary>
        /// <typeparam name="T">The type of objects to create.</typeparam>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <returns>A random <see langword="IEnumerable{T}"/> sequence of the specified type of objects.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception>
        public static IEnumerable <T> AnyEnumerable <T>(this IAnonymousData anon)
        {
            Argument.NotNull(anon, nameof(anon));

            return(anon.AnyEnumerable(typeof(T), 0, 20).Cast <T>());
        }
Пример #6
0
        /// <summary>
        /// Creates a random <see langword="IEnumerable{T}"/> sequence of 0 to 20 objects of the specified type.
        /// </summary>
        /// <typeparam name="T">The type of objects to create.</typeparam>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <returns>A random <see langword="IEnumerable{T}"/> sequence of the specified type of objects.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception>
        public static IEnumerable <T> AnyEnumerable <T>(this IAnonymousData anon)
        {
            Argument.NotNull(anon, nameof(anon));

            return(anon.AnyEnumerable(typeof(T), anon.GetMinimumItemCount(), anon.GetMaximumItemCount()).Cast <T>());
        }