namespace ColaFlow.Modules.Identity.IntegrationTests.Infrastructure;
///
/// Database Fixture for In-Memory Database Tests
/// Implements IClassFixture for xUnit test lifecycle management
/// Each test class gets its own isolated database instance
///
public class DatabaseFixture : IDisposable
{
public ColaFlowWebApplicationFactory Factory { get; } = new(useInMemoryDatabase: true);
// Note: Client property is kept for backward compatibility but creates new instances
// Tests should call CreateClient() for isolation to avoid shared state issues
public HttpClient Client => CreateClient();
// Use In-Memory Database for fast, isolated tests
///
/// Creates a new HttpClient for each test to ensure test isolation
/// Prevents Authorization header sharing between tests
///
public HttpClient CreateClient()
{
return Factory.CreateClient();
}
public void Dispose()
{
Factory?.Dispose();
GC.SuppressFinalize(this);
}
}