Reputation: 1871
How can I set up AutoFixture so that when it generates an iterable, the RepeatCount
will be different each time? I know I can manually change it each time, but I was wondering if there's some setting that I can change when I initialize the fixture.
Upvotes: 1
Views: 251
Reputation: 233125
AutoFixture doesn't have such a feature, but in a pinch, you can do something like this:
var fixture = new Fixture();
var rnd = new Random();
var foos = fixture.CreateMany<Foo>(rnd.Next(10));
or
var fixture = new Fixture();
var rnd = new Random();
var foos = fixture.Create<Generator<Foo>>().Take(rnd.Next(10));
If, however, you're interested in taking a more principled step in that direction, you should look at FsCheck or Hedgehog.
Upvotes: 1