tests and fixes

This commit is contained in:
2025-05-11 18:28:33 +03:00
parent 6ab5b9f1df
commit 07f5663c75
8 changed files with 120 additions and 13 deletions

View File

@@ -31,7 +31,7 @@ public sealed class ApplicantFaker : Faker<Applicant>
=> new Passport
{
Issuer = f.Company.CompanyName(),
Number = f.Random.String(ConfigurationConstraints.PasswordLength, 'a', 'z'),
Number = f.Random.String(ConfigurationConstraints.PassportNumberLength, 'a', 'z'),
ExpirationDate = f.Date.Future(4, dateTimeProvider.Now()),
IssueDate = f.Date.Past(4, dateTimeProvider.Now())
});
@@ -62,4 +62,4 @@ public sealed class ApplicantFaker : Faker<Applicant>
PhoneNum = f.Phone.PhoneNumber()
});
}
}
}

View File

@@ -1,4 +1,3 @@
using ApplicationLayer.InfrastructureServicesInterfaces;
using ApplicationLayer.Services.Applicants.Models;
using Bogus;
using Domains;
@@ -7,7 +6,7 @@ namespace VisaApi.Fakers.Applicants.Requests;
public sealed class PassportModelFaker : Faker<PassportModel>
{
public PassportModelFaker(IDateTimeProvider dateTimeProvider)
public PassportModelFaker()
{
RuleFor(m => m.Issuer, f => f.Company.CompanyName());
@@ -15,9 +14,9 @@ public sealed class PassportModelFaker : Faker<PassportModel>
f => f.Random.String(ConfigurationConstraints.PassportNumberLength, 'a', 'z'));
RuleFor(m => m.ExpirationDate,
f => f.Date.Future(4, dateTimeProvider.Now()));
f => f.Date.Future(4));
RuleFor(m => m.IssueDate,
f => f.Date.Past(4, dateTimeProvider.Now()));
f => f.Date.Past(4));
}
}
}

View File

@@ -0,0 +1,35 @@
using ApplicationLayer.InfrastructureServicesInterfaces;
using ApplicationLayer.Services.AuthServices.Requests;
using Bogus;
using Domains.ApplicantDomain;
using VisaApi.Fakers.Applicants.Requests;
namespace VisaApi.Fakers.Auth
{
public sealed class RegisterApplicantRequestFaker : Faker<RegisterApplicantRequest>
{
private readonly NameModelFaker nameModelFaker = new();
private readonly PassportModelFaker passportModelFaker = new();
private readonly PlaceOfWorkModelFaker placeOfWorkModelFaker = new();
private readonly RegisterRequestFaker registerRequestFaker = new();
public RegisterApplicantRequestFaker(IDateTimeProvider dateTimeProvider)
{
RuleFor(x => x.ApplicantName, () => nameModelFaker.Generate());
RuleFor(x => x.BirthDate, faker => dateTimeProvider.Now().AddYears(-faker.Random.Int(20, 100)));
RuleFor(x => x.Citizenship, faker => faker.Address.Country());
RuleFor(x => x.CitizenshipByBirth, faker => faker.Address.Country());
RuleFor(x => x.CityOfBirth, faker => faker.Address.City());
RuleFor(x => x.CountryOfBirth, faker => faker.Address.Country());
RuleFor(x => x.FatherName, () => nameModelFaker.Generate());
RuleFor(x => x.Gender, faker => faker.PickRandom<Gender>());
RuleFor(x => x.IsNonResident, faker => faker.Random.Bool());
RuleFor(x => x.JobTitle, faker => faker.Lorem.Word());
RuleFor(x => x.MaritalStatus, faker => faker.PickRandom<MaritalStatus>());
RuleFor(x => x.MotherName, () => nameModelFaker.Generate());
RuleFor(x => x.Passport, () => passportModelFaker.Generate());
RuleFor(x => x.PlaceOfWork, () => placeOfWorkModelFaker.Generate());
RuleFor(x => x.RegisterRequest, () => registerRequestFaker.Generate());
}
}
}

View File

@@ -10,5 +10,5 @@ public sealed class RegisterRequestFaker : Faker<RegisterRequest>
public RegisterRequestFaker()
{
RuleFor(r => r.AuthData, () => authDataFaker.Generate());
}
}
}
}