refactor (readonly for static objects in tests and file-scoped namespaces
This commit is contained in:
		| @@ -7,25 +7,25 @@ using Infrastructure.Database.Users.Repositories; | ||||
| using VisaApi.Fakers.Users; | ||||
| 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(); | ||||
|  | ||||
|     /// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary> | ||||
|     /// <param name="context"> Database context </param> | ||||
|     /// <returns>Repository</returns> | ||||
|     private static IUsersRepository GetRepository(DbContext context) | ||||
|         => new UsersRepository(context, context); | ||||
|  | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="IUsersRepository.FindByEmailAsync"/> method that should return null for not existing email | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task FindByEmailForNotExistingShouldReturnNull() | ||||
|     { | ||||
|         private readonly static UserFaker userFaker = new(); | ||||
|  | ||||
|         /// <summary> Returns <see cref="IVisaApplicationsRepository"/> </summary> | ||||
|         /// <param name="context"> Database context </param> | ||||
|         /// <returns>Repository</returns> | ||||
|         private static IUsersRepository GetRepository(DbContext context) | ||||
|             => new UsersRepository(context, context); | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="IUsersRepository.FindByEmailAsync"/> method that should return null for not existing email | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task FindByEmailForNotExistingShouldReturnNull() | ||||
|         { | ||||
|             await using var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var repository = GetRepository(context); | ||||
|  | ||||
| @@ -34,12 +34,12 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories | ||||
|             result.Should().BeNull(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="IUsersRepository.FindByEmailAsync"/> method that should return entity for existing email | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task FindByEmailForExistingShouldReturnEntity() | ||||
|         { | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="IUsersRepository.FindByEmailAsync"/> method that should return entity for existing email | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task FindByEmailForExistingShouldReturnEntity() | ||||
|     { | ||||
|             await using var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var repository = GetRepository(context); | ||||
|             var user = userFaker.Generate(); | ||||
| @@ -51,12 +51,12 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories | ||||
|             result.Should().Be(user); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="IUsersRepository.GetAllOfRoleAsync"/> method that should return empty from empty db | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task GetAllOfRoleForEmptyShouldReturnEmpty() | ||||
|         { | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="IUsersRepository.GetAllOfRoleAsync"/> method that should return empty from empty db | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task GetAllOfRoleForEmptyShouldReturnEmpty() | ||||
|     { | ||||
|             await using var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var repository = GetRepository(context); | ||||
|  | ||||
| @@ -65,12 +65,12 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories | ||||
|             result.Should().BeEmpty(); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Test for <see cref="IUsersRepository.GetAllOfRoleAsync"/> method that should return entities from not empty db | ||||
|         /// </summary> | ||||
|         [Fact] | ||||
|         private async Task GetAllOfRoleForNotEmptyShouldReturnEntities() | ||||
|         { | ||||
|     /// <summary> | ||||
|     /// Test for <see cref="IUsersRepository.GetAllOfRoleAsync"/> method that should return entities from not empty db | ||||
|     /// </summary> | ||||
|     [Fact] | ||||
|     private async Task GetAllOfRoleForNotEmptyShouldReturnEntities() | ||||
|     { | ||||
|             await using var context = InMemoryContextProvider.GetDbContext(); | ||||
|             var repository = GetRepository(context); | ||||
|             var users = new List<User>(); | ||||
| @@ -88,5 +88,4 @@ namespace VisaApi.Tests.Infrastructure.Database.Repositories | ||||
|  | ||||
|             result.Should().Contain(users).And.HaveSameCount(users); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user