refactor (readonly for static objects in tests and file-scoped namespaces
This commit is contained in:
@@ -3,15 +3,15 @@ using Bogus;
|
||||
using Domains;
|
||||
using Domains.ApplicantDomain;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants
|
||||
namespace VisaApi.Fakers.Applicants;
|
||||
|
||||
/// <summary>
|
||||
/// Generates applicants
|
||||
/// </summary>
|
||||
public sealed class ApplicantFaker : Faker<Applicant>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates applicants
|
||||
/// </summary>
|
||||
public sealed class ApplicantFaker : Faker<Applicant>
|
||||
public ApplicantFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
public ApplicantFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(a => a.Citizenship, f => f.Address.Country());
|
||||
|
||||
RuleFor(a => a.Gender, f => f.Random.Enum<Gender>());
|
||||
@@ -62,5 +62,4 @@ namespace VisaApi.Fakers.Applicants
|
||||
PhoneNum = f.Phone.PhoneNumber()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using ApplicationLayer.Services.Applicants.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants.Requests
|
||||
namespace VisaApi.Fakers.Applicants.Requests;
|
||||
|
||||
public sealed class NameModelFaker : Faker<NameModel>
|
||||
{
|
||||
public sealed class NameModelFaker : Faker<NameModel>
|
||||
public NameModelFaker()
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,12 @@ using ApplicationLayer.Services.Applicants.Models;
|
||||
using Bogus;
|
||||
using Domains;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants.Requests
|
||||
namespace VisaApi.Fakers.Applicants.Requests;
|
||||
|
||||
public sealed class PassportModelFaker : Faker<PassportModel>
|
||||
{
|
||||
public sealed class PassportModelFaker : Faker<PassportModel>
|
||||
public PassportModelFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
public PassportModelFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(m => m.Issuer, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(m => m.Number,
|
||||
@@ -20,5 +20,4 @@ namespace VisaApi.Fakers.Applicants.Requests
|
||||
RuleFor(m => m.IssueDate,
|
||||
f => f.Date.Past(4, dateTimeProvider.Now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@ using ApplicationLayer.Services.Applicants.Models;
|
||||
using Bogus;
|
||||
using Domains.ApplicantDomain;
|
||||
|
||||
namespace VisaApi.Fakers.Applicants.Requests
|
||||
namespace VisaApi.Fakers.Applicants.Requests;
|
||||
|
||||
public sealed class PlaceOfWorkModelFaker : Faker<PlaceOfWorkModel>
|
||||
{
|
||||
public sealed class PlaceOfWorkModelFaker : Faker<PlaceOfWorkModel>
|
||||
public PlaceOfWorkModelFaker()
|
||||
{
|
||||
public PlaceOfWorkModelFaker()
|
||||
{
|
||||
RuleFor(m => m.Name, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(m => m.PhoneNum, f => f.Phone.PhoneNumber("###########"));
|
||||
@@ -21,5 +21,4 @@ namespace VisaApi.Fakers.Applicants.Requests
|
||||
Building = f.Address.BuildingNumber()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using ApplicationLayer.Services.AuthServices.Common;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Auth
|
||||
namespace VisaApi.Fakers.Auth;
|
||||
|
||||
public sealed class AuthDataFaker : Faker<AuthData>
|
||||
{
|
||||
public sealed class AuthDataFaker : Faker<AuthData>
|
||||
public AuthDataFaker()
|
||||
{
|
||||
public AuthDataFaker()
|
||||
{
|
||||
RuleFor(a => a.Email, f => f.Internet.Email());
|
||||
|
||||
RuleFor(a => a.Password, f => f.Internet.Password());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using ApplicationLayer.Services.AuthServices.Requests;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Auth
|
||||
{
|
||||
public sealed class RegisterRequestFaker : Faker<RegisterRequest>
|
||||
{
|
||||
private static AuthDataFaker authDataFaker = new();
|
||||
namespace VisaApi.Fakers.Auth;
|
||||
|
||||
public RegisterRequestFaker()
|
||||
{
|
||||
public sealed class RegisterRequestFaker : Faker<RegisterRequest>
|
||||
{
|
||||
private static AuthDataFaker authDataFaker = new();
|
||||
|
||||
public RegisterRequestFaker()
|
||||
{
|
||||
RuleFor(r => r.AuthData, () => authDataFaker.Generate());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using ApplicationLayer.Services.Users.Models;
|
||||
using Bogus;
|
||||
|
||||
namespace VisaApi.Fakers.Common
|
||||
namespace VisaApi.Fakers.Common;
|
||||
|
||||
public sealed class ChangeAuthDataFaker : Faker<ChangeAuthData>
|
||||
{
|
||||
public sealed class ChangeAuthDataFaker : Faker<ChangeAuthData>
|
||||
public ChangeAuthDataFaker()
|
||||
{
|
||||
public ChangeAuthDataFaker()
|
||||
{
|
||||
RuleFor(a => a.Email, f => f.Internet.Email());
|
||||
|
||||
RuleFor(a => a.Password, f => f.Internet.Password());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,14 @@
|
||||
using Bogus;
|
||||
using VisaApi.Fakers.Common;
|
||||
|
||||
namespace VisaApi.Fakers.Users.Requests
|
||||
{
|
||||
public sealed class ChangeUserAuthDataRequestFaker : Faker<ChangeUserAuthDataRequest>
|
||||
{
|
||||
private static ChangeAuthDataFaker changeAuthDataFaker = new();
|
||||
namespace VisaApi.Fakers.Users.Requests;
|
||||
|
||||
public ChangeUserAuthDataRequestFaker()
|
||||
{
|
||||
public sealed class ChangeUserAuthDataRequestFaker : Faker<ChangeUserAuthDataRequest>
|
||||
{
|
||||
private static ChangeAuthDataFaker changeAuthDataFaker = new();
|
||||
|
||||
public ChangeUserAuthDataRequestFaker()
|
||||
{
|
||||
CustomInstantiator(_ => new(Guid.NewGuid(), changeAuthDataFaker.Generate()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
using Bogus;
|
||||
using Domains.Users;
|
||||
|
||||
namespace VisaApi.Fakers.Users
|
||||
namespace VisaApi.Fakers.Users;
|
||||
|
||||
/// <summary>
|
||||
/// Generates users
|
||||
/// </summary>
|
||||
public sealed class UserFaker : Faker<User>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates users
|
||||
/// </summary>
|
||||
public sealed class UserFaker : Faker<User>
|
||||
public UserFaker()
|
||||
{
|
||||
public UserFaker()
|
||||
{
|
||||
RuleFor(u => u.Email, f => f.Internet.Email());
|
||||
|
||||
RuleFor(u => u.Password, f => f.Internet.Password());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,27 @@
|
||||
using Bogus;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates past visas
|
||||
/// </summary>
|
||||
public sealed class PastVisaFaker : Faker<PastVisa>
|
||||
{
|
||||
private IDateTimeProvider dateTimeProvider;
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
public PastVisaFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,28 +2,27 @@
|
||||
using Bogus;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates past visas
|
||||
/// </summary>
|
||||
public sealed class PastVisitFaker : Faker<PastVisit>
|
||||
{
|
||||
private IDateTimeProvider dateTimeProvider;
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
public PastVisitFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,19 +2,18 @@
|
||||
using Bogus;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates permissions to destination Country
|
||||
/// </summary>
|
||||
public sealed class PermissionToDestCountryFaker : Faker<PermissionToDestCountry>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates permissions to destination Country
|
||||
/// </summary>
|
||||
public sealed class PermissionToDestCountryFaker : Faker<PermissionToDestCountry>
|
||||
public PermissionToDestCountryFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
public PermissionToDestCountryFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
RuleFor(p => p.Issuer, f => f.Company.CompanyName());
|
||||
|
||||
RuleFor(p => p.ExpirationDate,
|
||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,20 +3,19 @@ using Bogus;
|
||||
using Domains;
|
||||
using Domains.VisaApplicationDomain;
|
||||
|
||||
namespace VisaApi.Fakers.VisaApplications
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
/// <summary>
|
||||
/// Generates re-entry permissions
|
||||
/// </summary>
|
||||
public sealed class ReentryPermitFaker : Faker<ReentryPermit>
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates re-entry permissions
|
||||
/// </summary>
|
||||
public sealed class ReentryPermitFaker : Faker<ReentryPermit>
|
||||
public ReentryPermitFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,18 +4,18 @@ 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!;
|
||||
namespace VisaApi.Fakers.VisaApplications;
|
||||
|
||||
public VisaApplicationFaker(IDateTimeProvider dateTimeProvider)
|
||||
{
|
||||
/// <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);
|
||||
@@ -44,8 +44,8 @@ namespace VisaApi.Fakers.VisaApplications
|
||||
f => f.Random.Int(1, ConfigurationConstraints.MaxValidDays));
|
||||
}
|
||||
|
||||
public VisaApplication GenerateValid(Applicant applicant)
|
||||
{
|
||||
public VisaApplication GenerateValid(Applicant applicant)
|
||||
{
|
||||
var result = Generate();
|
||||
|
||||
result.ApplicantId = applicant.Id;
|
||||
@@ -61,5 +61,4 @@ namespace VisaApi.Fakers.VisaApplications
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user