I am writing an exporting function to take data from a database table and export to text. Before I plug the code into the rest of the app I would like to test the export based on random data created in c#. I have found many examples in SO about creating test data in a database but none that was created directly in code. Does anybody have an example or know of a link to one?
Thanks
You can use AutoFixture to generate pseudo-random data directly from C# code.
It is a convention-based and extensible library that uses reflection to populate objects with data.
It can be used as simply as this:
After the second line of code, the
mcinstance will be populated with all appropiate constructor parameters, and all writable properties will have been assigned.It supports nested hierachies, non-default constructors, mapping from interfaces to concrete types and many other things.
You can customize it (almost) to your heart’s content as well.