persistence/Persistence.IntegrationTests/BaseIntegrationTest.cs

28 lines
715 B
C#
Raw Normal View History

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
2024-12-10 11:27:22 +05:00
using Persistence.Database;
using Persistence.Database.Model;
using Xunit;
namespace Persistence.IntegrationTests;
public abstract class BaseIntegrationTest : IClassFixture<WebAppFactoryFixture>,
IDisposable
{
protected readonly IServiceScope scope;
protected readonly PersistenceDbContext dbContext;
protected BaseIntegrationTest(WebAppFactoryFixture factory)
{
scope = factory.Services.CreateScope();
dbContext = scope.ServiceProvider.GetRequiredService<PersistencePostgresContext>();
}
public void Dispose()
{
scope.Dispose();
dbContext.Dispose();
}
}