refactor (readonly for static objects in tests and file-scoped namespaces
This commit is contained in:
@@ -1,13 +1,12 @@
|
|||||||
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]*$");
|
||||||
|
|
||||||
public readonly static Regex EnglishPhraseRegex = new(@"^[a-zA-Z №0-9;,\-_+=#*']*$");
|
public readonly static Regex EnglishPhraseRegex = new(@"^[a-zA-Z №0-9;,\-_+=#*']*$");
|
||||||
|
|
||||||
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}$");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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!;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,15 @@
|
|||||||
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
|
||||||
|
public class ChangeAuthData
|
||||||
{
|
{
|
||||||
/// Auth data with nullable password for making change auth data requests
|
|
||||||
public class ChangeAuthData
|
|
||||||
{
|
|
||||||
[Required]
|
[Required]
|
||||||
[MaxLength(ConfigurationConstraints.EmailLength)]
|
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||||
public string Email { get; set; } = null!;
|
public string Email { get; set; } = null!;
|
||||||
|
|
||||||
[MaxLength(ConfigurationConstraints.PasswordLength)]
|
[MaxLength(ConfigurationConstraints.PasswordLength)]
|
||||||
public string? Password { get; set; }
|
public string? Password { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
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
|
||||||
[Required]
|
[Required]
|
||||||
public Guid Id { get; private set; } = Guid.NewGuid();
|
public Guid Id { get; private set; } = Guid.NewGuid();
|
||||||
@@ -12,5 +12,4 @@ namespace ApplicationLayer.Services.Users.Models
|
|||||||
[Required]
|
[Required]
|
||||||
[MaxLength(ConfigurationConstraints.EmailLength)]
|
[MaxLength(ConfigurationConstraints.EmailLength)]
|
||||||
public string Email { get; set; } = null!;
|
public string Email { get; set; } = null!;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
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()
|
||||||
{
|
{
|
||||||
RuleFor(r => r.UserId)
|
RuleFor(r => r.UserId)
|
||||||
@@ -20,5 +20,4 @@ namespace ApplicationLayer.Services.Users.Requests.Validation
|
|||||||
.MaximumLength(ConfigurationConstraints.EmailLength)
|
.MaximumLength(ConfigurationConstraints.EmailLength)
|
||||||
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
|
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
|
||||||
@@ -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.");
|
||||||
}
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
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]*$");
|
||||||
|
|
||||||
public readonly static Regex EnglishPhraseRegex = new(@"^[a-z A-Z№0-9?><;,{}[\]\-_+=!@#$%\^&*|']*$");
|
public readonly static Regex EnglishPhraseRegex = new(@"^[a-z A-Z№0-9?><;,{}[\]\-_+=!@#$%\^&*|']*$");
|
||||||
@@ -16,5 +16,4 @@ namespace BlazorWebAssemblyVisaApiClient
|
|||||||
public const string ApplicantRole = "Applicant";
|
public const string ApplicantRole = "Applicant";
|
||||||
public const string ApprovingAuthorityRole = "ApprovingAuthority";
|
public const string ApprovingAuthorityRole = "ApprovingAuthority";
|
||||||
public const string AdminRole = "Admin";
|
public const string AdminRole = "Admin";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,10 @@ 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()
|
||||||
{
|
{
|
||||||
CreateMap<RegisterApplicantRequestModel, RegisterApplicantRequest>(MemberList.Destination);
|
CreateMap<RegisterApplicantRequestModel, RegisterApplicantRequest>(MemberList.Destination);
|
||||||
@@ -15,5 +15,4 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.AutoMapper.Profiles
|
|||||||
|
|
||||||
CreateMap<PlaceOfWorkModel, VisaApiClient.PlaceOfWorkModel>(MemberList.Destination);
|
CreateMap<PlaceOfWorkModel, VisaApiClient.PlaceOfWorkModel>(MemberList.Destination);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,12 @@
|
|||||||
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()
|
||||||
{
|
{
|
||||||
CreateMap<VisaApplicationCreateRequestModel, VisaApplicationCreateRequest>(MemberList.Destination);
|
CreateMap<VisaApplicationCreateRequestModel, VisaApplicationCreateRequest>(MemberList.Destination);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
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)
|
||||||
{
|
{
|
||||||
var enumMembers = value.GetType().GetMembers();
|
var enumMembers = value.GetType().GetMembers();
|
||||||
@@ -14,5 +14,4 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
|
|||||||
var displayName = displayAttribute?.Name ?? value.ToString();
|
var displayName = displayAttribute?.Name ?? value.ToString();
|
||||||
return displayName;
|
return displayName;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
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)
|
||||||
=> ErrorsToString(validationResult.Errors.Select(e => e.ErrorMessage));
|
=> ErrorsToString(validationResult.Errors.Select(e => e.ErrorMessage));
|
||||||
|
|
||||||
@@ -18,5 +18,4 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Helpers
|
|||||||
|
|
||||||
return stringBuilder.ToString();
|
return stringBuilder.ToString();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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");
|
||||||
}
|
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
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; }
|
||||||
|
|
||||||
public Action? OnRoleChanged { get; set; }
|
public Action? OnRoleChanged { get; set; }
|
||||||
@@ -11,5 +11,4 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
|
|||||||
public Task<ApplicantModel> GetApplicant();
|
public Task<ApplicantModel> GetApplicant();
|
||||||
|
|
||||||
public void UpdateCurrentRole();
|
public void UpdateCurrentRole();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,10 @@ 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();
|
||||||
|
|
||||||
public string? CurrentRole { get; private set; }
|
public string? CurrentRole { get; private set; }
|
||||||
@@ -49,5 +49,4 @@ namespace BlazorWebAssemblyVisaApiClient.Infrastructure.Services.UserDataProvide
|
|||||||
OnRoleChanged?.Invoke();
|
OnRoleChanged?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
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
|
||||||
|
public class PlaceOfWorkModel
|
||||||
{
|
{
|
||||||
/// Model of place of work with attributes required for validation to work
|
|
||||||
public class PlaceOfWorkModel
|
|
||||||
{
|
|
||||||
[Required]
|
[Required]
|
||||||
[StringLength(ConfigurationConstraints.PlaceOfWorkNameLength, MinimumLength = 1)]
|
[StringLength(ConfigurationConstraints.PlaceOfWorkNameLength, MinimumLength = 1)]
|
||||||
public string Name { get; set; } = default!;
|
public string Name { get; set; } = default!;
|
||||||
@@ -17,5 +17,4 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
|
|||||||
[Required]
|
[Required]
|
||||||
[StringLength(ConfigurationConstraints.PhoneNumberLength, MinimumLength = ConfigurationConstraints.PhoneNumberMinLength)]
|
[StringLength(ConfigurationConstraints.PhoneNumberLength, MinimumLength = ConfigurationConstraints.PhoneNumberMinLength)]
|
||||||
public string PhoneNum { get; set; } = default!;
|
public string PhoneNum { get; set; } = default!;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,11 @@ 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
|
||||||
|
public class RegisterApplicantRequestModel
|
||||||
{
|
{
|
||||||
/// Model of request with attributes required for validation to work
|
|
||||||
public class RegisterApplicantRequestModel
|
|
||||||
{
|
|
||||||
[Required]
|
[Required]
|
||||||
[ValidateComplexType]
|
[ValidateComplexType]
|
||||||
public RegisterRequestModel RegisterRequest { get; set; } = new();
|
public RegisterRequestModel RegisterRequest { get; set; } = new();
|
||||||
@@ -64,5 +64,4 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Applicants.Models
|
|||||||
public PlaceOfWorkModel PlaceOfWork { get; set; } = new();
|
public PlaceOfWorkModel PlaceOfWork { get; set; } = new();
|
||||||
|
|
||||||
public bool IsNonResident { get; set; }
|
public bool IsNonResident { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
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
|
||||||
|
public class RegisterRequestModel
|
||||||
{
|
{
|
||||||
/// Model of request with attributes required for validation to work
|
|
||||||
public class RegisterRequestModel
|
|
||||||
{
|
|
||||||
[Required]
|
[Required]
|
||||||
[ValidateComplexType]
|
[ValidateComplexType]
|
||||||
public AuthData AuthData { get; set; } = new AuthData();
|
public AuthData AuthData { get; set; } = new AuthData();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
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()
|
||||||
{
|
{
|
||||||
RuleFor(r => r.NewAuthData)
|
RuleFor(r => r.NewAuthData)
|
||||||
@@ -17,5 +17,4 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.Auth
|
|||||||
.MaximumLength(ConfigurationConstraints.EmailLength)
|
.MaximumLength(ConfigurationConstraints.EmailLength)
|
||||||
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
|
.WithMessage($"Email address length must be less than {ConfigurationConstraints.EmailLength}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
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
|
||||||
|
public class VisaApplicationCreateRequestModel
|
||||||
{
|
{
|
||||||
/// Model for request for data annotations validation to work
|
|
||||||
public class VisaApplicationCreateRequestModel
|
|
||||||
{
|
|
||||||
[ValidateComplexType]
|
[ValidateComplexType]
|
||||||
public ReentryPermitModel? ReentryPermit { get; set; } = default!;
|
public ReentryPermitModel? ReentryPermit { get; set; } = default!;
|
||||||
|
|
||||||
@@ -34,5 +34,4 @@ namespace BlazorWebAssemblyVisaApiClient.Validation.VisaApplications.Models
|
|||||||
|
|
||||||
[ValidateComplexType]
|
[ValidateComplexType]
|
||||||
public List<PastVisitModel> PastVisits { get; set; } = [];
|
public List<PastVisitModel> PastVisits { get; set; } = [];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
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; }
|
||||||
|
|
||||||
protected Task<HttpRequestMessage> CreateHttpRequestMessageAsync(CancellationToken cancellationToken)
|
protected Task<HttpRequestMessage> CreateHttpRequestMessageAsync(CancellationToken cancellationToken)
|
||||||
@@ -26,5 +26,4 @@ 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;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,13 @@ using Bogus;
|
|||||||
using Domains;
|
using Domains;
|
||||||
using Domains.ApplicantDomain;
|
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.Citizenship, f => f.Address.Country());
|
||||||
@@ -62,5 +62,4 @@ namespace VisaApi.Fakers.Applicants
|
|||||||
PhoneNum = f.Phone.PhoneNumber()
|
PhoneNum = f.Phone.PhoneNumber()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
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()
|
||||||
{
|
{
|
||||||
RuleFor(m => m.FirstName, f => f.Name.FirstName());
|
RuleFor(m => m.FirstName, f => f.Name.FirstName());
|
||||||
@@ -13,5 +13,4 @@ namespace VisaApi.Fakers.Applicants.Requests
|
|||||||
|
|
||||||
RuleFor(m => m.Patronymic, f => f.Name.FirstName());
|
RuleFor(m => m.Patronymic, f => f.Name.FirstName());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,10 +3,10 @@ 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)
|
||||||
{
|
{
|
||||||
RuleFor(m => m.Issuer, f => f.Company.CompanyName());
|
RuleFor(m => m.Issuer, f => f.Company.CompanyName());
|
||||||
@@ -20,5 +20,4 @@ namespace VisaApi.Fakers.Applicants.Requests
|
|||||||
RuleFor(m => m.IssueDate,
|
RuleFor(m => m.IssueDate,
|
||||||
f => f.Date.Past(4, dateTimeProvider.Now()));
|
f => f.Date.Past(4, dateTimeProvider.Now()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@ 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()
|
||||||
{
|
{
|
||||||
RuleFor(m => m.Name, f => f.Company.CompanyName());
|
RuleFor(m => m.Name, f => f.Company.CompanyName());
|
||||||
@@ -21,5 +21,4 @@ namespace VisaApi.Fakers.Applicants.Requests
|
|||||||
Building = f.Address.BuildingNumber()
|
Building = f.Address.BuildingNumber()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
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()
|
||||||
{
|
{
|
||||||
RuleFor(a => a.Email, f => f.Internet.Email());
|
RuleFor(a => a.Email, f => f.Internet.Email());
|
||||||
|
|
||||||
RuleFor(a => a.Password, f => f.Internet.Password());
|
RuleFor(a => a.Password, f => f.Internet.Password());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
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();
|
||||||
|
|
||||||
public RegisterRequestFaker()
|
public RegisterRequestFaker()
|
||||||
{
|
{
|
||||||
RuleFor(r => r.AuthData, () => authDataFaker.Generate());
|
RuleFor(r => r.AuthData, () => authDataFaker.Generate());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
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()
|
||||||
{
|
{
|
||||||
RuleFor(a => a.Email, f => f.Internet.Email());
|
RuleFor(a => a.Email, f => f.Internet.Email());
|
||||||
|
|
||||||
RuleFor(a => a.Password, f => f.Internet.Password());
|
RuleFor(a => a.Password, f => f.Internet.Password());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,15 +2,14 @@
|
|||||||
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();
|
||||||
|
|
||||||
public ChangeUserAuthDataRequestFaker()
|
public ChangeUserAuthDataRequestFaker()
|
||||||
{
|
{
|
||||||
CustomInstantiator(_ => new(Guid.NewGuid(), changeAuthDataFaker.Generate()));
|
CustomInstantiator(_ => new(Guid.NewGuid(), changeAuthDataFaker.Generate()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
using Bogus;
|
using Bogus;
|
||||||
using Domains.Users;
|
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.Email, f => f.Internet.Email());
|
||||||
|
|
||||||
RuleFor(u => u.Password, f => f.Internet.Password());
|
RuleFor(u => u.Password, f => f.Internet.Password());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
using Bogus;
|
using Bogus;
|
||||||
using Domains.VisaApplicationDomain;
|
using Domains.VisaApplicationDomain;
|
||||||
|
|
||||||
namespace VisaApi.Fakers.VisaApplications
|
namespace VisaApi.Fakers.VisaApplications;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates past visas
|
||||||
|
/// </summary>
|
||||||
|
public sealed class PastVisaFaker : Faker<PastVisa>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Generates past visas
|
|
||||||
/// </summary>
|
|
||||||
public sealed class PastVisaFaker : Faker<PastVisa>
|
|
||||||
{
|
|
||||||
private IDateTimeProvider dateTimeProvider;
|
private IDateTimeProvider dateTimeProvider;
|
||||||
|
|
||||||
public PastVisaFaker(IDateTimeProvider dateTimeProvider)
|
public PastVisaFaker(IDateTimeProvider dateTimeProvider)
|
||||||
@@ -25,5 +25,4 @@ namespace VisaApi.Fakers.VisaApplications
|
|||||||
result.ExpirationDate = result.IssueDate.AddDays(Random.Shared.Next(1, 11));
|
result.ExpirationDate = result.IssueDate.AddDays(Random.Shared.Next(1, 11));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
using Bogus;
|
using Bogus;
|
||||||
using Domains.VisaApplicationDomain;
|
using Domains.VisaApplicationDomain;
|
||||||
|
|
||||||
namespace VisaApi.Fakers.VisaApplications
|
namespace VisaApi.Fakers.VisaApplications;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates past visas
|
||||||
|
/// </summary>
|
||||||
|
public sealed class PastVisitFaker : Faker<PastVisit>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Generates past visas
|
|
||||||
/// </summary>
|
|
||||||
public sealed class PastVisitFaker : Faker<PastVisit>
|
|
||||||
{
|
|
||||||
private IDateTimeProvider dateTimeProvider;
|
private IDateTimeProvider dateTimeProvider;
|
||||||
|
|
||||||
public PastVisitFaker(IDateTimeProvider dateTimeProvider)
|
public PastVisitFaker(IDateTimeProvider dateTimeProvider)
|
||||||
@@ -25,5 +25,4 @@ namespace VisaApi.Fakers.VisaApplications
|
|||||||
result.EndDate = result.StartDate.AddDays(Random.Shared.Next(1, 11));
|
result.EndDate = result.StartDate.AddDays(Random.Shared.Next(1, 11));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
using Bogus;
|
using Bogus;
|
||||||
using Domains.VisaApplicationDomain;
|
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.Issuer, f => f.Company.CompanyName());
|
||||||
@@ -16,5 +16,4 @@ namespace VisaApi.Fakers.VisaApplications
|
|||||||
RuleFor(p => p.ExpirationDate,
|
RuleFor(p => p.ExpirationDate,
|
||||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,13 @@ using Bogus;
|
|||||||
using Domains;
|
using Domains;
|
||||||
using Domains.VisaApplicationDomain;
|
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,
|
RuleFor(p => p.Number,
|
||||||
@@ -18,5 +18,4 @@ namespace VisaApi.Fakers.VisaApplications
|
|||||||
RuleFor(p => p.ExpirationDate,
|
RuleFor(p => p.ExpirationDate,
|
||||||
f => f.Date.Future(4, dateTimeProvider.Now()));
|
f => f.Date.Future(4, dateTimeProvider.Now()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,13 @@ using Domains;
|
|||||||
using Domains.ApplicantDomain;
|
using Domains.ApplicantDomain;
|
||||||
using Domains.VisaApplicationDomain;
|
using Domains.VisaApplicationDomain;
|
||||||
|
|
||||||
namespace VisaApi.Fakers.VisaApplications
|
namespace VisaApi.Fakers.VisaApplications;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates visa applications
|
||||||
|
/// </summary>
|
||||||
|
public sealed class VisaApplicationFaker : Faker<VisaApplication>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Generates visa applications
|
|
||||||
/// </summary>
|
|
||||||
public sealed class VisaApplicationFaker : Faker<VisaApplication>
|
|
||||||
{
|
|
||||||
private static ReentryPermitFaker reentryPermitFaker = null!;
|
private static ReentryPermitFaker reentryPermitFaker = null!;
|
||||||
private static PermissionToDestCountryFaker permissionToDestCountryFaker = null!;
|
private static PermissionToDestCountryFaker permissionToDestCountryFaker = null!;
|
||||||
|
|
||||||
@@ -61,5 +61,4 @@ namespace VisaApi.Fakers.VisaApplications
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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 readonly static IValidator<NameModel> validator = new NameModelValidator();
|
||||||
{
|
private readonly static NameModelFaker faker = new();
|
||||||
private static IValidator<NameModel> validator = new NameModelValidator();
|
|
||||||
private 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
|
||||||
@@ -167,5 +167,4 @@ namespace VisaApi.Tests.Application.Validation.Applicants
|
|||||||
|
|
||||||
result.Errors.Should().BeEmpty();
|
result.Errors.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 readonly static IDateTimeProvider dateTimeProvider = new TestDateTimeProvider();
|
||||||
{
|
private readonly static IValidator<PassportModel> validator = new PassportModelValidator(dateTimeProvider);
|
||||||
private static IDateTimeProvider dateTimeProvider = new TestDateTimeProvider();
|
private readonly static PassportModelFaker faker = new(dateTimeProvider);
|
||||||
private static IValidator<PassportModel> validator = new PassportModelValidator(dateTimeProvider);
|
|
||||||
private 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
|
||||||
@@ -171,5 +171,4 @@ namespace VisaApi.Tests.Application.Validation.Applicants
|
|||||||
|
|
||||||
result.Errors.Should().BeEmpty();
|
result.Errors.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 readonly static IValidator<PlaceOfWorkModel> validator = new PlaceOfWorkModelValidator();
|
||||||
{
|
private readonly static PlaceOfWorkModelFaker faker = new();
|
||||||
private static IValidator<PlaceOfWorkModel> validator = new PlaceOfWorkModelValidator();
|
|
||||||
private 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
|
||||||
@@ -350,5 +350,4 @@ namespace VisaApi.Tests.Application.Validation.Applicants
|
|||||||
|
|
||||||
result.Errors.Should().BeEmpty();
|
result.Errors.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ 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();
|
||||||
private readonly static AuthDataFaker faker = new();
|
private readonly static AuthDataFaker faker = new();
|
||||||
|
|
||||||
@@ -110,5 +110,4 @@ namespace VisaApi.Tests.Application.Validation.Auth
|
|||||||
result.Errors.Where(error => error.PropertyName == nameof(authData.Password))
|
result.Errors.Where(error => error.PropertyName == nameof(authData.Password))
|
||||||
.Should().BeEmpty();
|
.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,11 +11,11 @@ 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)]
|
||||||
|
public class RegisterRequestValidatorTests
|
||||||
{
|
{
|
||||||
[Collection(Collections.ContextUsingTestCollection)]
|
|
||||||
public class RegisterRequestValidatorTests
|
|
||||||
{
|
|
||||||
private readonly static IValidator<AuthData> authDataValidator = new AuthDataValidator();
|
private readonly static IValidator<AuthData> authDataValidator = new AuthDataValidator();
|
||||||
private readonly static RegisterRequestFaker requestFaker = new();
|
private readonly static RegisterRequestFaker requestFaker = new();
|
||||||
private readonly static UserFaker userFaker = new();
|
private readonly static UserFaker userFaker = new();
|
||||||
@@ -90,5 +90,4 @@ namespace VisaApi.Tests.Application.Validation.Auth
|
|||||||
|
|
||||||
result.Errors.Should().BeEmpty();
|
result.Errors.Should().BeEmpty();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@ 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();
|
||||||
private readonly static ChangeUserAuthDataRequestFaker faker = new();
|
private readonly static ChangeUserAuthDataRequestFaker faker = new();
|
||||||
|
|
||||||
@@ -45,5 +45,4 @@ namespace VisaApi.Tests.Application.Validation.Users
|
|||||||
|
|
||||||
result.IsValid.Should().BeTrue();
|
result.IsValid.Should().BeTrue();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
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>()
|
||||||
.UseInMemoryDatabase("VisaApiDB")
|
.UseInMemoryDatabase("VisaApiDB")
|
||||||
.ConfigureWarnings(b => b.Ignore(InMemoryEventId.TransactionIgnoredWarning))
|
.ConfigureWarnings(b => b.Ignore(InMemoryEventId.TransactionIgnoredWarning))
|
||||||
@@ -20,5 +20,4 @@ namespace VisaApi.Tests.Infrastructure.Database
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -9,11 +9,11 @@ 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)]
|
||||||
|
public class ApplicantsRepositoryTests
|
||||||
{
|
{
|
||||||
[Collection(Collections.ContextUsingTestCollection)]
|
|
||||||
public class ApplicantsRepositoryTests
|
|
||||||
{
|
|
||||||
private readonly static UserFaker userFaker = new();
|
private readonly static UserFaker userFaker = new();
|
||||||
private readonly static ApplicantFaker applicantFaker = new(GetDateTimeProvider());
|
private readonly static ApplicantFaker applicantFaker = new(GetDateTimeProvider());
|
||||||
|
|
||||||
@@ -151,5 +151,4 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories
|
|||||||
|
|
||||||
result.Should().Be(applicant.IsNonResident);
|
result.Should().Be(applicant.IsNonResident);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -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);
|
||||||
}
|
|
||||||
@@ -7,11 +7,11 @@ 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)]
|
||||||
|
public class UsersRepositoryTests
|
||||||
{
|
{
|
||||||
[Collection(Collections.ContextUsingTestCollection)]
|
|
||||||
public class UsersRepositoryTests
|
|
||||||
{
|
|
||||||
private readonly static UserFaker userFaker = new();
|
private readonly static UserFaker userFaker = new();
|
||||||
|
|
||||||
/// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary>
|
/// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary>
|
||||||
@@ -88,5 +88,4 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories
|
|||||||
|
|
||||||
result.Should().Contain(users).And.HaveSameCount(users);
|
result.Should().Contain(users).And.HaveSameCount(users);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,11 +11,11 @@ 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)]
|
||||||
|
public class VisaApplicationsRepositoryTests
|
||||||
{
|
{
|
||||||
[Collection(Collections.ContextUsingTestCollection)]
|
|
||||||
public class VisaApplicationsRepositoryTests
|
|
||||||
{
|
|
||||||
private readonly static UserFaker userFaker = new();
|
private readonly static UserFaker userFaker = new();
|
||||||
private readonly static ApplicantFaker applicantFaker = new(GetDateTimeProvider());
|
private readonly static ApplicantFaker applicantFaker = new(GetDateTimeProvider());
|
||||||
private readonly static VisaApplicationFaker applicationFaker = new(GetDateTimeProvider());
|
private readonly static VisaApplicationFaker applicationFaker = new(GetDateTimeProvider());
|
||||||
@@ -262,5 +262,4 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories
|
|||||||
|
|
||||||
result.Should().Contain(applicationPending).And.HaveCount(1);
|
result.Should().Contain(applicationPending).And.HaveCount(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user