This commit introduces a using directive for `System.Reflection` in `DbRepositoryTests.cs` to support reflection features. The `Setup` method is updated to include `AddAutoMapper`, ensuring AutoMapper services are registered for dependency injection in the test environment.
36 lines
892 B
C#
36 lines
892 B
C#
namespace DigitalData.Core.Tests.Infrastructure;
|
|
|
|
using Bogus;
|
|
using DigitalData.Core.Infrastructure;
|
|
using DigitalData.Core.Tests.Mock;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.Reflection;
|
|
|
|
public class DbRepositoryTests
|
|
{
|
|
private IHost _host;
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
var builder = Host.CreateApplicationBuilder();
|
|
|
|
builder.Services.AddDbContext<MockDbContext>(opt => opt.UseInMemoryDatabase("MockDB"));
|
|
|
|
builder.Services.AddDbRepository<MockDbContext, User>(context => context.Users);
|
|
|
|
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());
|
|
|
|
_host = builder.Build();
|
|
}
|
|
|
|
[TearDown]
|
|
public void TearDown()
|
|
{
|
|
if (_host is IDisposable disposableHost)
|
|
disposableHost.Dispose();
|
|
}
|
|
}
|