nickdodd79 / AutoBogus

A C# library complementing the Bogus generator by adding auto creation and population capabilities.
MIT License
431 stars 50 forks source link

Add the ability to override the FakerHub used by all Fakers #31

Closed logiclrd closed 4 years ago

logiclrd commented 4 years ago

In our project, we want the ability to use repeatable random seeds with bogus data. As far as I can tell, the underlying Bogus library supports this by using a common FakerHub across all Faker instances -- this "hub" can then have its Randomizer configured at any time, affecting all future generated data, and if Randomizer is repeatedly set to an object with the same seed, then the same sequence of calls to Bogus will produce the same sequence of bogus data.

This PR adds the ability to configure AutoBogus to inject a caller-supplied Faker in as the FakerHub for calls into the underlying Bogus layer.

Unit tests verify the new configuration builder functionality and the injection of the FakerHub value itself.

nickdodd79 commented 4 years ago

Thanks for the contribution, @logiclrd. I will take a look and get it merged shortly.