4

I would like to ask your help to use Bogus Faker.

I have this

private readonly Faker _faker;

_faker = new Faker("fr");

List<string> _randomString = (List<string>)_faker.Make(3, () => _faker.Random.Word()); // OK

List<string[]> _randomStrinArray = (List<string[]>)_faker.Make(3, () => _faker.Random.Word()); // KO
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
jolynice
  • 514
  • 1
  • 8
  • 25

2 Answers2

7

Looks like you found your solution. That's great by the way!

Here are some other alternatives if you're intrested:

var faker = new Faker();

List<string> randomStrings = Enumerable.Range(1,7)
                       .Select(_ => faker.Random.Word())
                       .ToList();
randomStrings.Dump();

output

List<string[]> randomStringArray = Enumerable.Range(1,7)
      .Select(_ => faker.Random.WordsArray(1,4))
      .ToList();

randomStringArray.Dump();

enter image description here

Brian Chavez
  • 8,048
  • 5
  • 54
  • 47
4

Hello I found the solution

List<string[]> _randomStrinArray = (List<string[]>) _faker.Make(3, () => _faker.Random.WordsArray(1,4));
jolynice
  • 514
  • 1
  • 8
  • 25