예제 #1
0
        /// <summary>
        /// Constrains the generator so that it only produces strings with lengths within the supplied range
        /// (inclusive).
        /// </summary>
        /// <param name="x">The first bound of the range.</param>
        /// <param name="y">The second bound of the range.</param>
        /// <returns>A new generator with the constraint applied.</returns>
        public static IStringGen WithLengthBetween(this IStringGen gen, int x, int y)
        {
            var minLength = x > y ? y : x;
            var maxLength = x > y ? x : y;

            return(gen.WithLengthGreaterThanEqual(minLength).WithLengthLessThanEqual(maxLength));
        }
예제 #2
0
 /// <summary>
 /// Constrains the generator so that it only produces strings with greater than the given Length.
 /// </summary>
 /// <param name="exclusiveMinLength">The minimum length that generated strings should be constrained to.</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static IStringGen WithLengthGreaterThan(this IStringGen gen, int exclusiveMinLength) =>
 gen.WithLengthGreaterThanEqual(exclusiveMinLength + 1);