refactor (readonly for static objects in tests and file-scoped namespaces
This commit is contained in:
		| @@ -11,32 +11,32 @@ using VisaApi.Fakers.Users; | ||||
| using VisaApi.Tests.Infrastructure.Database; | ||||
| using Xunit; | ||||
|  | ||||
| namespace VisaApi.Tests.Application.Validation.Auth | ||||
| { | ||||
|     [Collection(Collections.ContextUsingTestCollection)] | ||||
|     public class RegisterRequestValidatorTests | ||||
|     { | ||||
|         private readonly static IValidator<AuthData> authDataValidator = new AuthDataValidator(); | ||||
|         private readonly static RegisterRequestFaker requestFaker = new(); | ||||
|         private readonly static UserFaker userFaker = new(); | ||||
| namespace VisaApi.Tests.Application.Validation.Auth; | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Creates validator from context | ||||
|         /// </summary> | ||||
|         /// <param name="context">db context</param> | ||||
|         /// <returns>RegisterRequest validator</returns> | ||||
|         private static IValidator<RegisterRequest> GetValidator(DbContext context) | ||||
|         { | ||||
| [Collection(Collections.ContextUsingTestCollection)] | ||||
| public class RegisterRequestValidatorTests | ||||
| { | ||||
|     private readonly static IValidator<AuthData> authDataValidator = new AuthDataValidator(); | ||||
|     private readonly static RegisterRequestFaker requestFaker = new(); | ||||
|     private readonly static UserFaker userFaker = new(); | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Creates validator from context | ||||
|     /// </summary> | ||||
|     /// <param name="context">db context</param> | ||||
|     /// <returns>RegisterRequest validator</returns> | ||||
|     private static IValidator<RegisterRequest> GetValidator(DbContext context) | ||||
|     { | ||||
|             var repository = new UsersRepository(context, context); | ||||
|             return new RegisterRequestValidator(repository, authDataValidator); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="RegisterRequest"/> validator that should throw for empty auth data | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task ValidateForEmptyAuthDataShouldThrow() | ||||
|         { | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="RegisterRequest"/> validator that should throw for empty auth data | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task ValidateForEmptyAuthDataShouldThrow() | ||||
|     { | ||||
|             var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var validator = GetValidator(context); | ||||
|             var request = requestFaker.Generate(); | ||||
| @@ -55,12 +55,12 @@ namespace VisaApi.Tests.Application.Validation.Auth | ||||
|             result.Should().NotBeNull(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="RegisterRequest"/> validator that should return error for used email | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task ValidateForUsedEmailShouldReturnError() | ||||
|         { | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="RegisterRequest"/> validator that should return error for used email | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task ValidateForUsedEmailShouldReturnError() | ||||
|     { | ||||
|             var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var validator = GetValidator(context); | ||||
|             var user = userFaker.Generate(); | ||||
| @@ -76,12 +76,12 @@ namespace VisaApi.Tests.Application.Validation.Auth | ||||
|                 .And.HaveCount(1); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="RegisterRequest"/> validator that should return o errors for valid requests | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task ValidateForValidRequestShouldReturnNoErrors() | ||||
|         { | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="RegisterRequest"/> validator that should return o errors for valid requests | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task ValidateForValidRequestShouldReturnNoErrors() | ||||
|     { | ||||
|             var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var validator = GetValidator(context); | ||||
|             var request = requestFaker.Generate(); | ||||
| @@ -90,5 +90,4 @@ namespace VisaApi.Tests.Application.Validation.Auth | ||||
|  | ||||
|             result.Errors.Should().BeEmpty(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user