FluentBogus 1.0.0
dotnet add package FluentBogus --version 1.0.0
NuGet\Install-Package FluentBogus -Version 1.0.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="FluentBogus" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FluentBogus --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FluentBogus, 1.0.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 FluentBogus as a Cake Addin #addin nuget:?package=FluentBogus&version=1.0.0 // Install FluentBogus as a Cake Tool #tool nuget:?package=FluentBogus&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
fluent-bogus
Bogus based fake object generator using fluent syntax
Usage example:
Generate a fake object:
var user = new FluentFaker<User>().Build();
Generate multiple objects:
var users = new FluentFaker<User>().BuildMany(3);
Include navigation properties:
var users = new FluentFaker<User>()
.Include(u => u.Company.BillingAddress)
.Include(u => u.Company.Departments)
.BuildMany(3);
To extend with custom faker rules, just create a new class derived from FluentFaker<> and specify the assembly where it's defined:
public class UserFaker : FluentFaker<User>
{
public UserFaker()
{
Faker.RuleFor(u => u.FirstName, f => f.Person.FirstName);
Faker.RuleFor(u => u.LastName, f => f.Person.LastName);
Faker.RuleFor(u => u.Email, f => f.Person.Email);
Faker.RuleFor(u => u.Location, f => f.Person.Address.Street);
}
public UserFaker WithPassword(string password)
{
Faker.RuleFor(u => u.Password, password);
return this;
}
}
public void Setup()
{
FluentFaker.Setup(new FluentFakerOptions
{
FakeBuilderAssemblies = new List<Assembly>
{
Assembly.GetExecutingAssembly(),
typeof(IFakerAssemblyMarker).GetTypeInfo().Assembly
}
});
}
public void CreateFakes()
{
var users = new UserFaker()
.WithPassword("Pa$$wOrd!")
.Include(u => u.Company.BillingAddress)
.Include(u => u.Company.Departments)
.BuildMany(3);
}
Used classes in Usage examples:
User:
public class User
{
public int Id { get; set; }
public int CompanyId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Location { get; set; }
public DateTime BirthDate { get; set; }
public bool IsActive { get; set; }
public Company Company { get; set; }
}
Company:
public class Company
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public CompanyAddress LegalAddress { get; set; }
public CompanyAddress BillingAddress { get; set; }
public List<Department> Departments { get; set; }
}
CompanyAddress
public class CompanyAddress
{
public int Id { get; set; }
public string Country { get; set; }
public string City { get; set; }
public string StreetAddress { get; set; }
public string ZipCode { get; set; }
}
Department
public class Department
{
public string Name { get; set; }
public string Code { get; set; }
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net5.0
- Bogus (>= 33.1.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 | 1,594 | 10/4/2021 |