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:
@@ -1,5 +1,9 @@
|
||||
namespace DigitalData.Core.Tests.Infrastructure;
|
||||
|
||||
using DigitalData.Core.Infrastructure;
|
||||
using DigitalData.Core.Tests.Mock;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
public class DbRepositoryTests
|
||||
@@ -11,6 +15,10 @@ public class DbRepositoryTests
|
||||
{
|
||||
var builder = Host.CreateApplicationBuilder();
|
||||
|
||||
builder.Services.AddDbContext<MockDbContext>(opt => opt.UseInMemoryDatabase("MockDB"));
|
||||
|
||||
builder.Services.AddDbRepository<MockDbContext, User>(context => context.Users);
|
||||
|
||||
_host = builder.Build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user