Bogus.Faker: How to pick a random enum value
Asked Answered
B

1

36

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?

Bonsai answered 15/10, 2018 at 15:0 Comment(0)
B
49

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

i.TypeOfSchedule = Faker.PickRandom<Schedule>(); // with 'Schedule' of type Enum :-)
Bonsai answered 15/10, 2018 at 15:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.