Backend (.NET 10): - EventFlow CQRS/Event Sourcing with PostgreSQL - GraphQL.NET API with mutations and queries - Custom ReadModelSqlGenerator for snake_case PostgreSQL columns - Hangfire for background job processing - Integration tests with isolated test databases Frontend (React/Vite): - Initial project structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using EventFlow;
|
|
using EventFlow.Aggregates;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Books.Api.Tests.Infrastructure;
|
|
|
|
/// <summary>
|
|
/// Base class for integration tests with isolated database per test class.
|
|
/// Uses IClassFixture pattern - each test class gets its own database.
|
|
/// </summary>
|
|
public abstract class IntegrationTestBase
|
|
: IClassFixture<TestWebApplicationFactory>, IDisposable
|
|
{
|
|
protected readonly TestWebApplicationFactory Factory;
|
|
protected readonly HttpClient Client;
|
|
private readonly IServiceScope _scope;
|
|
|
|
protected IntegrationTestBase(TestWebApplicationFactory factory)
|
|
{
|
|
Factory = factory;
|
|
Client = factory.CreateGraphQLClient();
|
|
_scope = factory.Services.CreateScope();
|
|
}
|
|
|
|
protected IServiceProvider Services => _scope.ServiceProvider;
|
|
|
|
protected ICommandBus CommandBus => Services.GetRequiredService<ICommandBus>();
|
|
protected IAggregateStore AggregateStore => Services.GetRequiredService<IAggregateStore>();
|
|
|
|
protected T GetService<T>() where T : notnull
|
|
=> Services.GetRequiredService<T>();
|
|
|
|
public void Dispose()
|
|
{
|
|
_scope?.Dispose();
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|