refactor (readonly for static objects in tests and file-scoped namespaces

This commit is contained in:
2024-09-22 17:34:29 +03:00
parent 1625764e0a
commit a80076e2e6
50 changed files with 1196 additions and 1246 deletions

View File

@@ -1,7 +1,7 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace ApplicationLayer namespace ApplicationLayer;
{
public static class Constants public static class Constants
{ {
public readonly static Regex EnglishWordRegex = new("^[a-zA-Z]*$"); public readonly static Regex EnglishWordRegex = new("^[a-zA-Z]*$");
@@ -10,4 +10,3 @@ namespace ApplicationLayer
public readonly static Regex PhoneNumRegex = new(@"^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$"); public readonly static Regex PhoneNumRegex = new(@"^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$");
} }
}

View File

@@ -1,9 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace ApplicationLayer.Services.AuthServices.Common namespace ApplicationLayer.Services.AuthServices.Common;
{
public class AuthToken public class AuthToken
{ {
[Required] public string Token { get; set; } = null!; [Required] public string Token { get; set; } = null!;
} }
}

View File

@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Domains; using Domains;
namespace ApplicationLayer.Services.Users.Models namespace ApplicationLayer.Services.Users.Models;
{
/// Auth data with nullable password for making change auth data requests /// Auth data with nullable password for making change auth data requests
public class ChangeAuthData public class ChangeAuthData
{ {
@@ -13,4 +13,3 @@ namespace ApplicationLayer.Services.Users.Models
[MaxLength(ConfigurationConstraints.PasswordLength)] [MaxLength(ConfigurationConstraints.PasswordLength)]
public string? Password { get; set; } public string? Password { get; set; }
} }
}

View File

@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Domains; using Domains;
namespace ApplicationLayer.Services.Users.Models namespace ApplicationLayer.Services.Users.Models;
{
public class UserModel public class UserModel
{ {
/// Unique Identifier of user /// Unique Identifier of user
@@ -13,4 +13,3 @@ namespace ApplicationLayer.Services.Users.Models
[MaxLength(ConfigurationConstraints.EmailLength)] [MaxLength(ConfigurationConstraints.EmailLength)]
public string Email { get; set; } = null!; public string Email { get; set; } = null!;
} }
}

View File

@@ -1,8 +1,8 @@
using Domains; using Domains;
using FluentValidation; using FluentValidation;
namespace ApplicationLayer.Services.Users.Requests.Validation namespace ApplicationLayer.Services.Users.Requests.Validation;
{
public class ChangeUserAuthDataRequestValidator : AbstractValidator<ChangeUserAuthDataRequest> public class ChangeUserAuthDataRequestValidator : AbstractValidator<ChangeUserAuthDataRequest>
{ {
public ChangeUserAuthDataRequestValidator() public ChangeUserAuthDataRequestValidator()
@@ -21,4 +21,3 @@ namespace ApplicationLayer.Services.Users.Requests.Validation
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}"); .WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
} }
} }
}

View File

@@ -1,4 +1,3 @@
namespace BlazorWebAssemblyVisaApiClient.Common.Exceptions namespace BlazorWebAssemblyVisaApiClient.Common.Exceptions;
{
public class BlazorClientException(string message) : Exception(message); public class BlazorClientException(string message) : Exception(message);
}

View File

@@ -1,4 +1,3 @@
namespace BlazorWebAssemblyVisaApiClient.Common.Exceptions namespace BlazorWebAssemblyVisaApiClient.Common.Exceptions;
{
public class NotLoggedInException() : BlazorClientException("User is not logged in."); public class NotLoggedInException() : BlazorClientException("User is not logged in.");
}

View File

@@ -1,8 +1,8 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace BlazorWebAssemblyVisaApiClient namespace BlazorWebAssemblyVisaApiClient;
{
public static class Constants public static class Constants
{ {
public readonly static Regex EnglishWordRegex = new("^[a-zA-Z]*$"); public readonly static Regex EnglishWordRegex = new("^[a-zA-Z]*$");
@@ -17,4 +17,3 @@ namespace BlazorWebAssemblyVisaApiClient
public const string ApprovingAuthorityRole = "ApprovingAuthority"; public const string ApprovingAuthorityRole = "ApprovingAuthority";
public const string AdminRole = "Admin"; public const string AdminRole = "Admin";
} }
}

