started fakers
This commit is contained in:
64
SchengenVisaApi/VisaApiTests/Fakers/ApplicantFaker.cs
Normal file
64
SchengenVisaApi/VisaApiTests/Fakers/ApplicantFaker.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||||
|
using Bogus;
|
||||||
|
using Domains;
|
||||||
|
using Domains.ApplicantDomain;
|
||||||
|
using Domains.Users;
|
||||||
|
|
||||||
|
namespace VisaApi.Fakers
|
||||||
|
{
|
||||||
|
public sealed class ApplicantFaker : Faker<Applicant>
|
||||||
|
{
|
||||||
|
public ApplicantFaker(User user, IDateTimeProvider dateTimeProvider)
|
||||||
|
{
|
||||||
|
RuleFor(a => a.Citizenship, f => f.Address.Country());
|
||||||
|
|
||||||
|
RuleFor(a => a.Gender, f => f.Random.Enum<Gender>());
|
||||||
|
|
||||||
|
RuleForType(typeof(Name), f
|
||||||
|
=> new Name
|
||||||
|
{
|
||||||
|
FirstName = f.Name.LastName(),
|
||||||
|
Surname = f.Name.LastName(),
|
||||||
|
Patronymic = f.Name.FirstName()
|
||||||
|
});
|
||||||
|
|
||||||
|
RuleFor(a => a.BirthDate,
|
||||||
|
f => f.Date.Past(60, dateTimeProvider.Now()));
|
||||||
|
|
||||||
|
RuleFor(a => a.Passport, f
|
||||||
|
=> new Passport
|
||||||
|
{
|
||||||
|
Issuer = f.Company.CompanyName(),
|
||||||
|
Number = f.Random.String(ConfigurationConstraints.PasswordLength),
|
||||||
|
ExpirationDate = f.Date.Future(4, dateTimeProvider.Now()),
|
||||||
|
IssueDate = f.Date.Past(4, dateTimeProvider.Now())
|
||||||
|
});
|
||||||
|
|
||||||
|
RuleFor(a => a.JobTitle, f => f.Name.JobTitle());
|
||||||
|
|
||||||
|
RuleFor(a => a.MaritalStatus, f => f.Random.Enum<MaritalStatus>());
|
||||||
|
|
||||||
|
RuleFor(a => a.UserId, () => user.Id);
|
||||||
|
|
||||||
|
RuleFor(a => a.CitizenshipByBirth, f => f.Address.Country());
|
||||||
|
|
||||||
|
RuleFor(a => a.CityOfBirth, f => f.Address.City());
|
||||||
|
|
||||||
|
RuleFor(a => a.IsNonResident, f => f.Random.Bool());
|
||||||
|
|
||||||
|
RuleFor(a => a.PlaceOfWork, f
|
||||||
|
=> new PlaceOfWork
|
||||||
|
{
|
||||||
|
Address = new Address
|
||||||
|
{
|
||||||
|
Country = f.Address.Country(),
|
||||||
|
City = f.Address.City(),
|
||||||
|
Street = f.Address.StreetName(),
|
||||||
|
Building = f.Address.BuildingNumber()
|
||||||
|
},
|
||||||
|
Name = f.Company.CompanyName(),
|
||||||
|
PhoneNum = f.Phone.PhoneNumber()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
SchengenVisaApi/VisaApiTests/Fakers/UserFaker.cs
Normal file
15
SchengenVisaApi/VisaApiTests/Fakers/UserFaker.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Bogus;
|
||||||
|
using Domains.Users;
|
||||||
|
|
||||||
|
namespace VisaApi.Fakers
|
||||||
|
{
|
||||||
|
public sealed class UserFaker : Faker<User>
|
||||||
|
{
|
||||||
|
public UserFaker()
|
||||||
|
{
|
||||||
|
RuleFor(u => u.Email, f => f.Internet.Email());
|
||||||
|
|
||||||
|
RuleFor(u => u.Password, f => f.Internet.Password());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Bogus" Version="35.6.1" />
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.1" />
|
<PackageReference Include="FluentAssertions" Version="6.12.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user