Creating test data in code

I am writing an export function to collect data from a database table and export to text. Before I connect the code to the rest of the application, I would like to test the export based on random data created in C #. I found many examples in SO about creating test data in a database, but not one of them was created directly in the code. Does anyone have an example or know a link to it?

thank

+5
source share
2 answers

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.

:

Fixture fixture = new Fixture();
MyClass mc = fixture.CreateAnonymous<MyClass>();

mc , .

, , .

() .

+5
0

All Articles