View File

@@ -3,8 +3,8 @@ using BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models;
using VisaApiClient; using VisaApiClient;
using PlaceOfWorkModel = BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models.PlaceOfWorkModel; using PlaceOfWorkModel = BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models.PlaceOfWorkModel;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles;
{
public class RegisterApplicantRequestProfile : Profile public class RegisterApplicantRequestProfile : Profile
{ {
public RegisterApplicantRequestProfile() public RegisterApplicantRequestProfile()
@@ -16,4 +16,3 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles
CreateMap<PlaceOfWorkModel, VisaApiClient.PlaceOfWorkModel>(MemberList.Destination); CreateMap<PlaceOfWorkModel, VisaApiClient.PlaceOfWorkModel>(MemberList.Destination);
} }
} }
}

View File

@@ -2,8 +2,8 @@
using BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models; using BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles;
{
public class VisaApplicationCreateRequestProfile : Profile public class VisaApplicationCreateRequestProfile : Profile
{ {
public VisaApplicationCreateRequestProfile() public VisaApplicationCreateRequestProfile()
@@ -11,4 +11,3 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles
CreateMap<VisaApplicationCreateRequestModel, VisaApplicationCreateRequest>(MemberList.Destination); CreateMap<VisaApplicationCreateRequestModel, VisaApplicationCreateRequest>(MemberList.Destination);
} }
} }
}

View File

@@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers;
{
public static class EnumExtensions public static class EnumExtensions
{ {
public static string GetDisplayName(this Enum value) public static string GetDisplayName(this Enum value)
@@ -15,4 +15,3 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
return displayName; return displayName;
} }
} }
}

View File

@@ -1,8 +1,8 @@
using System.Text; using System.Text;
using FluentValidation.Results; using FluentValidation.Results;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers;
{
public static class ValidationResultExtensions public static class ValidationResultExtensions
{ {
public static string ToErrorsString(this ValidationResult validationResult) public static string ToErrorsString(this ValidationResult validationResult)
@@ -19,4 +19,3 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
return stringBuilder.ToString(); return stringBuilder.ToString();
} }
} }
}

View File

@@ -1,9 +1,8 @@
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider;
{
public class DateTimeProvider : IDateTimeProvider public class DateTimeProvider : IDateTimeProvider
{ {
public DateTime Now() => DateTime.Now; public DateTime Now() => DateTime.Now;
public string FormattedNow() => Now().ToString("yyyy-MM-dd"); public string FormattedNow() => Now().ToString("yyyy-MM-dd");
} }
}

View File

@@ -1,9 +1,8 @@
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.DateTimeProvider;
{
public interface IDateTimeProvider public interface IDateTimeProvider
{ {
DateTime Now(); DateTime Now();
string FormattedNow(); string FormattedNow();
} }
}

View File

@@ -1,6 +1,5 @@
using BlazorWebAssemblyVisaApiClient.Common.Exceptions; using BlazorWebAssemblyVisaApiClient.Common.Exceptions;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions;
{
public class UnknownRoleException() : BlazorClientException("Unknown user role"); public class UnknownRoleException() : BlazorClientException("Unknown user role");
}

View File

@@ -1,7 +1,7 @@
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider;
{
public interface IUserDataProvider public interface IUserDataProvider
{ {
public string? CurrentRole { get; } public string? CurrentRole { get; }
@@ -12,4 +12,3 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
public void UpdateCurrentRole(); public void UpdateCurrentRole();
} }
}

View File

@@ -3,8 +3,8 @@ using System.Security.Claims;
using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions; using BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider.Exceptions;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvider;
{
public class UserDataProvider(Client client) : IUserDataProvider public class UserDataProvider(Client client) : IUserDataProvider
{ {
private readonly static JwtSecurityTokenHandler tokenHandler = new(); private readonly static JwtSecurityTokenHandler tokenHandler = new();
@@ -50,4 +50,3 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
} }
} }
} }
}

View File

