oriches / faker-cs

C# port of the Ruby Faker gem (http://faker.rubyforge.org/)
MIT License
179 stars 52 forks source link

Allow setting a seed to always generate same data #13

Closed utillity closed 3 years ago

utillity commented 3 years ago

Hi,

in my opinion the need to use the Cryptographic random number generator is not needed, explicitly because if you want to always create the same data, you need to be able to set the Seed to a constant value. My change should be completely transparent and backward compatible to any users which do not need to set a constant seed.

I also added the corresponding tests.

The only change you must undo is the one to the .nuspec

Best, Tilli

utillity commented 3 years ago

As specified above: The only change you must undo is the one to the .nuspec

oriches commented 3 years ago

The rrandom function is designed to be random, not pseudo random clas from .Net.

utillity commented 3 years ago

If you search for "seeding a database with unit-test data" you will find that there are numerous tools out there which do this deterministic seeding. So there is a need for it and your tool could do both. But as I released my version to nuget as Faker.Net-Seed, I leave it up to you if you wish to also support this scenario, or if you think that just because you don't need it, noone will.

Siliconrob commented 3 years ago

I agree with @oriches here. If you want a consistent value for an input that seems like the case for a mock not random data as this was built to be a fairly robust random function