コード例 #1
0
ファイル: AnonymousInt16.cs プロジェクト: stan-osipov/testify
        /// <summary>
        /// Creates a random <see langword="short"/> value within the specified range using the specified
        /// distribution algorithm.
        /// </summary>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="minimum">The minimum value.</param>
        /// <param name="maximum">The maximum value.</param>
        /// <param name="distribution">The distribution algorithm to use.</param>
        /// <returns>A random <see langword="short"/> value.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        ///     <paramref name="maximum"/> is less than <paramref name="minimum"/>.
        /// </exception>
        public static short AnyInt16(this IAnonymousData anon, short minimum, short maximum, Distribution distribution)
        {
            Argument.NotNull(anon, nameof(anon));
            Argument.InRange(
                maximum,
                minimum,
                short.MaxValue,
                nameof(maximum),
                "The maximum value must be greater than the minimum value.");

            return((short)anon.AnyInt64(minimum, maximum, distribution));
        }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
ファイル: AnonymousInt16.cs プロジェクト: stan-osipov/testify
        /// <summary>
        /// Creates a random <see langword="short"/> 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="short"/> value.</returns>
        /// <exception cref="System.ArgumentNullException"><paramref name="anon"/> is <see langword="null"/>.</exception>
        public static short AnyInt16(this IAnonymousData anon, Distribution distribution)
        {
            Argument.NotNull(anon, nameof(anon));

            return(anon.AnyInt16(short.MinValue, short.MaxValue, distribution));
        }
コード例 #4
0
        /// <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));
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <summary>
        /// Creates an anonymous <see langword="char"/> value within the specified range using the specified
        /// distribution algorithm.
        /// </summary>
        /// <param name="anon">The anonymous data provider to use.</param>
        /// <param name="minimum">The minimum value.</param>
        /// <param name="maximum">The maximum value.</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, char minimum, char maximum, Distribution distribution)
        {
            Argument.NotNull(anon, nameof(anon));
            Argument.InRange(maximum, minimum, char.MaxValue, nameof(maximum), "The maximum value must be greater than the minimum value.");

            return((char)anon.AnyInt64(minimum, maximum, distribution));
        }
コード例 #7
0
        /// <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));
        }
コード例 #8
0
ファイル: AnonymousDouble.cs プロジェクト: dmrickey/testify
        /// <summary>
        /// Creates a random positive <see langword="double"/> 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="double"/> 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 double AnyPositiveDouble(this IAnonymousData anon, Distribution distribution)
        {
            Argument.NotNull(anon, nameof(anon));

            return(anon.AnyDouble(0, float.MaxValue, distribution));
        }