Search code examples
c#unit-testingbogus

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?


Solution

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

    i.TypeOfSchedule = Faker.PickRandom<Schedule>(); // with 'Schedule' of type Enum :-)