Update dependency injection and repository tests

Modified `AddDbRepository` method to allow broader entity types and registered `queryFactory` as a singleton. Added necessary using directives in `DbRepositoryTests.cs` and updated the `Setup` method to configure an in-memory database for testing with `MockDbContext` and `User` entity.
This commit is contained in:
Developer 02
2025-04-17 15:05:23 +02:00
parent 35050d65a8
commit 561a751de4
2 changed files with 9 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ public static class DependencyInjection
{
public static IServiceCollection AddDbRepository<TDbContext, TEntity>(this IServiceCollection services, Func<TDbContext, DbSet<TEntity>> queryFactory)
where TDbContext : DbContext
where TEntity : DbContext
where TEntity : class
{
return services
.AddScoped<IRepository<TEntity>, DbRepository<TDbContext, TEntity>>()