Updated the `Fake` class to introduce flexible methods for generating fake `User` and `UserDto` objects with optional parameters. Removed the static `UserFaker` instance and related properties. Added a new `DbSet<User>` property to `MockDbContext` for improved management of `User` entities.
17 lines
764 B
C#
17 lines
764 B
C#
using Bogus;
|
|
|
|
namespace DigitalData.Core.Tests.Mock;
|
|
|
|
public static class Fake
|
|
{
|
|
public static Faker<User> CreateUserFaker(string? firstName = null, string? email = null, int? age = null) => new Faker<User>()
|
|
.RuleFor(u => u.FirstName, f => firstName ?? f.Name.FirstName())
|
|
.RuleFor(u => u.Email, f => email ?? f.Internet.Email())
|
|
.RuleFor(u => u.Age, f => age ?? f.Random.Int(18, 99));
|
|
|
|
public static Faker<UserDto> CreateUserDtoFaker(string? firstName = null, string? email = null, int? age = null) => new Faker<UserDto>()
|
|
.RuleFor(u => u.FirstName, f => firstName ?? f.Name.FirstName())
|
|
.RuleFor(u => u.Email, f => email ?? f.Internet.Email())
|
|
.RuleFor(u => u.Age, f => age ?? f.Random.Int(18, 99));
|
|
}
|