using AsbCloudDb.Model;
using Microsoft.Extensions.DependencyInjection;
using Xunit;

namespace AsbCloudWebApi.IntegrationTests;

public abstract class BaseIntegrationTest : IClassFixture<WebAppFactoryFixture>,
   IDisposable
{
   protected readonly IServiceScope scope;

   protected readonly AsbCloudDbContext dbContext;

   protected BaseIntegrationTest(WebAppFactoryFixture factory)
   {
      scope = factory.Services.CreateScope();
      
      dbContext = scope.ServiceProvider.GetRequiredService<AsbCloudDbContext>();
   }

   public void Dispose()
   {
      scope.Dispose();
      dbContext.Dispose();
   }
}