-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMockData.cs
More file actions
37 lines (28 loc) · 1 KB
/
MockData.cs
File metadata and controls
37 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#:package Bogus 35.6.3
using System.Text.Json;
using Bogus;
if(!int.TryParse(args.FirstOrDefault(), out var count))
{
count = 50;
}
Console.WriteLine($"Generating {count} fake people...");
var people = new Faker<Person>()
.RuleFor(p => p.FirstName, f => f.Name.FirstName())
.RuleFor(p => p.LastName, f => f.Name.LastName())
.RuleFor(p => p.Email, (f, p) => f.Internet.Email(p.FirstName, p.LastName))
.RuleFor(p => p.Address, f => f.Address.FullAddress())
.Generate(count);
var json = JsonSerializer.Serialize(people, new JsonSerializerOptions
{
WriteIndented = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
});
File.WriteAllText("people.json", json);
Console.WriteLine($"Generated {count} fake people and saved to 'people.json'.");
record Person
{
public required string FirstName { get; set; }
public required string LastName { get; set; }
public required string Email { get; set; }
public required string Address { get; set; }
}