@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models;
{
/// Model of place of work with attributes required for validation to work /// Model of place of work with attributes required for validation to work
public class PlaceOfWorkModel public class PlaceOfWorkModel
{ {
@@ -18,4 +18,3 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
[StringLength(ConfigurationConstraints.PhoneNumberLength, MinimumLength = ConfigurationConstraints.PhoneNumberMinLength)] [StringLength(ConfigurationConstraints.PhoneNumberLength, MinimumLength = ConfigurationConstraints.PhoneNumberMinLength)]
public string PhoneNum { get; set; } = default!; public string PhoneNum { get; set; } = default!;
} }
}

View File

@@ -3,8 +3,8 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models;
{
/// Model of request with attributes required for validation to work /// Model of request with attributes required for validation to work
public class RegisterApplicantRequestModel public class RegisterApplicantRequestModel
{ {
@@ -65,4 +65,3 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
public bool IsNonResident { get; set; } public bool IsNonResident { get; set; }
} }
}

View File

@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models;
{
/// Model of request with attributes required for validation to work /// Model of request with attributes required for validation to work
public class RegisterRequestModel public class RegisterRequestModel
{ {
@@ -10,4 +10,3 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
[ValidateComplexType] [ValidateComplexType]
public AuthData AuthData { get; set; } = new AuthData(); public AuthData AuthData { get; set; } = new AuthData();
} }
}

View File

@@ -1,8 +1,8 @@
using FluentValidation; using FluentValidation;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Validation.Auth namespace BlazorWebAssemblyVisaApiClient.Validation.Auth;
{
public class ChangeUserAuthDataRequestValidator : AbstractValidator<ChangeUserAuthDataRequest> public class ChangeUserAuthDataRequestValidator : AbstractValidator<ChangeUserAuthDataRequest>
{ {
public ChangeUserAuthDataRequestValidator() public ChangeUserAuthDataRequestValidator()
@@ -18,4 +18,3 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Auth
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}"); .WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
} }
} }
}

View File

@@ -1,8 +1,8 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using VisaApiClient; using VisaApiClient;
namespace BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models namespace BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models;
{
/// Model for request for data annotations validation to work /// Model for request for data annotations validation to work
public class VisaApplicationCreateRequestModel public class VisaApplicationCreateRequestModel
{ {
@@ -35,4 +35,3 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models
[ValidateComplexType] [ValidateComplexType]
public List<PastVisitModel> PastVisits { get; set; } = []; public List<PastVisitModel> PastVisits { get; set; } = [];
} }
}

View File

@@ -1,7 +1,7 @@
using System.Text; using System.Text;
namespace VisaApiClient namespace VisaApiClient;
{
public class ClientBase public class ClientBase
{ {
public AuthToken? AuthToken { get; set; } public AuthToken? AuthToken { get; set; }
@@ -27,4 +27,3 @@ namespace VisaApiClient
protected async Task ProcessResponseAsync(HttpClient client, HttpResponseMessage response, CancellationToken cancellationToken) protected async Task ProcessResponseAsync(HttpClient client, HttpResponseMessage response, CancellationToken cancellationToken)
=> await Task.CompletedTask; => await Task.CompletedTask;
} }
}

View File

@@ -1,7 +1,6 @@
namespace VisaApi namespace VisaApi;
{
public static class Collections public static class Collections
{ {
public const string ContextUsingTestCollection = "ContextUsingTestCollection"; public const string ContextUsingTestCollection = "ContextUsingTestCollection";
} }
}

View File

@@ -3,8 +3,8 @@ using Bogus;
using Domains; using Domains;
using Domains.ApplicantDomain; using Domains.ApplicantDomain;
namespace VisaApi.Fakers.Applicants namespace VisaApi.Fakers.Applicants;
{
/// <summary> /// <summary>
/// Generates applicants /// Generates applicants
/// </summary> /// </summary>
@@ -63,4 +63,3 @@ namespace VisaApi.Fakers.Applicants
}); });
} }
} }
}

View File

@@ -1,8 +1,8 @@
using ApplicationLayer.Services.Applicants.Models; using ApplicationLayer.Services.Applicants.Models;
using Bogus; 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()
@@ -14,4 +14,3 @@ namespace VisaApi.Fakers.Applicants.Requests
RuleFor(m => m.Patronymic, f => f.Name.FirstName()); RuleFor(m => m.Patronymic, f => f.Name.FirstName());
} }
} }
}

