mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Replaces reflection-based repository instantiation with unit of work property accessors
This commit is contained in:
1 parent
4fa9eb6e26
commit
fee14afb89
87 files changed
+541
-735
No files matched your search
+5
-9
@@ -1,11 +1,8 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.DataAccess.Repositories.Books;
|
||||
using Lumina.Application.Common.DataAccess.UoW;
|
||||
using Lumina.Application.Common.Infrastructure.Authentication;
|
||||
using Lumina.Application.Common.Infrastructure.Time;
|
||||
using Lumina.DataAccess.Common.DependencyInjection;
|
||||
using Lumina.DataAccess.Core.Repositories.Books;
|
||||
using Lumina.DataAccess.Core.Repositories.Common.Factory;
|
||||
using Lumina.DataAccess.Core.UoW;
|
||||
using Lumina.DataAccess.UnitTests.Common.Setup;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -36,8 +33,6 @@ public class DataAccessLayerServicesTests
|
||||
// Assert
|
||||
Assert.Contains(services, sd => sd.ServiceType == typeof(LuminaDbContext));
|
||||
Assert.Contains(services, sd => sd.ServiceType == typeof(IUnitOfWork) && sd.ImplementationType == typeof(UnitOfWork));
|
||||
Assert.Contains(services, sd => sd.ServiceType == typeof(IRepositoryFactory) && sd.ImplementationType == typeof(RepositoryFactory));
|
||||
Assert.Contains(services, sd => sd.ServiceType == typeof(IBookRepository) && sd.ImplementationType == typeof(BookRepository));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -62,7 +57,7 @@ public class DataAccessLayerServicesTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddDataAccessLayerServices_WhenCalled_ShouldRegisterRepositories()
|
||||
public void AddDataAccessLayerServices_WhenCalled_ShouldExposeRepositoriesThroughUnitOfWork()
|
||||
{
|
||||
// Arrange
|
||||
ServiceCollection services = new();
|
||||
@@ -72,11 +67,12 @@ public class DataAccessLayerServicesTests
|
||||
|
||||
services.AddTransient<ICurrentUserService, TestCurrentUserService>();
|
||||
services.AddTransient<IDateTimeProvider, TestDateTimeProvider>();
|
||||
|
||||
|
||||
ServiceProvider serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
// Assert
|
||||
IBookRepository? repository = serviceProvider.GetService<IBookRepository>();
|
||||
Assert.NotNull(repository);
|
||||
IUnitOfWork unitOfWork = serviceProvider.GetRequiredService<IUnitOfWork>();
|
||||
Assert.NotNull(unitOfWork.BookRepository);
|
||||
Assert.NotNull(unitOfWork.PermissionRepository);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user