persistence/DD.Persistence.IntegrationTests/BaseIntegrationTest.cs

27 lines
719 B
C#
Raw Normal View History

using Microsoft.Extensions.DependencyInjection;
using DD.Persistence.Database;
using DD.Persistence.Database.Model;
using Xunit;
namespace DD.Persistence.IntegrationTests;
2024-12-10 10:43:12 +05:00
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();
2024-12-10 10:43:12 +05:00
GC.SuppressFinalize(this);
}
}