View File

@@ -3,8 +3,8 @@ using ApplicationLayer.Services.Applicants.Models;
using Bogus; using Bogus;
using Domains; 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)
@@ -21,4 +21,3 @@ namespace VisaApi.Fakers.Applicants.Requests
f => f.Date.Past(4, dateTimeProvider.Now())); f => f.Date.Past(4, dateTimeProvider.Now()));
} }
} }
}

View File

@@ -2,8 +2,8 @@ using ApplicationLayer.Services.Applicants.Models;
using Bogus; using Bogus;
using Domains.ApplicantDomain; 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()
@@ -22,4 +22,3 @@ namespace VisaApi.Fakers.Applicants.Requests
}); });
} }
} }
}

View File

@@ -1,8 +1,8 @@
using ApplicationLayer.Services.AuthServices.Common; using ApplicationLayer.Services.AuthServices.Common;
using Bogus; 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()
@@ -12,4 +12,3 @@ namespace VisaApi.Fakers.Auth
RuleFor(a => a.Password, f => f.Internet.Password()); RuleFor(a => a.Password, f => f.Internet.Password());
} }
} }
}

View File

@@ -1,8 +1,8 @@
using ApplicationLayer.Services.AuthServices.Requests; using ApplicationLayer.Services.AuthServices.Requests;
using Bogus; using Bogus;
namespace VisaApi.Fakers.Auth namespace VisaApi.Fakers.Auth;
{
public sealed class RegisterRequestFaker : Faker<RegisterRequest> public sealed class RegisterRequestFaker : Faker<RegisterRequest>
{ {
private static AuthDataFaker authDataFaker = new(); private static AuthDataFaker authDataFaker = new();
@@ -12,4 +12,3 @@ namespace VisaApi.Fakers.Auth
RuleFor(r => r.AuthData, () => authDataFaker.Generate()); RuleFor(r => r.AuthData, () => authDataFaker.Generate());
} }
} }
}

View File

@@ -1,8 +1,8 @@
using ApplicationLayer.Services.Users.Models; using ApplicationLayer.Services.Users.Models;
using Bogus; 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()
@@ -12,4 +12,3 @@ namespace VisaApi.Fakers.Common
RuleFor(a => a.Password, f => f.Internet.Password()); RuleFor(a => a.Password, f => f.Internet.Password());
} }
} }
}

View File

@@ -2,8 +2,8 @@
using Bogus; using Bogus;
using VisaApi.Fakers.Common; using VisaApi.Fakers.Common;
namespace VisaApi.Fakers.Users.Requests namespace VisaApi.Fakers.Users.Requests;
{
public sealed class ChangeUserAuthDataRequestFaker : Faker<ChangeUserAuthDataRequest> public sealed class ChangeUserAuthDataRequestFaker : Faker<ChangeUserAuthDataRequest>
{ {
private static ChangeAuthDataFaker changeAuthDataFaker = new(); private static ChangeAuthDataFaker changeAuthDataFaker = new();
@@ -13,4 +13,3 @@ namespace VisaApi.Fakers.Users.Requests
CustomInstantiator(_ => new(Guid.NewGuid(), changeAuthDataFaker.Generate())); CustomInstantiator(_ => new(Guid.NewGuid(), changeAuthDataFaker.Generate()));
} }
} }
}

View File

@@ -1,8 +1,8 @@
using Bogus; using Bogus;
using Domains.Users; using Domains.Users;
namespace VisaApi.Fakers.Users namespace VisaApi.Fakers.Users;
{
/// <summary> /// <summary>
/// Generates users /// Generates users
/// </summary> /// </summary>
@@ -15,4 +15,3 @@ namespace VisaApi.Fakers.Users
RuleFor(u => u.Password, f => f.Internet.Password()); RuleFor(u => u.Password, f => f.Internet.Password());
} }
} }
}

View File

