From 40c4d19990c450b3e4893893700343de913c89bf Mon Sep 17 00:00:00 2001 From: prtsie Date: Tue, 17 Sep 2024 16:56:30 +0300 Subject: [PATCH] started fakers --- .../VisaApiTests/Fakers/ApplicantFaker.cs | 64 +++++++++++++++++++ .../VisaApiTests/Fakers/UserFaker.cs | 15 +++++ .../VisaApiTests/VisaApiTests.csproj | 1 + 3 files changed, 80 insertions(+) create mode 100644 SchengenVisaApi/VisaApiTests/Fakers/ApplicantFaker.cs create mode 100644 SchengenVisaApi/VisaApiTests/Fakers/UserFaker.cs diff --git a/SchengenVisaApi/VisaApiTests/Fakers/ApplicantFaker.cs b/SchengenVisaApi/VisaApiTests/Fakers/ApplicantFaker.cs new file mode 100644 index 0000000..12d2a73 --- /dev/null +++ b/SchengenVisaApi/VisaApiTests/Fakers/ApplicantFaker.cs @@ -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 + { + public ApplicantFaker(User user, IDateTimeProvider dateTimeProvider) + { + RuleFor(a => a.Citizenship, f => f.Address.Country()); + + RuleFor(a => a.Gender, f => f.Random.Enum()); + + 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()); + + 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() + }); + } + } +} diff --git a/SchengenVisaApi/VisaApiTests/Fakers/UserFaker.cs b/SchengenVisaApi/VisaApiTests/Fakers/UserFaker.cs new file mode 100644 index 0000000..7b9164f --- /dev/null +++ b/SchengenVisaApi/VisaApiTests/Fakers/UserFaker.cs @@ -0,0 +1,15 @@ +using Bogus; +using Domains.Users; + +namespace VisaApi.Fakers +{ + public sealed class UserFaker : Faker + { + public UserFaker() + { + RuleFor(u => u.Email, f => f.Internet.Email()); + + RuleFor(u => u.Password, f => f.Internet.Password()); + } + } +} diff --git a/SchengenVisaApi/VisaApiTests/VisaApiTests.csproj b/SchengenVisaApi/VisaApiTests/VisaApiTests.csproj index 0be6f2d..9511b31 100644 --- a/SchengenVisaApi/VisaApiTests/VisaApiTests.csproj +++ b/SchengenVisaApi/VisaApiTests/VisaApiTests.csproj @@ -11,6 +11,7 @@ +