RimuTec.Faker 2.1.0

dotnet add package RimuTec.Faker --version 2.1.0
NuGet\Install-Package RimuTec.Faker -Version 2.1.0
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="RimuTec.Faker" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RimuTec.Faker --version 2.1.0
#r "nuget: RimuTec.Faker, 2.1.0"
#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 RimuTec.Faker as a Cake Addin
#addin nuget:?package=RimuTec.Faker&version=2.1.0

// Install RimuTec.Faker as a Cake Tool
#tool nuget:?package=RimuTec.Faker&version=2.1.0

Faker

RimuTec.Faker provides generators for fake, yet realistically looking data. Use it for testing, for creating screenshots to show off your cool software, and similar more. Generators include Lorem, Name, Address, Date, Company, Business, and similar more.

RimuTec.Faker is a C# port of the Ruby Faker gem https://github.com/faker-ruby/faker. It also has some generators and methods that are not in the original Ruby Faker, e.g. Weather.

RimuTec.Faker supports the following targets:

  • .NET Standard 2.0 (netstandard2.0)
  • .NET Standard 2.1 (netstandard2.1)
  • .NET Framework 4.6.2 (net462)
  • .NET 6.0 (net6.0)
  • .NET 7.0 (net7.0) (from version 1.12.0 onwards)

In case you need support for other targets, please file an issue at https://github.com/RimuTec/Faker/issues and we'll check if we can support the target you need as well. Thank you!

The library including its source code are licensed under the MIT license. It supports 51 locales out of the box. And you can extend it with your own custom locales using yaml files.

Metric Status
Nuget NuGet Badge

Usage

Quick Start

  1. Install NuGet package. See https://www.nuget.org/packages/RimuTec.Faker for instructions
  2. Add using RimuTec.Faker; at the beginning of your C# source file (or the equivalent for your preferred .NET language), e.g.
    using RimuTec.Faker; // at the beginning of your file
    
  3. Generate fake data in your tests, e.g.
    var firstName = Name.NameWithMiddle(); // in your test
    
    or
    var paragraphs = Lorem.Paragraphs(4); // in your test
    

In case of name clashes with other classes in your code base, use one of these techniques.

Documentation

We also have more detailed documentation for RimuTec.Faker.

Release Notes

Release notes are available at https://github.com/RimuTec/Faker/blob/master/releasenotes.md

Support & Suggestions

If you need support or have a suggestion for improvement please file an issue at https://github.com/RimuTec/Faker/issues. Thank you!

Semantic Versioning

We use semantic versioning (SemVer) for RimuTec.Faker. This means we endeavor to follow these rules:

Given a version number MAJOR.MINOR.PATH we increment:

  1. MAJOR version if we make incompatible API changes, i.e. breaking changes
  2. MINOR version if we make compatible API changes, i.e. we add functionality in a backwards compatible manner
  3. PATCH version if we make backwards compatible bug fixes but don't add new functionality

Reporting Bugs

RimuTec.Faker has a test suite with over 13,000 unit tests covering all built-in locales. This does not guarantee absence of bugs.

If you find a bug please consider making a contribution to the open-source community by reporting the bug at https://github.com/RimuTec/Faker/issues. Ideally, please include steps to reproduce the issue. We also consider pull requests (PR). All your feedback will help make the library more valuable for other users as well. Thank you!

Available Fake Data Generators

The classes listed below are already ported. Our aim is to add the remaining classes and method over time. If you have preferences please file suggestions as issues on Github (see below). Thank you!

Class to set the locale to be used:

Locales and Customization

The following 50 locales are supported out of the box (no extra files needed):

bg, ca, ca-CAT, da-DK, de, de-AT, de-CH, ee, en, en-AU, en-au-ocker, en-BORK, en-CA, en-GB, en-IND, en-MS, en-NEP, en-NG, en-NZ, en-PAK, en-SG, en-UG, en-US, en-ZA, es, es-MX, fa, fi-FI, fr, fr-CA, fr-CH, he, id, it, ja, ko, lv, nb-NO, nl, pl, pt, pt-BR, ru, sk, sv, tr, uk, vi, zh-CN, zh-TW

To set the locale in C# use something like Config.Locale = "de";.

In addition you can use custom locale files for methods that are marked with an asterisk. Ensure that the custom locale file (yml) is copied to the directory that also contains RimuTec.Faker.dll, usually the output directory of your test project.

Note: With release 1.8 we removed support for locale 'no' as the language file has an incorrect format. Once this issue has been corrected at Ruby Faker gem we'll add it back in if all tests pass.

How To Build

Prerequisites

  • Docker Desktop (Windows and MacOS)
  • Docker Engine (Linux)
  • VS Code
  • Git client
  • VS Code extension "Remove Development", version 0.20.0 or later

We are using a dev container to ensure better consistency across environments but also to avoid having to install development tools on the host. You may be able to build without a container but we don't officially support that setup.

Visual Studio Code

  1. Clone the repository into a linux file system.

    • Important note for Windows user: Use a WSL or WSL2 distro. Also, do not clone into a path starting with /mnt as this is likely to cause issues with VS Code and some extensions. The background is that file change messages are not reliably propagated as of writing when mounting a non-Linux file system into a dev container which is Linux based. For more details about this see article "Docker Desktop on WSL2: The Problem with Mixing File Systems".
  2. Navigate to the directory containing your local clone.

    • Windows only: Use a WSL or WSL2 terminal to navigate to it. Do not use \\wsl$ via File Explorer.
  3. Open the folder in VS Code using the command code . in the shell. When prompted re-open in the dev container

  4. To build, open a terminal inside VS Code, ensure you are in /app and execute dotnet build or dotnet test.

Issues With Building

If you encounter issues with building the library please file an issue on GitHub, ideally with what you tried, what the expected and what the actual outcome was. Thank you!

Credits

This project uses yaml source files from the Ruby Faker gem, licensed under the MIT license. Thank you to all their contributors!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 is compatible.  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 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.0 565 11/8/2023
2.0.0 1,053 9/24/2023
1.12.0 371 9/24/2023
1.11.0 12,971 12/30/2021
1.10.0 1,054 1/7/2021
1.9.0 981 12/19/2020
1.8.0 812 12/18/2020
1.7.0 742 12/13/2020
1.6.0 844 12/5/2020
1.5.0 943 5/17/2020
1.4.0 953 4/5/2020
1.3.0 853 3/28/2020
1.2.0 898 3/22/2020
1.1.0 879 3/22/2020
1.0.0 828 2/6/2020
0.44.0 871 2/6/2020
0.43.0 948 1/19/2020
0.42.0 892 1/19/2020
0.41.0 853 1/19/2020
0.40.0 1,878 8/5/2018
0.39.0 1,180 7/29/2018
0.38.0 1,166 7/27/2018
0.37.0 1,116 7/26/2018
0.36.0 1,176 7/25/2018
0.35.0 1,141 7/24/2018
0.34.0 1,114 7/23/2018
0.33.0 1,154 7/22/2018
0.32.0 1,169 7/17/2018
0.31.0 1,288 7/17/2018
0.30.0 1,276 7/15/2018
0.29.0 1,245 7/14/2018
0.28.0 1,272 7/13/2018
0.27.0 1,247 7/12/2018
0.26.0 1,296 7/11/2018
0.25.0 1,247 7/10/2018
0.24.0 1,246 7/9/2018
0.23.0 1,294 7/8/2018
0.22.0 1,130 7/7/2018
0.21.0 1,205 7/6/2018
0.20.0 1,194 7/5/2018
0.19.0 1,212 7/4/2018
0.18.0 1,219 7/4/2018
0.17.0 1,262 7/2/2018
0.16.0 1,279 7/1/2018
0.15.0 1,302 6/30/2018
0.14.0 1,255 6/29/2018
0.13.0 1,213 6/28/2018
0.12.0 1,273 6/27/2018
0.11.0 1,230 6/26/2018
0.10.0 1,224 6/25/2018
0.9.0 1,256 6/24/2018
0.8.0 1,279 6/23/2018
0.7.0 1,278 6/22/2018
0.6.0 1,379 6/21/2018
0.5.0 1,286 6/20/2018
0.4.0 1,205 6/20/2018
0.3.0 1,227 6/19/2018
0.2.0 1,288 6/19/2018
0.1.0 1,235 6/18/2018

Relase notes listing new features and other changes are available at https://github.com/RimuTec/Faker/blob/master/releasenotes.md