@@ -2,8 +2,8 @@
using Bogus; using Bogus;
using Domains.VisaApplicationDomain; using Domains.VisaApplicationDomain;
namespace VisaApi.Fakers.VisaApplications namespace VisaApi.Fakers.VisaApplications;
{
/// <summary> /// <summary>
/// Generates past visas /// Generates past visas
/// </summary> /// </summary>
@@ -26,4 +26,3 @@ namespace VisaApi.Fakers.VisaApplications
return result; return result;
} }
} }
}

View File

@@ -2,8 +2,8 @@
using Bogus; using Bogus;
using Domains.VisaApplicationDomain; using Domains.VisaApplicationDomain;
namespace VisaApi.Fakers.VisaApplications namespace VisaApi.Fakers.VisaApplications;
{
/// <summary> /// <summary>
/// Generates past visas /// Generates past visas
/// </summary> /// </summary>
@@ -26,4 +26,3 @@ namespace VisaApi.Fakers.VisaApplications
return result; return result;
} }
} }
}

View File

@@ -2,8 +2,8 @@
using Bogus; using Bogus;
using Domains.VisaApplicationDomain; using Domains.VisaApplicationDomain;
namespace VisaApi.Fakers.VisaApplications namespace VisaApi.Fakers.VisaApplications;
{
/// <summary> /// <summary>
/// Generates permissions to destination Country /// Generates permissions to destination Country
/// </summary> /// </summary>
@@ -17,4 +17,3 @@ namespace VisaApi.Fakers.VisaApplications
f => f.Date.Future(4, dateTimeProvider.Now())); f => f.Date.Future(4, dateTimeProvider.Now()));
} }
} }
}

View File

@@ -3,8 +3,8 @@ using Bogus;
using Domains; using Domains;
using Domains.VisaApplicationDomain; using Domains.VisaApplicationDomain;
namespace VisaApi.Fakers.VisaApplications namespace VisaApi.Fakers.VisaApplications;
{
/// <summary> /// <summary>
/// Generates re-entry permissions /// Generates re-entry permissions
/// </summary> /// </summary>
@@ -19,4 +19,3 @@ namespace VisaApi.Fakers.VisaApplications
f => f.Date.Future(4, dateTimeProvider.Now())); f => f.Date.Future(4, dateTimeProvider.Now()));
} }
} }
}

View File

@@ -4,8 +4,8 @@ using Domains;
using Domains.ApplicantDomain; using Domains.ApplicantDomain;
using Domains.VisaApplicationDomain; using Domains.VisaApplicationDomain;
namespace VisaApi.Fakers.VisaApplications namespace VisaApi.Fakers.VisaApplications;
{
/// <summary> /// <summary>
/// Generates visa applications /// Generates visa applications
/// </summary> /// </summary>
@@ -62,4 +62,3 @@ namespace VisaApi.Fakers.VisaApplications
return result; return result;
} }
} }
}

View File

@@ -1,9 +1,8 @@
using ApplicationLayer.InfrastructureServicesInterfaces; using ApplicationLayer.InfrastructureServicesInterfaces;
namespace VisaApi.Services namespace VisaApi.Services;
{
public class TestDateTimeProvider : IDateTimeProvider public class TestDateTimeProvider : IDateTimeProvider
{ {
public DateTime Now() => DateTime.Now; public DateTime Now() => DateTime.Now;
} }
}

View File

@@ -7,12 +7,12 @@ using FluentValidation;
using VisaApi.Fakers.Applicants.Requests; using VisaApi.Fakers.Applicants.Requests;
using Xunit; using Xunit;
namespace VisaApi.Tests.Application.Validation.Applicants namespace VisaApi.Tests.Application.Validation.Applicants;
{
public class NameModelValidatorTests public class NameModelValidatorTests
{ {
private static IValidator<NameModel> validator = new NameModelValidator(); private readonly static IValidator<NameModel> validator = new NameModelValidator();
private static NameModelFaker faker = new(); private readonly static NameModelFaker faker = new();
/// <summary> /// <summary>
/// Test for <see cref="NameModel"/> validator that should throw for empty first name /// Test for <see cref="NameModel"/> validator that should throw for empty first name
@@ -168,4 +168,3 @@ namespace VisaApi.Tests.Application.Validation.Applicants
result.Errors.Should().BeEmpty(); result.Errors.Should().BeEmpty();
} }
} }
}

