/// <summary> /// Anies the specified populate option. /// </summary> /// <typeparam name="T">The type of the object to create.</typeparam> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="populateOption">Specifies how to populate the properties.</param> /// <returns>An instance of the specified type.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is null.</exception> public static T Any <T>(this IAnonymousData anon, PopulateOption populateOption) { Argument.NotNull(anon, nameof(anon)); return((T)anon.Any(typeof(T), populateOption)); }
/// <summary> /// Freezes the specified value as the result for any further calls to <see cref="Any"/> /// for the specified type. /// </summary> /// <typeparam name="T">The type to freeze.</typeparam> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="value">The instance to freeze.</param> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static void Freeze <T>(this IRegisterAnonymousData anon, T value) { Argument.NotNull(anon, nameof(anon)); anon.Freeze(typeof(T), value); }
/// <summary> /// Creates a random positive <see langword="double"/> value. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random positive <see langword="double"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static double AnyNegativeDouble(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyDouble(float.MinValue, 0, Distribution.Uniform)); }
/// <summary> /// Creates a random <see langword="string"/> value representing a surname. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random first name.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static string AnySurname(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyItem(Surnames)); }
/// <summary> /// Creates a random <see langword="short"/> value using a uniform distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random <see langword="short"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static short AnyInt16(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyInt16(short.MinValue, short.MaxValue, Distribution.Uniform)); }
/// <summary> /// Creates a random <see langword="TimeSpan"/> value using the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random <see langword="TimeSpan"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static TimeSpan AnyTimeSpan(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyTimeSpan(TimeSpan.MinValue, TimeSpan.MaxValue, distribution)); }
/// <summary> /// Creates an anonymous <see langword="char"/> value within the range of basic Latin characters using /// the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random basic Latin character.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static char AnyBasicLatinChar(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyChar((char)BasicLatinCharRange.Minimum, (char)BasicLatinCharRange.Maximum, distribution)); }
/// <summary> /// Creates an anonymous <see langword="DateTime"/> value using a uniform distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random <see langword="DateTime"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception> public static DateTime AnyDateTime(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyDateTime(DateTime.MinValue, DateTime.MaxValue, Distribution.Uniform)); }
/// <summary> /// Creates an anonymous <see langword="char"/> value within the range of alpha/numeric characters /// using the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random alpha/numeric character.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static char AnyAlphaNumericChar(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return((char)Range.CreateLongFromRanges(anon, distribution, LowerCaseAlphaRange, UpperCaseAlphaRange, NumericRange)); }
/// <summary> /// Creates an anonymous <see langword="char"/> value within the range of basic Latin characters using /// a uniform distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random basic Latin character.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static char AnyBasicLatinChar(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyBasicLatinChar(Distribution.Uniform)); }
/// <summary> /// Creates an anonymous <see langword="char"/> value within the range of printable characters /// using the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random printable character.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static char AnyPrintableChar(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return((char)Range.CreateLongFromRanges(anon, distribution, BasicLatinCharRange, LatinSupplementRange)); }
/// <summary> /// Creates an anonymous <see langword="char"/> value using the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random <see langword="char"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static char AnyChar(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyChar(char.MinValue, char.MaxValue, distribution)); }
/// <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 <see langword="null"/>.</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>()); }
/// <summary> /// Populates the specified instance by assigning all properties to anonymous values. /// </summary> /// <typeparam name="TInstance">The type of the instance to populate.</typeparam> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="instance">The instance to populate.</param> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is null.</exception> /// <returns>The populated instance.</returns> public static TInstance Populate <TInstance>(this IAnonymousData anon, TInstance instance) { Argument.NotNull(anon, nameof(anon)); return(anon.Populate(instance, false)); }
/// <summary> /// Creates a random positive <see langword="float"/> value. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random positive <see langword="float"/> value.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception> /// <remarks> /// This method may return a zero value, which strictly makes this "any non-negative" from a mathematical /// perspective, but the term "positive" is used because this is what many would expect. /// </remarks> public static float AnyPositiveSingle(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnySingle(0, float.MaxValue, distribution)); }
/// <summary> /// Creates an object of the specified type and optionally populates the properties. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="type">The type to create..</param> /// <returns>An instance of the specified type.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> or <paramref name="type"/> /// is null.</exception> public static object Any(this IAnonymousData anon, Type type) { Argument.NotNull(anon, nameof(anon)); return(anon.Any(type, PopulateOption.None)); }
/// <summary> /// Creates a random <see langword="float"/> value using a uniform distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random <see langword="float"/> value.</returns> /// <exception cref="System.ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception> public static float AnySingle(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnySingle(float.MinValue, float.MaxValue, Distribution.Uniform)); }
/// <summary> /// Creates a random positive <see langword="short"/> value. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random positive <see langword="short"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> /// <remarks> /// This method may return a zero value, which strictly makes this "any non-negative" from a mathematical /// perspective, but the term "positive" is used because this is what many would expect. /// </remarks> public static short AnyPositiveInt16(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyInt16(0, short.MaxValue, distribution)); }
/// <summary> /// Creates a random <see langword="string"/> value representing a full name. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <returns>A random full name.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static string AnyFullName(this IAnonymousData anon) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyFullName(anon.AnyBool())); }
/// <summary> /// Creates a random positive <see langword="short"/> value. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random positive <see langword="short"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static short AnyNegativeInt16(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyInt16(short.MinValue, -1, distribution)); }
/// <summary> /// Creates a random <see langword="string"/> value with a length of 0 to 20 characters using /// the specified distribution algorithm for generating alpha characters. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random <see langword="string"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static string AnyString(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyString(0, 20, distribution)); }
/// <summary> /// Creates a random <see langword="DateTimeOffset"/> value using the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random <see langword="DateTimeOffset"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception> public static DateTimeOffset AnyDateTimeOffset(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyDateTimeOffset(DateTimeOffset.MinValue, DateTimeOffset.MaxValue, distribution)); }
/// <summary> /// Creates a random <see langword="double"/> value using the specified distribution algorithm. /// </summary> /// <param name="anon">The anonymous data provider to use.</param> /// <param name="distribution">The distribution algorithm to use.</param> /// <returns>A random <see langword="double"/> value.</returns> /// <exception cref="ArgumentNullException"><paramref name="anon"/> is <c>null</c>.</exception> public static double AnyDouble(this IAnonymousData anon, Distribution distribution) { Argument.NotNull(anon, nameof(anon)); return(anon.AnyDouble(float.MinValue, float.MaxValue, distribution)); }