Bogus 20.0.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Bogus --version 20.0.1
NuGet\Install-Package Bogus -Version 20.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bogus" Version="20.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bogus --version 20.0.1
#r "nuget: Bogus, 20.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Bogus as a Cake Addin
#addin nuget:?package=Bogus&version=20.0.1

// Install Bogus as a Cake Tool
#tool nuget:?package=Bogus&version=20.0.1

The Great C# Example

public enum Gender
{
    Male,
    Female
}

//Set the randomzier seed if you wish to generate repeatable data sets.
Randomizer.Seed = new Random(8675309);

var fruit = new[] { "apple", "banana", "orange", "strawberry", "kiwi" };

var orderIds = 0;
var testOrders = new Faker<Order>()
    //Ensure all properties have rules. By default, StrictMode is false
    //Set a global policy by using Faker.DefaultStrictMode
    .StrictMode(true)
    //OrderId is deterministic
    .RuleFor(o => o.OrderId, f => orderIds++)
    //Pick some fruit from a basket
    .RuleFor(o => o.Item, f => f.PickRandom(fruit))
    //A random quantity from 1 to 10
    .RuleFor(o => o.Quantity, f => f.Random.Number(1, 10));


var userIds = 0;
var testUsers = new Faker<User>()
    //Optional: Call for objects that have complex initialization
    .CustomInstantiator(f => new User(userIds++, f.Random.Replace("###-##-####")))

    //Basic rules using built-in generators
    .RuleFor(u => u.FirstName, f => f.Name.FirstName())
    .RuleFor(u => u.LastName, f => f.Name.LastName())
    .RuleFor(u => u.Avatar, f => f.Internet.Avatar())
    .RuleFor(u => u.UserName, (f, u) => f.Internet.UserName(u.FirstName, u.LastName))
    .RuleFor(u => u.Email, (f, u) => f.Internet.Email(u.FirstName, u.LastName))
    .RuleFor(u => u.SomethingUnique, f => $"Value {f.UniqueIndex}")
    .RuleFor(u => u.SomeGuid, Guid.NewGuid)

    //Use an enum outside scope.
    .RuleFor(u => u.Gender, f => f.PickRandom<Gender>())
    //Use a method outside scope.
    .RuleFor(u => u.CartId, f => Guid.NewGuid())
    //Compound property with context, use the first/last name properties
    .RuleFor(u => u.FullName, (f, u) => u.FirstName + " " + u.LastName)
    //And composability of a complex collection.
    .RuleFor(u => u.Orders, f => testOrders.Generate(3).ToList())
    //Optional: After all rules are applied finish with the following action
    .FinishWith((f, u) =>
        {
            Console.WriteLine("User Created! Id={0}", u.Id);
        });

var user = testUsers.Generate();
Console.WriteLine(user.DumpAsJson());

/* OUTPUT:
User Created! Id=0
 *
{
  "Id": 0,
  "FirstName": "Audrey",
  "LastName": "Spencer",
  "FullName": "Audrey Spencer",
  "UserName": "Audrey_Spencer72",
  "Email": "Audrey82@gmail.com",
  "Avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/itstotallyamy/128.jpg",
  "CartId": "863f9462-5b88-471f-b833-991d68db8c93",
  "SSN": "923-88-4231",
  "Gender": 0,
  "Orders": [
    {
      "OrderId": 0,
      "Item": "orange",
      "Quantity": 8
    },
    {
      "OrderId": 1,
      "Item": "banana",
      "Quantity": 2
    },
    {
      "OrderId": 2,
      "Item": "kiwi",
      "Quantity": 9
    }
  ]
} */
Click here for F# and VB.NET examples!
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (136)

Showing the top 5 NuGet packages that depend on Bogus:

Package Downloads
AutoBogus

A C# library complementing the Bogus generator by adding auto creation and population capabilities.

FunFair.Test.Common

FunFair Common Test Infrastructure for building xUnit tests on top of.

Reo.Core.Testing

Package Description

HQ

This package contains the full-stack build for HQ.io.

Indice.AspNetCore.Identity

Package Description

GitHub repositories (107)

Showing the top 5 popular GitHub repositories that depend on Bogus:

