2025-04-22 09:53:20 +02:00

29 lines
1.3 KiB
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));
private static readonly Faker<User> UserFaker = CreateUserFaker();
public static User User => UserFaker.Generate();
public static List<User> Users => UserFaker.Generate(Random.Shared.Next(1, 10));
public static Faker<UserCreateDto> CreateUserCreateDtoFaker(string? firstName = null, string? email = null, int? age = null) => new Faker<UserCreateDto>()
.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));
private static readonly Faker<UserCreateDto> UserCreateDtoFaker = CreateUserCreateDtoFaker();
public static UserCreateDto UserCreateDto => UserCreateDtoFaker.Generate();
public static List<UserCreateDto> UserCreateDtos => UserCreateDtoFaker.Generate(Random.Shared.Next(1, 10));
}