public static void Main()
TestNoStrictModeMissingPropertyRule();
TestStrictModeMissingPropertyRule();
TestGlobalStrictModeMissingPropertyRule();
public static void TestNoStrictModeMissingPropertyRule()
WriteTitle("No strict mode. FirstName only.");
var personFaker = new Faker<Person>()
.RuleFor(p => p.FirstName, f => f.Name.FirstName());
var person = personFaker.Generate();
public static void TestStrictModeMissingPropertyRule()
WriteTitle("Yes strict mode. FirstName only.");
var personFaker = new Faker<Person>()
.RuleFor(p => p.FirstName, f => f.Name.FirstName());
var person = personFaker.Generate();
Console.WriteLine("Exception: ");
Console.WriteLine(e.Message);
public static void TestGlobalStrictModeMissingPropertyRule()
WriteTitle("Yes global strict mode. FirstName only.");
Faker.DefaultStrictMode = true;
var personFaker = new Faker<Person>()
.RuleFor(p => p.FirstName, f => f.Name.FirstName());
var person = personFaker.Generate();
Console.WriteLine("Exception: ");
Console.WriteLine(e.Message);
public static void WriteTitle(string title)
Console.WriteLine("====================================");
Console.WriteLine(title);
public static void WriteJson(object obj)
var options = new JsonSerializerOptions { WriteIndented = true};
var json = JsonSerializer.Serialize(obj, options);
public string FirstName {get; set;}
public string LastName {get; set;}