View File

@@ -9,13 +9,13 @@ using VisaApi.Fakers.Applicants.Requests;
using VisaApi.Services; using VisaApi.Services;
using Xunit; using Xunit;
namespace VisaApi.Tests.Application.Validation.Applicants namespace VisaApi.Tests.Application.Validation.Applicants;
{
public class PassportModelValidatorTests public class PassportModelValidatorTests
{ {
private static IDateTimeProvider dateTimeProvider = new TestDateTimeProvider(); private readonly static IDateTimeProvider dateTimeProvider = new TestDateTimeProvider();
private static IValidator<PassportModel> validator = new PassportModelValidator(dateTimeProvider); private readonly static IValidator<PassportModel> validator = new PassportModelValidator(dateTimeProvider);
private static PassportModelFaker faker = new(dateTimeProvider); private readonly static PassportModelFaker faker = new(dateTimeProvider);
/// <summary> /// <summary>
/// Test for <see cref="PassportModel"/> validator that should return error for empty number /// Test for <see cref="PassportModel"/> validator that should return error for empty number
@@ -172,4 +172,3 @@ namespace VisaApi.Tests.Application.Validation.Applicants
result.Errors.Should().BeEmpty(); result.Errors.Should().BeEmpty();
} }
} }
}

View File

@@ -7,12 +7,12 @@ using FluentValidation;
using VisaApi.Fakers.Applicants.Requests; using VisaApi.Fakers.Applicants.Requests;
using Xunit; using Xunit;
namespace VisaApi.Tests.Application.Validation.Applicants namespace VisaApi.Tests.Application.Validation.Applicants;
{
public class PlaceOfWorkModelValidatorTests public class PlaceOfWorkModelValidatorTests
{ {
private static IValidator<PlaceOfWorkModel> validator = new PlaceOfWorkModelValidator(); private readonly static IValidator<PlaceOfWorkModel> validator = new PlaceOfWorkModelValidator();
private static PlaceOfWorkModelFaker faker = new(); private readonly static PlaceOfWorkModelFaker faker = new();
/// <summary> /// <summary>
/// Test for <see cref="PlaceOfWorkModel"/> validator that should return error for empty phone num /// Test for <see cref="PlaceOfWorkModel"/> validator that should return error for empty phone num
@@ -351,4 +351,3 @@ namespace VisaApi.Tests.Application.Validation.Applicants
result.Errors.Should().BeEmpty(); result.Errors.Should().BeEmpty();
} }
} }
}

View File

@@ -7,8 +7,8 @@ using FluentValidation;
using VisaApi.Fakers.Auth; using VisaApi.Fakers.Auth;
using Xunit; using Xunit;
namespace VisaApi.Tests.Application.Validation.Auth namespace VisaApi.Tests.Application.Validation.Auth;
{
public class AuthDataValidatorTests public class AuthDataValidatorTests
{ {
private readonly static IValidator<AuthData> validator = new AuthDataValidator(); private readonly static IValidator<AuthData> validator = new AuthDataValidator();
@@ -111,4 +111,3 @@ namespace VisaApi.Tests.Application.Validation.Auth
.Should().BeEmpty(); .Should().BeEmpty();
} }
} }
}

View File

@@ -11,8 +11,8 @@ using VisaApi.Fakers.Users;
using VisaApi.Tests.Infrastructure.Database; using VisaApi.Tests.Infrastructure.Database;
using Xunit; using Xunit;
namespace VisaApi.Tests.Application.Validation.Auth namespace VisaApi.Tests.Application.Validation.Auth;
{
[Collection(Collections.ContextUsingTestCollection)] [Collection(Collections.ContextUsingTestCollection)]
public class RegisterRequestValidatorTests public class RegisterRequestValidatorTests
{ {
@@ -91,4 +91,3 @@ namespace VisaApi.Tests.Application.Validation.Auth
result.Errors.Should().BeEmpty(); result.Errors.Should().BeEmpty();
} }
} }
}

View File

