persistence/Persistence.IntegrationTests/BaseIntegrationTest.cs
ngfrolov 980d3100af
Добавил отдельный контекст не привязанный к конкретной БД.
Поправил скрипт инициализации.
Пересоздао миграции.
2024-11-26 15:07:18 +05:00

27 lines
676 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Persistence.Database.Model;
using Xunit;
namespace Persistence.IntegrationTests;
public abstract class BaseIntegrationTest : IClassFixture<WebAppFactoryFixture>,
IDisposable
{
protected readonly IServiceScope scope;
protected readonly DbContext dbContext;
protected BaseIntegrationTest(WebAppFactoryFixture factory)
{
scope = factory.Services.CreateScope();
dbContext = scope.ServiceProvider.GetRequiredService<PersistencePostgresContext>();
}
public void Dispose()
{
scope.Dispose();
dbContext.Dispose();
}
}