typestar

fake_seed_data.cs in C#

Bogus generates the realistic test data you did not want to write.

// fake_seed_data: Bogus builds realistic fixtures from declarative rules
using Bogus;

var faker = new Faker<User>()
    .CustomInstantiator(f => new User(
        f.Name.FullName(),
        f.Internet.Email(),
        f.Random.Int(18, 80)));

var users = faker.Generate(5);
foreach (var user in users)
{
    Console.WriteLine($"{user.Name,-24} {user.Age,3}  {user.Email}");
}

var adults = users.Count(u => u.Age >= 30);
Console.WriteLine($"{adults} of {users.Count} are 30 or older");

record User(string Name, string Email, int Age);

How it works

  1. A Faker<User> holds the rules; CustomInstantiator fills a record.
  2. Generate(5) yields fresh, plausible users each run.
  3. Downstream code — the count of 30+ — treats it as real data.

Keywords and builtins used here

The run, in numbers

Lines
19
Characters to type
505
Tokens
113
Three-star pace
85 tpm

At the three-star pace of 85 tokens a minute, this run takes about 80 seconds.

Type this snippet

Step 2 of 2 in Encore, step 16 of 16 in The open ecosystem.

← Previous