Truly Constrained Non-Deterministic Numbers in AutoFixture
08 October 2012
Numbers in AutoFixture are currently created using a strictly monotonically increasing sequence.
Starting with version 2.13.0, by applying a specific customization numbers can also be created using a constrained non-deterministic sequence. The new customization is called
Once the customization has been applied to a
Fixture instance subsequent requests for numeric types will yield random non-repeatable numbers in the range of [1, 255]. When requesting more than 255 numbers the range is automatically changed to [256, 32767] and so on.
Supplying a custom range
To supply a custom range, customize an instance of the Fixture class with an instance of the
RandomNumericSequenceGenerator and pass to its constructor a sequence of integer numbers (e.g.
-100, 100, 255).
After applying the customization, numbers are now created in the range of [-100, 100]. However, when requesting more numbers than the range size the range is automatically changed to [101, 255].