GenFu icon indicating copy to clipboard operation
GenFu copied to clipboard

Genfu instances

Open marcoregueira opened this issue 6 years ago • 0 comments

GenFu has been refactored to allow creation of instances. This will allow creation of specialized generators and usage in DI.

var childGenerator = new GenFuInstance();
var adultGenerator = new GenFuInstance();

childGenerator.Configure<Person>().Fill(x => x.Age).WithinRange(1, 10);
adultGenerator.Configure<Person>().Fill(x => x.Age).WithinRange(20, 100);

Classic static usage is still supported. No breaking changes, as you can see in the tests.

The only breaking change is the class CalendarDate that doesn't support static usage anymore. It could be reworked to avoid the change but that would mean having two versions of this class, the old static and a new one, that could be misleading. I think the impact for this change will be minimum, anyway.

Property fillers are overloaded to allow passing a GenFu instance. They will use the global instance when none is provided to avoid breaking changes, but I have the feeling that requiring an instance would be better for clarity.

marcoregueira avatar Dec 20 '18 09:12 marcoregueira