Repository Stars
FluentValidation/FluentValidation
A popular .NET validation library for building strongly-typed validation rules.
bchavez/Bogus
:card_index: A simple fake data generator for C#, F#, and VB.NET. Based on and ported from the famed faker.js.
elsa-workflows/elsa-core
A .NET workflows library
graphql-dotnet/graphql-dotnet
GraphQL for .NET
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
Version Downloads Last updated
35.5.0 481,037 3/9/2024
35.4.1 146,006 3/2/2024
35.4.0 1,226,426 1/14/2024
35.3.2 6,576 1/14/2024
35.3.1 10,542 1/13/2024
35.3.0 338,527 1/1/2024
35.2.0 72,762 12/26/2023
35.0.1 281,414 12/12/2023
34.0.2 23,292,051 3/27/2022
34.0.1 4,062,916 11/23/2021
33.1.1 2,726,198 8/29/2021
33.0.2 6,795,373 2/21/2021
33.0.1 365,654 2/7/2021
32.1.1 202,119 1/31/2021
32.0.2 2,026,427 12/12/2020
32.0.1 676,667 11/28/2020
31.0.3 8,200,685 10/4/2020
30.0.4 745,146 8/15/2020
30.0.1-beta-4 11,197 7/24/2020
30.0.1-beta-3 15,567 6/30/2020
30.0.1-beta-2 5,241 6/21/2020
30.0.1-beta-1 7,577 6/15/2020
29.0.2 4,570,421 4/11/2020
29.0.1 1,519,789 2/10/2020
28.4.4 2,189,077 12/10/2019
28.4.3 268,075 12/4/2019
28.4.2 23,065 11/30/2019
28.4.1 1,103,235 10/15/2019
28.3.2 223,141 10/4/2019
28.3.1 166,827 9/21/2019
28.2.1 533,906 9/10/2019
28.1.1 7,060 9/10/2019
28.0.3 207,370 8/28/2019
28.0.2 1,144,392 7/7/2019
28.0.1 57,769 7/2/2019
27.0.1 1,158,199 5/2/2019
26.0.2 425,467 3/22/2019
26.0.1 642,473 2/26/2019
25.0.4 505,812 1/18/2019
25.0.3 121,528 1/6/2019
25.0.2 226,301 12/11/2018
25.0.1 117,356 11/27/2018
24.3.1 189,486 11/3/2018
24.3.0 498,540 10/2/2018
24.2.0 55,161 9/27/2018
23.0.2 177,525 8/13/2018
22.3.2 162,447 7/18/2018
22.3.1 109,774 7/5/2018
22.2.1 27,556 6/29/2018
22.1.4 30,610 6/26/2018
22.1.3 60,359 6/14/2018
22.1.2 302,819 5/29/2018
22.1.1 30,085 5/21/2018
22.0.9 6,309 5/17/2018
22.0.8 401,778 4/10/2018
22.0.7 55,134 4/1/2018
22.0.6 8,508 3/29/2018
22.0.5 143,726 3/3/2018
22.0.3 18,807 2/27/2018
22.0.2 167,932 1/6/2018
22.0.1 54,984 12/23/2017
21.0.5 12,244 12/16/2017
21.0.4 29,828 12/13/2017
21.0.2 19,131 12/8/2017
20.0.2 122,264 11/6/2017
20.0.1 8,033 11/5/2017
19.0.2 43,391 11/1/2017
18.0.2 133,574 9/14/2017
18.0.1 15,612 9/13/2017
17.0.1 79,256 8/25/2017
16.0.3 14,312 8/24/2017
16.0.2 6,654 8/23/2017
15.0.7 8,482 8/21/2017
15.0.6 27,151 8/3/2017
15.0.5 8,331 7/28/2017
15.0.3 239,318 5/7/2017
15.0.1 35,870 4/11/2017
12.0.1 14,723 3/27/2017
11.0.5 13,412 3/20/2017
11.0.4 31,501 3/15/2017
11.0.3 9,320 3/13/2017
11.0.2 51,826 2/23/2017
11.0.1 4,805 2/21/2017
10.0.1 4,836 2/18/2017
9.0.2 25,151 1/19/2017
9.0.1 4,300 1/18/2017
8.0.4 4,549 1/17/2017
8.0.3 39,316 12/20/2016
8.0.2 12,205 12/7/2016
8.0.1 14,933 11/25/2016
8.0.1-beta-1 22,492 10/22/2016
7.1.7 78,669 10/11/2016
7.1.6 43,538 8/8/2016
7.1.5 8,548 7/27/2016
7.1.4 7,646 7/7/2016
7.1.3 26,311 6/28/2016
7.1.3-beta-1 3,811 5/20/2016
7.1.2 43,233 5/16/2016
7.1.2-beta-1 3,848 5/16/2016
7.1.1 4,208 5/15/2016
7.1.1-beta-1 3,697 5/15/2016
6.1.1 9,747 3/30/2016
6.1.1-beta-1 3,961 3/29/2016
5.1.1-beta-3 3,855 3/23/2016
5.1.1-beta-2 4,233 3/22/2016
5.1.1-beta-1 3,936 3/21/2016
5.0.1 12,971 2/25/2016
5.0.1-beta-2 4,038 2/25/2016
4.0.1 4,487 2/16/2016
4.0.1-beta-1 3,765 2/16/2016
3.0.6 6,239 1/21/2016
3.0.6-beta-1 3,742 1/21/2016
3.0.5 8,502 1/21/2016
3.0.5-beta-4 3,698 1/20/2016
3.0.5-beta-3 3,775 1/18/2016
3.0.5-beta-2 4,933 1/12/2016
3.0.4 5,022 12/10/2015
3.0.3 4,102 12/9/2015
3.0.2 4,305 11/24/2015
3.0.1 4,673 10/22/2015
3.0.0.3 4,994 7/21/2015
3.0.0.2 5,982 7/12/2015
3.0.0.1 24,862 7/12/2015
2.1.5.2 4,618 6/22/2015
2.1.5.1 4,168 6/11/2015
2.1.4.2 4,217 6/11/2015
2.1.4.1 4,219 6/10/2015
2.1.4 26,969 6/9/2015

