Home - baileydauterman/Faker.NET GitHub Wiki
Welcome to the Faker.NET wiki!
Getting Started
Faker.NET was created as a port of faker.js to the .NET environment. It is available for use in C#, F#, and PowerShell. Faker.NET has a main entry point under the static Faker
class.
SetLocale
Inside of the static Faker
class you control what type of fake data will be created on the fly.
The static Faker
class uses the IFakerInstance
under the hood. This can be overridden with pre-defined locales to include:
public enum FakerLocale
{
Unknown,
English,
Arabic,
French,
Russian,
Mandarin,
German,
}
or you can create your own custom IFakerInstance
by extending the IFakerInstance
interface found under Faker.NET.Interfaces
.
To change the static Faker
instance to a supported locale - simply call Faker.SetLocale(FakerLocale.German)
(or any other available FakerLocale
).
SetSeed
On top of allowing the modularity of locales faker also allows for setting a seed on the randomizer. This allows for deterministic creation of fake data. (Extremely useful for unit testing).
using Faker.NET;
Faker.SetSeed(12345);
Non-Static Faker Instances
Using the FakerLocaleFactory
you can specify a locale and receive an instance of the given IFakerInstance
. For example:
using Faker.NET;
var enInstance = FakerLocaleFactory.Create(FakerLocale.English);
var ruInstance = FakerLocaleFactory.Create(FakerLocale.Russian);
enInstance.Person.FirstName();
ruInstance.Person.FirstName();