Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bogus.Faker: How to pick a random enum value

I'm using c# Bogus.Faker library to create random test data for my unit tests.
I want to know how to easily pick a random enum value ?

Any suggestions?

like image 241
hannes neukermans Avatar asked Oct 15 '18 15:10

hannes neukermans


1 Answers

Found the solution:
You have to use Faker.PickRandom<> method

i.TypeOfSchedule = Faker.PickRandom<Schedule>(); // with 'Schedule' of type Enum :-)
like image 167
hannes neukermans Avatar answered Nov 20 '22 01:11

hannes neukermans