Вытащил солюшен на уровень выше, чтобы прощё было дотнетить
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
65
VisaApiTests/Fakers/Applicants/ApplicantFaker.cs
Normal file
65
VisaApiTests/Fakers/Applicants/ApplicantFaker.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using Bogus;
|
||||
using Domains;
|
||||
using Domains.ApplicantDomain;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants;
|
||||
|
||||
/// <summary>
|
||||
/// Generates applicants
|
||||
/// </summary>
|
||||
public sealed class ApplicantFaker : Faker<Applicant>
|
||||
{
|
||||
public ApplicantFaker(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.PassportNumberLength, 'a', 'z'),
|
||||
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.CitizenshipByBirth, f => f.Address.Country());
|
||||
|
||||
RuleFor(a => a.CityOfBirth, f => f.Address.City());
|
||||
|
||||
RuleFor(a => a.CountryOfBirth, f => f.Address.Country());
|
||||
|
||||
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()
|
||||
});
|
||||
}
|
||||
}
|
||||
16
VisaApiTests/Fakers/Applicants/Requests/NameModelFaker.cs
Normal file
16
VisaApiTests/Fakers/Applicants/Requests/NameModelFaker.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using ApplicationLayer.Services.Applicants.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants.Requests;
|
||||
|
||||
public sealed class NameModelFaker : Faker<NameModel>
|
||||
{
|
||||
public NameModelFaker()
|
||||
{
|
||||
RuleFor(m => m.FirstName, f => f.Name.FirstName());
|
||||
|
||||
RuleFor(m => m.Surname, f => f.Name.LastName());
|
||||
|
||||
RuleFor(m => m.Patronymic, f => f.Name.FirstName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using ApplicationLayer.Services.Applicants.Models;
|
||||
using Bogus;
|
||||
using Domains;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants.Requests;
|
||||
|
||||
public sealed class PassportModelFaker : Faker<PassportModel>
|
||||
{
|
||||
public PassportModelFaker()
|
||||
{
|
||||
RuleFor(m => m.Issuer, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(m => m.Number,
|
||||
f => f.Random.String(ConfigurationConstraints.PassportNumberLength, 'a', 'z'));
|
||||
|
||||
RuleFor(m => m.ExpirationDate,
|
||||
f => f.Date.Future(4));
|
||||
|
||||
RuleFor(m => m.IssueDate,
|
||||
f => f.Date.Past(4));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using ApplicationLayer.Services.Applicants.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants.Requests;
|
||||
|
||||
public sealed class PlaceOfWorkModelFaker : Faker<PlaceOfWorkModel>
|
||||
{
|
||||
public PlaceOfWorkModelFaker()
|
||||
{
|
||||
RuleFor(m => m.Name, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(m => m.PhoneNum, f => f.Phone.PhoneNumber("###########"));
|
||||
|
||||
RuleFor(m => m.Address,
|
||||
f => new AddressModel
|
||||
{
|
||||
Country = f.Address.Country(),
|
||||
City = f.Address.City(),
|
||||
Street = f.Address.StreetName(),
|
||||
Building = f.Address.BuildingNumber()
|
||||
});
|
||||
}
|
||||
}
|
||||
14
VisaApiTests/Fakers/Auth/AuthDataFaker.cs
Normal file
14
VisaApiTests/Fakers/Auth/AuthDataFaker.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using ApplicationLayer.Services.AuthServices.Common;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Auth;
|
||||
|
||||
public sealed class AuthDataFaker : Faker<AuthData>
|
||||
{
|
||||
public AuthDataFaker()
|
||||
{
|
||||
RuleFor(a => a.Email, f => f.Internet.Email());
|
||||
|
||||
RuleFor(a => a.Password, f => f.Internet.Password());
|
||||
}
|
||||
}
|
||||
35
VisaApiTests/Fakers/Auth/RegisterApplicantRequestFaker.cs
Normal file
35
VisaApiTests/Fakers/Auth/RegisterApplicantRequestFaker.cs
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
14
VisaApiTests/Fakers/Auth/RegisterRequestFaker.cs
Normal file
14
VisaApiTests/Fakers/Auth/RegisterRequestFaker.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using ApplicationLayer.Services.AuthServices.Requests;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Auth;
|
||||
|
||||
public sealed class RegisterRequestFaker : Faker<RegisterRequest>
|
||||
{
|
||||
private static AuthDataFaker authDataFaker = new();
|
||||
|
||||
public RegisterRequestFaker()
|
||||
{
|
||||
RuleFor(r => r.AuthData, () => authDataFaker.Generate());
|
||||
}
|
||||
}
|
||||
14
VisaApiTests/Fakers/Common/ChangeAuthDataFaker.cs
Normal file
14
VisaApiTests/Fakers/Common/ChangeAuthDataFaker.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using ApplicationLayer.Services.Users.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Common;
|
||||
|
||||
public sealed class ChangeAuthDataFaker : Faker<ChangeAuthData>
|
||||
{
|
||||
public ChangeAuthDataFaker()
|
||||
{
|
||||
RuleFor(a => a.Email, f => f.Internet.Email());
|
||||
|
||||
RuleFor(a => a.Password, f => f.Internet.Password());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using ApplicationLayer.Services.Users.Requests;
|
||||
using Bogus;
|
||||
using VisaApi.Fakers.Common;
|
||||
|
||||
namespace VisaApi.Fakers.Users.Requests;
|
||||
|
||||
public sealed class ChangeUserAuthDataRequestFaker : Faker<ChangeUserAuthDataRequest>
|
||||
{
|
||||
private static ChangeAuthDataFaker changeAuthDataFaker = new();
|
||||
|
||||
public ChangeUserAuthDataRequestFaker()
|
||||
{
|
||||
CustomInstantiator(_ => new(Guid.NewGuid(), changeAuthDataFaker.Generate()));
|
||||
}
|
||||
}
|
||||
17
VisaApiTests/Fakers/Users/UserFaker.cs
Normal file
17
VisaApiTests/Fakers/Users/UserFaker.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Bogus;
|
||||
using Domains.Users;
|
||||
|
||||
namespace VisaApi.Fakers.Users;
|
||||
|
||||
/// <summary>
|
||||
/// Generates users
|
||||
/// </summary>
|
||||
public sealed class UserFaker : Faker<User>
|
||||
{
|
||||
public UserFaker()
|
||||
{
|
||||
RuleFor(u => u.Email, f => f.Internet.Email());
|
||||
|
||||
RuleFor(u => u.Password, f => f.Internet.Password());
|
||||
}
|
||||
}
|
||||
28
VisaApiTests/Fakers/VisaApplications/PastVisaFaker.cs
Normal file
28
VisaApiTests/Fakers/VisaApplications/PastVisaFaker.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using Bogus;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates past visas
|
||||
/// </summary>
|
||||
public sealed class PastVisaFaker : Faker<PastVisa>
|
||||
{
|
||||
private IDateTimeProvider dateTimeProvider;
|
||||
|
||||
public PastVisaFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
this.dateTimeProvider = dateTimeProvider;
|
||||
|
||||
RuleFor(pv => pv.Name, f => f.Random.Words());
|
||||
}
|
||||
|
||||
public PastVisa GenerateValid()
|
||||
{
|
||||
var result = Generate();
|
||||
result.IssueDate = dateTimeProvider.Now().AddDays(-Random.Shared.Next(11, 900));
|
||||
result.ExpirationDate = result.IssueDate.AddDays(Random.Shared.Next(1, 11));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
28
VisaApiTests/Fakers/VisaApplications/PastVisitFaker.cs
Normal file
28
VisaApiTests/Fakers/VisaApplications/PastVisitFaker.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using Bogus;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates past visas
|
||||
/// </summary>
|
||||
public sealed class PastVisitFaker : Faker<PastVisit>
|
||||
{
|
||||
private IDateTimeProvider dateTimeProvider;
|
||||
|
||||
public PastVisitFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
this.dateTimeProvider = dateTimeProvider;
|
||||
|
||||
RuleFor(pv => pv.DestinationCountry, f => f.Address.Country());
|
||||
}
|
||||
|
||||
public PastVisit GenerateValid()
|
||||
{
|
||||
var result = Generate();
|
||||
result.StartDate = dateTimeProvider.Now().AddDays(-Random.Shared.Next(11, 900));
|
||||
result.EndDate = result.StartDate.AddDays(Random.Shared.Next(1, 11));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using Bogus;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates permissions to destination Country
|
||||
/// </summary>
|
||||
public sealed class PermissionToDestCountryFaker : Faker<PermissionToDestCountry>
|
||||
{
|
||||
public PermissionToDestCountryFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(p => p.Issuer, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(p => p.ExpirationDate,
|
||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||
}
|
||||
}
|
||||
21
VisaApiTests/Fakers/VisaApplications/ReentryPermitFaker.cs
Normal file
21
VisaApiTests/Fakers/VisaApplications/ReentryPermitFaker.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using Bogus;
|
||||
using Domains;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates re-entry permissions
|
||||
/// </summary>
|
||||
public sealed class ReentryPermitFaker : Faker<ReentryPermit>
|
||||
{
|
||||
public ReentryPermitFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(p => p.Number,
|
||||
f => f.Random.String(ConfigurationConstraints.ReentryPermitNumberLength, 'a', 'z'));
|
||||
|
||||
RuleFor(p => p.ExpirationDate,
|
||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using ApplicationLayer.Services.VisaApplications.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Generates past visas
|
||||
/// </summary>
|
||||
public sealed class PastVisaModelFaker : Faker<PastVisaModel>
|
||||
{
|
||||
private IDateTimeProvider dateTimeProvider;
|
||||
|
||||
public PastVisaModelFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
this.dateTimeProvider = dateTimeProvider;
|
||||
|
||||
RuleFor(pv => pv.Name, f => f.Random.Words());
|
||||
}
|
||||
|
||||
public PastVisaModel GenerateValid()
|
||||
{
|
||||
var result = Generate();
|
||||
result.IssueDate = dateTimeProvider.Now().AddDays(-Random.Shared.Next(11, 900));
|
||||
result.ExpirationDate = result.IssueDate.AddDays(Random.Shared.Next(1, 11));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using ApplicationLayer.Services.VisaApplications.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Generates past visas
|
||||
/// </summary>
|
||||
public sealed class PastVisitModelFaker : Faker<PastVisitModel>
|
||||
{
|
||||
private IDateTimeProvider dateTimeProvider;
|
||||
|
||||
public PastVisitModelFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
this.dateTimeProvider = dateTimeProvider;
|
||||
|
||||
RuleFor(pv => pv.DestinationCountry, f => f.Address.Country());
|
||||
}
|
||||
|
||||
public PastVisitModel GenerateValid()
|
||||
{
|
||||
var result = Generate();
|
||||
result.StartDate = dateTimeProvider.Now().AddDays(-Random.Shared.Next(11, 900));
|
||||
result.EndDate = result.StartDate.AddDays(Random.Shared.Next(1, 11));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using ApplicationLayer.Services.VisaApplications.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications.Requests
|
||||
{
|
||||
public sealed class PermissionToDestCountryModelFaker : Faker<PermissionToDestCountryModel>
|
||||
{
|
||||
public PermissionToDestCountryModelFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(p => p.Issuer, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(p => p.ExpirationDate,
|
||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using ApplicationLayer.Services.VisaApplications.Models;
|
||||
using Bogus;
|
||||
using Domains;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications.Requests;
|
||||
|
||||
/// <summary>
|
||||
/// Generates re-entry permissions
|
||||
/// </summary>
|
||||
public sealed class ReentryPermitModelFaker : Faker<ReentryPermitModel>
|
||||
{
|
||||
public ReentryPermitModelFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(p => p.Number,
|
||||
f => f.Random.String(ConfigurationConstraints.ReentryPermitNumberLength, 'a', 'z'));
|
||||
|
||||
RuleFor(p => p.ExpirationDate,
|
||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||
}
|
||||
}
|
||||
64
VisaApiTests/Fakers/VisaApplications/VisaApplicationFaker.cs
Normal file
64
VisaApiTests/Fakers/VisaApplications/VisaApplicationFaker.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using ApplicationLayer.InfrastructureServicesInterfaces;
|
||||
using Bogus;
|
||||
using Domains;
|
||||
using Domains.ApplicantDomain;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates visa applications
|
||||
/// </summary>
|
||||
public sealed class VisaApplicationFaker : Faker<VisaApplication>
|
||||
{
|
||||
private static ReentryPermitFaker reentryPermitFaker = null!;
|
||||
private static PermissionToDestCountryFaker permissionToDestCountryFaker = null!;
|
||||
|
||||
public VisaApplicationFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
reentryPermitFaker = new(dateTimeProvider);
|
||||
permissionToDestCountryFaker = new(dateTimeProvider);
|
||||
var pastVisaFaker = new PastVisaFaker(dateTimeProvider);
|
||||
var pastVisitFaker = new PastVisitFaker(dateTimeProvider);
|
||||
|
||||
RuleFor(va => va.Status, f => f.Random.Enum<ApplicationStatus>());
|
||||
|
||||
RuleFor(va => va.DestinationCountry, f => f.Address.Country());
|
||||
|
||||
RuleFor(va => va.PastVisas,
|
||||
f => f.PickRandom(pastVisaFaker.Generate(3), f.Random.Int(0, 3)).ToList());
|
||||
|
||||
RuleFor(va => va.PastVisits,
|
||||
f => f.PickRandom(pastVisitFaker.Generate(3), f.Random.Int(0, 3)).ToList());
|
||||
|
||||
RuleFor(va => va.VisaCategory, f => f.Random.Enum<VisaCategory>());
|
||||
|
||||
RuleFor(va => va.ForGroup, f => f.Random.Bool());
|
||||
|
||||
RuleFor(va => va.RequestedNumberOfEntries,
|
||||
f => f.Random.Enum<RequestedNumberOfEntries>());
|
||||
|
||||
RuleFor(va => va.RequestDate, dateTimeProvider.Now);
|
||||
|
||||
RuleFor(va => va.ValidDaysRequested,
|
||||
f => f.Random.Int(1, ConfigurationConstraints.MaxValidDays));
|
||||
}
|
||||
|
||||
public VisaApplication GenerateValid(Applicant applicant)
|
||||
{
|
||||
var result = Generate();
|
||||
|
||||
result.ApplicantId = applicant.Id;
|
||||
if (applicant.IsNonResident)
|
||||
{
|
||||
result.ReentryPermit = reentryPermitFaker.Generate();
|
||||
}
|
||||
|
||||
if (result.VisaCategory is VisaCategory.Transit)
|
||||
{
|
||||
result.PermissionToDestCountry = permissionToDestCountryFaker.Generate();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user