:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
Hello. I'm your host Brian Chavez (twitter). Bogus is a simple fake data generator for .NET languages like C#, F# and VB.NET. Bogus is fundamentally a C# port of faker.js
and inspired by FluentValidation's syntax sugar.
Bogus will help you load databases, UI and apps with fake data for your testing needs. If you like Bogus star :star: the repository and show your friends! :smile: If you find Bogus useful consider supporting the project by purchasing a Bogus Premium license that gives you extra Bogus superpowers! :dizzy: :muscle: You can also sponsor the project here! :moneybag: :dollar:
Nuget Package Bogus
Install-Package BogusMinimum Requirements: .NET Standard 1.3 or .NET Standard 2.0 or .NET Framework 4.0.
…| Language | Description |
|---|---|
| C# | Full working example of 'The Great C# Example' |
| C# | Using Bogus and EF Core to a seed database |
| C# | Extending Bogus with custom APIs and data |
| F# | Using Bogus with F# |
| VB.NET | Using Bogus with VB.NET |
Since we're a port of faker.js, we support a whole bunch of different locales. Here's an example in Korean:
[Test]
public void With_Korean_Locale()
{
var lorem = new Bogus.DataSets.Lorem(locale: "ko");
Console.WriteLine(lorem.Sentence(5));
}
/* 국가는 무상으로 행위로 의무를 구성하지 신체의 처벌받지 예술가의 경우와 */Bogus supports the following locales:
| Locale Code | Language | Locale Code | Language | |
|---|---|---|---|---|
af_ZA |
Afrikaans | fr_CH |
French (Switzerland) | |
ar |
Arabic | ge |
Georgian | |
az |
Azerbaijani | hr |
Hrvatski | |
cz |
Czech | id_ID |
Indonesia | |
de |
German | it |
Italian | |
de_AT |
German (Austria) | ja |
Japanese | |
de_CH |
German (Switzerland) | ko |
Korean | |
el |
Greek | lv |
Latvian | |
en |
English | nb_NO |
Norwegian | |
en_AU |
English (Australia) | ne |
Nepalese | |
en_AU_ocker |
English (Australia Ocker) | nl |
Dutch | |
en_BORK |
English (Bork) | nl_BE |
Dutch (Belgium) | |
en_CA |
English (Canada) | pl |
Polish | |
en_GB |
English (Great Britain) | pt_BR |
Portuguese (Brazil) | |
en_IE |
English (Ireland) | pt_PT |
Portuguese (Portugal) | |
en_IND |
English (India) | ro |
Romanian | |
en_NG |
Nigeria (English) | ru |
Russian | |
en_US |
English (United States) | sk |
Slovakian | |
en_ZA |
English (South Africa) | sv |
Swedish | |
es |
Spanish | tr |
Turkish | |
es_MX |
Spanish (Mexico) | uk |
Ukrainian | |
fa |
Farsi | vi |
Vietnamese | |
fi |
Finnish | zh_CN |
Chinese | |
fr |
French | zh_TW |
Chinese (Taiwan) | |
fr_CA |
French (Canada) | zu_ZA |
Zulu (South Africa) |
Note: Some locales may not have a complete data set. For example, zh_CN does not have a lorem data set, but ko has a lorem data set. Bogus will default to en if a locale-specific data set is not found. To further illustrate the previous example, the missing zh_CN:lorem data set will default to the en:lorem data set.
If you'd like to help contribute new locales or update existing ones please see our Creating Locales wiki page for more info.
You can use Bogus without a fluent setup. The examples below highlight three alternative ways to use Bogus without a fluent syntax setup.
Faker facade.Faker<T> inheritance.Faker facade:public void Using_The_Faker_Facade()
{
var faker = new Faker("en");
var o = new Order()
{
OrderId = faker.Random.Number(1, 100),
Item = faker.Lorem.Sentence(),
Quantity = faker.Random.Number(1, 10)
};
o.Dump();
}public void Using_DataSets_Directly()
{
var random = new Bogus.Randomizer();
var lorem = new Bogus.DataSets.Lorem("en");
var o = new Order()
{
OrderId = random.Number(1, 100),
Item = lorem.Sentence(),
Quantity = random.Number(1, 10)
};
o.Dump();
}Faker<T> inheritance:public class OrderFaker : Faker<Order> {
public OrderFaker() {
RuleFor(o => o.OrderId, f => f.Random.Number(1, 100));
RuleFor(o => o.Item, f => f.Lorem.Sentence());
RuleFor(o => o.Quantity, f => f.Random.Number(1, 10));
}
}
public void Using_FakerT_Inheritance()
{
var orderFaker = new OrderFaker();
var o = orderFaker.Generate();
o.Dump();
}In the examples above, all three alternative styles of using Bogus produce the same Order result:
{
"OrderId": 61,
"Item": "vel eUpdate Denmark (da) locale from faker-js
DateTimeReference is null
The AutoBogus mentioned in Amazing Community Extensions is abandoned
Passing parameters to Faker
Add Romania vehicle registration plates
Adds support for cnpj alphanumeric values
CodiceFiscale generator is not deterministic
Multithreaded Generation not working as expected
Include Copyright information in the NuGet feed
A list of subjects