import { InMemoryLeagueRepository } from '../../../adapters/leagues/persistence/inmemory/InMemoryLeagueRepository'; import { InMemoryDriverRepository } from '../../../adapters/drivers/persistence/inmemory/InMemoryDriverRepository'; import { InMemoryEventPublisher } from '../../../adapters/events/InMemoryEventPublisher'; import { CreateLeagueUseCase } from '../../../core/leagues/application/use-cases/CreateLeagueUseCase'; import { GetLeagueUseCase } from '../../../core/leagues/application/use-cases/GetLeagueUseCase'; import { GetLeagueRosterUseCase } from '../../../core/leagues/application/use-cases/GetLeagueRosterUseCase'; import { JoinLeagueUseCase } from '../../../core/leagues/application/use-cases/JoinLeagueUseCase'; import { LeaveLeagueUseCase } from '../../../core/leagues/application/use-cases/LeaveLeagueUseCase'; import { ApproveMembershipRequestUseCase } from '../../../core/leagues/application/use-cases/ApproveMembershipRequestUseCase'; import { RejectMembershipRequestUseCase } from '../../../core/leagues/application/use-cases/RejectMembershipRequestUseCase'; import { PromoteMemberUseCase } from '../../../core/leagues/application/use-cases/PromoteMemberUseCase'; import { DemoteAdminUseCase } from '../../../core/leagues/application/use-cases/DemoteAdminUseCase'; import { RemoveMemberUseCase } from '../../../core/leagues/application/use-cases/RemoveMemberUseCase'; import { LeagueCreateCommand } from '../../../core/leagues/application/ports/LeagueCreateCommand'; export class LeaguesTestContext { public readonly leagueRepository: InMemoryLeagueRepository; public readonly driverRepository: InMemoryDriverRepository; public readonly eventPublisher: InMemoryEventPublisher; public readonly createLeagueUseCase: CreateLeagueUseCase; public readonly getLeagueUseCase: GetLeagueUseCase; public readonly getLeagueRosterUseCase: GetLeagueRosterUseCase; public readonly joinLeagueUseCase: JoinLeagueUseCase; public readonly leaveLeagueUseCase: LeaveLeagueUseCase; public readonly approveMembershipRequestUseCase: ApproveMembershipRequestUseCase; public readonly rejectMembershipRequestUseCase: RejectMembershipRequestUseCase; public readonly promoteMemberUseCase: PromoteMemberUseCase; public readonly demoteAdminUseCase: DemoteAdminUseCase; public readonly removeMemberUseCase: RemoveMemberUseCase; constructor() { this.leagueRepository = new InMemoryLeagueRepository(); this.driverRepository = new InMemoryDriverRepository(); this.eventPublisher = new InMemoryEventPublisher(); this.createLeagueUseCase = new CreateLeagueUseCase(this.leagueRepository, this.eventPublisher); this.getLeagueUseCase = new GetLeagueUseCase(this.leagueRepository, this.eventPublisher); this.getLeagueRosterUseCase = new GetLeagueRosterUseCase(this.leagueRepository, this.eventPublisher); this.joinLeagueUseCase = new JoinLeagueUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); this.leaveLeagueUseCase = new LeaveLeagueUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); this.approveMembershipRequestUseCase = new ApproveMembershipRequestUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); this.rejectMembershipRequestUseCase = new RejectMembershipRequestUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); this.promoteMemberUseCase = new PromoteMemberUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); this.demoteAdminUseCase = new DemoteAdminUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); this.removeMemberUseCase = new RemoveMemberUseCase(this.leagueRepository, this.driverRepository, this.eventPublisher); } public clear(): void { this.leagueRepository.clear(); this.driverRepository.clear(); this.eventPublisher.clear(); } public async createLeague(command: Partial = {}) { const defaultCommand: LeagueCreateCommand = { name: 'Test League', visibility: 'public', ownerId: 'driver-123', approvalRequired: false, lateJoinAllowed: false, bonusPointsEnabled: false, penaltiesEnabled: false, protestsEnabled: false, appealsEnabled: false, ...command, }; return await this.createLeagueUseCase.execute(defaultCommand); } }