I know that this has already been answered, and the Generator was a very interesting finding. I think there is a much simpler approach for this problem.
var numberOfEnumValues = Enum.GetValues(typeof(Status)).Length; var users = fixture.CreateMany<User>(numberOfEnumValues);
In case the constructor is more complex, with several status values ββor the model has property identifiers of type Status. Then, as a rule, you have a problem, and the generator can hit too.
Say that:
public class SuperUser : User { public SuperUser(Status status, Status shownStatus): base(status) { } }
Then it will never be appreciated:
var users = fixture.Create<Generator<SuperUser>>(); var offlineUser = users.Where(u => u.Status == Status.Offline).First();
Spiros dellaportas
source share