## v20.0.1
* Added `Faker<T>.Clone()`: Clones internal state of a `Faker<T>` and allows for complex faking scenarios and rule combinations.
* Added `Faker<T>.UseSeed(n)`: Allows you to specify a localized seed value on a `Faker<T>` instead of a global static `Randomizer.Seed`.
* Stronger `Seed` determinism for multi-threaded scenarios.

## v19.0.2
* Fixed #99: Possible threading issue that can cause `System.ArgumentException`.

## v19.0.1
* Using new BSON binary data format for locales.
* Removed dependency on Newtonsoft.Json!
* Locale Updates -
* `fr`: new street address prefixes.
* `fa`: new street addresses.
* `pl`: removed 2008 value from city.
* `en`: new gender first names
* New Dutch (Belgium) `nl_BE` locale.
* New Romanian `ro` locale.
* Added `f.Finance.RoutingNumber` - Generates an ABA routing number with valid check digit.
* Added `Faker.GenerateForever` that returns `IEnumerable<T>` with unlimited generated items when iterated over.
* Added United Kingdom extension method to generate bank ShortCodes on `f.Finance.ShortCode()`.
* Re-ordered adjective and buzz in the `f.Company.Bs` for a correct gramatics.
* Added `f.Address.Direction`. Generates cardinal or ordinal directions.
* Added `f.Address.CardinalDirection`. Generates "North", "South", etc.
* Added `f.Address.OrdinalDirection`. Generates "Northeast", "Southwest", etc.

## v18.0.2
* Issue 86: Removed diacritic mark/accents (á, í, ó, ú, etc) from generated email addresses and user names.
* Added `string.RemoveDiacritics` helper method.

## v18.0.1
* Fixed bug in Finland's `f.Person.Henkilötunnus` personal identity code generator that sometimes produced 11 characters.
* Added `f.Finance.Ethereum`. Generate an Ethereum address.
* Added `f.Finance.CreditCardCvv`. Generate a random credit card CVV number.
* Improved `f.Finance.CreditCardNumber`. Generate a random credit card number.
* Added `f.Random.Hexadecimal`. Generates a random hexadecimal string.
* Added `f.System.DirectoryPath`. Generates a random directory path.
* Added `f.System.FilePath`. Generates a random file path.
* Added `f.Date.Soon`. Generates a date and time that will happen soon.
* Added `f.Random.ArrayElements`. Gets a random subset of an array.
* Added `f.Random.ListItems`. Gets a random subset of a list.
* Added `f.Company.Cnpj` extension method for Brazil. Generates Brazilian company document.
* Improved `f.PhoneNumbers`. More realistic US phone numbers.
* Improved `f.Address.Latitude/Longitude` with min and max parameters.
* Minimum for `f.Commerce.Price` is now $1.00 (not zero).
* Reduced assembly size by removing redundant locale data.
* Locale updates:
* `en_AU` - Update Australian postcode ranges.
* `en_IND` - Indian postcodes are always numeric.
* `ru` - Word corrections.


Full History Here: https://github.com/bchavez/Bogus/blob/master/HISTORY.md