Files
work-club-manager/backend/WorkClub.Tests.Integration/Infrastructure/IntegrationTestBase.cs
WorkClub Automation 1a5d5e8651 style(backend): apply dotnet format whitespace normalization
- Applied dotnet format to 24 files in backend/
- Corrects spacing, indentation, and formatting consistency
- No functional changes to code logic

Ultraworked with Sisyphus <https://github.com/code-yeongyu/oh-my-opencode>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-03-05 11:07:19 +01:00

42 lines
1.4 KiB
C#

using System.Text.Json;
namespace WorkClub.Tests.Integration.Infrastructure;
public abstract class IntegrationTestBase : IClassFixture<CustomWebApplicationFactory<Program>>, IAsyncLifetime
{
protected readonly HttpClient Client;
protected readonly CustomWebApplicationFactory<Program> Factory;
protected IntegrationTestBase(CustomWebApplicationFactory<Program> factory)
{
Factory = factory;
Client = factory.CreateClient();
}
protected void AuthenticateAs(string email, Dictionary<string, string> clubs, string? userId = null)
{
var clubsJson = JsonSerializer.Serialize(clubs);
Client.DefaultRequestHeaders.Remove("X-Test-Clubs");
Client.DefaultRequestHeaders.Add("X-Test-Clubs", clubsJson);
Client.DefaultRequestHeaders.Remove("X-Test-Email");
Client.DefaultRequestHeaders.Add("X-Test-Email", email);
if (!string.IsNullOrEmpty(userId))
{
Client.DefaultRequestHeaders.Remove("X-Test-UserId");
Client.DefaultRequestHeaders.Add("X-Test-UserId", userId);
}
}
protected void SetTenant(string tenantId)
{
Client.DefaultRequestHeaders.Remove("X-Tenant-Id");
Client.DefaultRequestHeaders.Add("X-Tenant-Id", tenantId);
}
public virtual Task InitializeAsync() => Task.CompletedTask;
public virtual Task DisposeAsync() => Task.CompletedTask;
}