@@ -5,8 +5,8 @@ using FluentValidation;
using VisaApi.Fakers.Users.Requests; using VisaApi.Fakers.Users.Requests;
using Xunit; using Xunit;
namespace VisaApi.Tests.Application.Validation.Users namespace VisaApi.Tests.Application.Validation.Users;
{
public class ChangeUserAuthDataRequestValidationTests public class ChangeUserAuthDataRequestValidationTests
{ {
private readonly static IValidator<ChangeUserAuthDataRequest> validator = new ChangeUserAuthDataRequestValidator(); private readonly static IValidator<ChangeUserAuthDataRequest> validator = new ChangeUserAuthDataRequestValidator();
@@ -46,4 +46,3 @@ namespace VisaApi.Tests.Application.Validation.Users
result.IsValid.Should().BeTrue(); result.IsValid.Should().BeTrue();
} }
} }
}

View File

@@ -2,8 +2,8 @@
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
using DbContext = Infrastructure.Database.DbContext; using DbContext = Infrastructure.Database.DbContext;
namespace VisaApi.Tests.Infrastructure.Database namespace VisaApi.Tests.Infrastructure.Database;
{
public static class InMemoryContextProvider public static class InMemoryContextProvider
{ {
private static DbContextOptions<DbContext> opts = new DbContextOptionsBuilder<DbContext>() private static DbContextOptions<DbContext> opts = new DbContextOptionsBuilder<DbContext>()
@@ -21,4 +21,3 @@ namespace VisaApi.Tests.Infrastructure.Database
return result; return result;
} }
} }
}

View File

@@ -9,8 +9,8 @@ using VisaApi.Fakers.Users;
using VisaApi.Services; using VisaApi.Services;
using Xunit; using Xunit;
namespace VisaApi.Tests.Infrastructure.Database.Repositories namespace VisaApi.Tests.Infrastructure.Database.Repositories;
{
[Collection(Collections.ContextUsingTestCollection)] [Collection(Collections.ContextUsingTestCollection)]
public class ApplicantsRepositoryTests public class ApplicantsRepositoryTests
{ {
@@ -152,4 +152,3 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories
result.Should().Be(applicant.IsNonResident); result.Should().Be(applicant.IsNonResident);
} }
} }
}

View File

@@ -1,7 +1,6 @@
using Domains.Users; using Domains.Users;
using Infrastructure.Database.Generic; using Infrastructure.Database.Generic;
namespace VisaApi.Tests.Infrastructure.Database.Repositories.Generic namespace VisaApi.Tests.Infrastructure.Database.Repositories.Generic;
{
public class TestGenericRepository(IGenericReader reader, IGenericWriter writer) : GenericRepository<User>(reader, writer); public class TestGenericRepository(IGenericReader reader, IGenericWriter writer) : GenericRepository<User>(reader, writer);
}

View File

@@ -7,8 +7,8 @@ using Infrastructure.Database.Users.Repositories;
using VisaApi.Fakers.Users; using VisaApi.Fakers.Users;
using Xunit; using Xunit;
namespace VisaApi.Tests.Infrastructure.Database.Repositories namespace VisaApi.Tests.Infrastructure.Database.Repositories;
{
[Collection(Collections.ContextUsingTestCollection)] [Collection(Collections.ContextUsingTestCollection)]
public class UsersRepositoryTests public class UsersRepositoryTests
{ {
@@ -89,4 +89,3 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories
result.Should().Contain(users).And.HaveSameCount(users); result.Should().Contain(users).And.HaveSameCount(users);
} }
} }
}

View File

@@ -11,8 +11,8 @@ using VisaApi.Fakers.VisaApplications;
using VisaApi.Services; using VisaApi.Services;
using Xunit; using Xunit;
namespace VisaApi.Tests.Infrastructure.Database.Repositories namespace VisaApi.Tests.Infrastructure.Database.Repositories;
{
[Collection(Collections.ContextUsingTestCollection)] [Collection(Collections.ContextUsingTestCollection)]
public class VisaApplicationsRepositoryTests public class VisaApplicationsRepositoryTests
{ {
@@ -263,4 +263,3 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories
result.Should().Contain(applicationPending).And.HaveCount(1); result.Should().Contain(applicationPending).And.HaveCount(1);
} }
} }
}