Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PickRandom to accept a N parameter an return more than one item #21

Closed
mdmoura opened this issue Mar 22, 2016 · 2 comments
Closed

PickRandom to accept a N parameter an return more than one item #21

mdmoura opened this issue Mar 22, 2016 · 2 comments

Comments

@mdmoura
Copy link

mdmoura commented Mar 22, 2016

Hello,

I think it would be really useful that PickRandom could return more than one item.

.RuleFor(x => x.Tags, y => tags.OrderBy(z => Guid.NewGuid()).Take(4).ToList())

I think instead the following could be done:

.RuleFor(x => x.Tags, y => y.PickRandom(tags, 4))

Internally, the following could be used:

collection.OrderBy(x => Guid.NewGuid()).Take(n)

or any other option ...

Thanks,
Miguel

@bchavez
Copy link
Owner

bchavez commented Mar 23, 2016

Hi Miguel,

The API already has something similar. You could do this also:

.RuleFor(x => x.Tags, y => y.Random.Shuffle(tags).Take(4))

@mdmoura
Copy link
Author

mdmoura commented Mar 23, 2016

Got it ... missed that. Thanks

@mdmoura mdmoura closed this as completed Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants