FakerLib.Net
1.0.0
dotnet add package FakerLib.Net --version 1.0.0
NuGet\Install-Package FakerLib.Net -Version 1.0.0
<PackageReference Include="FakerLib.Net" Version="1.0.0" />
<PackageVersion Include="FakerLib.Net" Version="1.0.0" />
<PackageReference Include="FakerLib.Net" />
paket add FakerLib.Net --version 1.0.0
#r "nuget: FakerLib.Net, 1.0.0"
#:package FakerLib.Net@1.0.0
#addin nuget:?package=FakerLib.Net&version=1.0.0
#tool nuget:?package=FakerLib.Net&version=1.0.0
FakerLib.Net
This is the official repository of the FakerLib.Net dummy data generator library for .NET
What is FakerLib.Net?
FakerLib.Net is a simple .NET Core package that can be used to create dummy (fake) list of collections. That is, populate any type of collections (List) (Enumerables) with random data of different sorts : Name, Cities, Phonenumbers, Countries, ZipCodes, UUIDs, Addresses, IPAddresses, URLs, Websites, EmailAddresses, ImageURLs etc. It could be used to populate DB's, collections and so on during development and testing.
Where can I get it?
First, install NuGet. Then, install FakerLib.Net from the package manager console:
PM> Install-Package FakerLib.Net
Or from the .NET CLI as:
dotnet add package FakerLib.Net
How do I get started?
First, configure FakerLib.Net FakerFactory to let it know what properties of a type (e.g class) do want to generate fake/dummy for by annotating each property of choice by a FakeAttribute like below: For instance, for a model class of Person, you would configure like below:
public class Person
{
[Fake(FakerType.Name)]
public string Name { get; set; }
[Fake(FakerType.City)]
public string City { get; set; }
[Fake(FakerType.Phone)]
public string Phone { get; set; }
public string HouseAddress { get; set; } = string.Empty;
}
All FakerTypes that you can use
public enum FakerType
{
Name = 0,
Sentence = 1,
ImageUrl = 2,
Phone = 3,
City = 4,
Country = 5,
TextParagraph = 6,
Website = 7,
IpAddress = 8,
Guid = 9,
GuidString = 10,
DateTime = 11,
Numeric = 12,
Address = 13,
EmailAddress = 14,
ZipCode = 15,
Url = 16
}
Then anywhere in your application code where you need a list of type(Person) filled with dummy data, use below.
var fakerFactory = new FakerFactory();
var dummyListOfPersons = fakerFactory.Setup<Person>(typeof(Person), 5) //meaning to generate 5 items of this type(Person) of dummy data.
OR you can use Dependency Injection by registering FakerFactory in your startup.cs DI container like below
//For .NET 6 and above
builder.Services.AddFakerFactory();
//For .NET 5 and below
services.AddFakerFactory();
//then you can inject typeof(IFakerFactory) into any class's constructor and make use of it.
private readonly IFakerFactory _fakerFactory;
public PersonService(IFakerFactory fakerFactory)
{
_fakerFactory = fakerFactory;
}
//Then make use of it somewhere inside this service class like below.
var dummyListOfPersons = _fakerFactory.Setup<Person>(typeof(Person), 5) //meaning to generate 5 items of this type(Person) of dummy data.
Do you have an issue?
If you're facing some problems using the package, file an issue above.
License, etc.
FakerLib.Net is Copyright © 2022 Faith Olusegun and other contributors under the MIT license.
And this project was first inspired in 2019 by the Faker Library in PHP Laravel. Not until now was it made real for C# .NET.
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.AspNetCore.Identity.EntityFrameworkCore (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.1)
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 |
|---|---|---|
| 1.0.0 | 977 | 10/27/2022 |