Exemple #1
0
        /// <summary>
        /// Constrains the generator so that it only produces sets with counts 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 ISetGen <T> WithCountBetween <T>(this ISetGen <T> gen, int x, int y)
        {
            var minCount = x > y ? y : x;
            var maxCount = x > y ? x : y;

            return(gen.WithCountGreaterThanEqual(minCount).WithCountLessThanEqual(maxCount));
        }
Exemple #2
0
            void ShouldError(ISetGen <object> gen)
            {
                Action action = () => gen.SampleOne(seed: seed, size: size);

                action.Should()
                .Throw <GalaxyCheck.Exceptions.GenErrorException>()
                .WithMessage("Error while running generator SetGen: 'minCount' cannot be greater than 'maxCount'");
            }
Exemple #3
0
 /// <summary>
 /// Constrains the generator so that it only produces sets less than the given count.
 /// </summary>
 /// <param name="exclusiveMaxCount">The maximum count that generated sets should be constrained to.</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static ISetGen <T> WithCountLessThan <T>(this ISetGen <T> gen, int exclusiveMaxCount) =>
 gen.WithCountLessThanEqual(exclusiveMaxCount - 1);
Exemple #4
0
 /// <summary>
 /// Constrains the generator so that it only produces sets with greater than the given count.
 /// </summary>
 /// <param name="exclusiveMinCount">The minimum count that generated sets should be constrained to.</param>
 /// <returns>A new generator with the constraint applied.</returns>
 public static ISetGen <T> WithCountGreaterThan <T>(this ISetGen <T> gen, int exclusiveMinCount) =>
 gen.WithCountGreaterThanEqual(exclusiveMinCount + 1);