Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible with Fixture to create a list of N objects?

Tags:

c#

fixture

I want to create with Fixture a list of N objects.

I know I can do it with:

List<Person> persons = new List<Person>();

for (int i = 0; i < numberOfPersons; i++)
{
    Person person = fixture.Build<Person>().Create();
    persons.Add(person);
}

Is there any way I can use the CreateMany() method or some other method in order to avoid the loop?

like image 403
Efstathios Chatzikyriakidis Avatar asked Dec 19 '22 10:12

Efstathios Chatzikyriakidis


1 Answers

Found the answer. CreateMany has some overloads that get 'count'.

Thanks people.

like image 160
Efstathios Chatzikyriakidis Avatar answered Dec 21 '22 23:12

Efstathios Chatzikyriakidis