integration tests
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { InMemoryLeagueRepository } from '../../../adapters/leagues/persistence/inmemory/InMemoryLeagueRepository';
|
||||
import { InMemoryDriverRepository } from '../../../adapters/drivers/persistence/inmemory/InMemoryDriverRepository';
|
||||
import { InMemoryEventPublisher } from '../../../adapters/events/InMemoryEventPublisher';
|
||||
import type { Logger } from '../../../core/shared/domain/Logger';
|
||||
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';
|
||||
@@ -13,6 +14,32 @@ import { DemoteAdminUseCase } from '../../../core/leagues/application/use-cases/
|
||||
import { RemoveMemberUseCase } from '../../../core/leagues/application/use-cases/RemoveMemberUseCase';
|
||||
import { LeagueCreateCommand } from '../../../core/leagues/application/ports/LeagueCreateCommand';
|
||||
|
||||
import { getPointsSystems } from '../../../adapters/bootstrap/PointsSystems';
|
||||
import { InMemoryLeagueRepository as InMemoryRacingLeagueRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryLeagueRepository';
|
||||
import { InMemoryDriverRepository as InMemoryRacingDriverRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryDriverRepository';
|
||||
import { InMemoryRaceRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryRaceRepository';
|
||||
import { InMemoryResultRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryResultRepository';
|
||||
import { InMemorySeasonRepository } from '../../../adapters/racing/persistence/inmemory/InMemorySeasonRepository';
|
||||
import { InMemorySeasonSponsorshipRepository } from '../../../adapters/racing/persistence/inmemory/InMemorySeasonSponsorshipRepository';
|
||||
import { InMemoryRaceRegistrationRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryRaceRegistrationRepository';
|
||||
import { InMemoryLeagueMembershipRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryLeagueMembershipRepository';
|
||||
import { InMemoryStandingRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryStandingRepository';
|
||||
import { InMemoryPenaltyRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryPenaltyRepository';
|
||||
import { InMemoryProtestRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryProtestRepository';
|
||||
import { GetLeagueScheduleUseCase } from '../../../core/racing/application/use-cases/GetLeagueScheduleUseCase';
|
||||
import { CreateLeagueSeasonScheduleRaceUseCase } from '../../../core/racing/application/use-cases/CreateLeagueSeasonScheduleRaceUseCase';
|
||||
import { UpdateLeagueSeasonScheduleRaceUseCase } from '../../../core/racing/application/use-cases/UpdateLeagueSeasonScheduleRaceUseCase';
|
||||
import { DeleteLeagueSeasonScheduleRaceUseCase } from '../../../core/racing/application/use-cases/DeleteLeagueSeasonScheduleRaceUseCase';
|
||||
import { PublishLeagueSeasonScheduleUseCase } from '../../../core/racing/application/use-cases/PublishLeagueSeasonScheduleUseCase';
|
||||
import { UnpublishLeagueSeasonScheduleUseCase } from '../../../core/racing/application/use-cases/UnpublishLeagueSeasonScheduleUseCase';
|
||||
import { RegisterForRaceUseCase } from '../../../core/racing/application/use-cases/RegisterForRaceUseCase';
|
||||
import { WithdrawFromRaceUseCase } from '../../../core/racing/application/use-cases/WithdrawFromRaceUseCase';
|
||||
import { GetLeagueStandingsUseCase } from '../../../core/racing/application/use-cases/GetLeagueStandingsUseCase';
|
||||
import { InMemoryWalletRepository } from '../../../adapters/payments/persistence/inmemory/InMemoryWalletRepository';
|
||||
import { GetLeagueWalletUseCase } from '../../../core/racing/application/use-cases/GetLeagueWalletUseCase';
|
||||
import { WithdrawFromLeagueWalletUseCase } from '../../../core/racing/application/use-cases/WithdrawFromLeagueWalletUseCase';
|
||||
import { InMemoryTransactionRepository } from '../../../adapters/racing/persistence/inmemory/InMemoryTransactionRepository';
|
||||
|
||||
export class LeaguesTestContext {
|
||||
public readonly leagueRepository: InMemoryLeagueRepository;
|
||||
public readonly driverRepository: InMemoryDriverRepository;
|
||||
@@ -29,6 +56,35 @@ export class LeaguesTestContext {
|
||||
public readonly demoteAdminUseCase: DemoteAdminUseCase;
|
||||
public readonly removeMemberUseCase: RemoveMemberUseCase;
|
||||
|
||||
public readonly logger: Logger;
|
||||
public readonly racingLeagueRepository: InMemoryRacingLeagueRepository;
|
||||
public readonly seasonRepository: InMemorySeasonRepository;
|
||||
public readonly seasonSponsorshipRepository: InMemorySeasonSponsorshipRepository;
|
||||
public readonly raceRepository: InMemoryRaceRepository;
|
||||
public readonly resultRepository: InMemoryResultRepository;
|
||||
public readonly standingRepository: InMemoryStandingRepository;
|
||||
public readonly racingDriverRepository: InMemoryRacingDriverRepository;
|
||||
public readonly raceRegistrationRepository: InMemoryRaceRegistrationRepository;
|
||||
public readonly leagueMembershipRepository: InMemoryLeagueMembershipRepository;
|
||||
public readonly penaltyRepository: InMemoryPenaltyRepository;
|
||||
public readonly protestRepository: InMemoryProtestRepository;
|
||||
|
||||
public readonly getLeagueScheduleUseCase: GetLeagueScheduleUseCase;
|
||||
public readonly createLeagueSeasonScheduleRaceUseCase: CreateLeagueSeasonScheduleRaceUseCase;
|
||||
public readonly updateLeagueSeasonScheduleRaceUseCase: UpdateLeagueSeasonScheduleRaceUseCase;
|
||||
public readonly deleteLeagueSeasonScheduleRaceUseCase: DeleteLeagueSeasonScheduleRaceUseCase;
|
||||
public readonly publishLeagueSeasonScheduleUseCase: PublishLeagueSeasonScheduleUseCase;
|
||||
public readonly unpublishLeagueSeasonScheduleUseCase: UnpublishLeagueSeasonScheduleUseCase;
|
||||
public readonly registerForRaceUseCase: RegisterForRaceUseCase;
|
||||
public readonly withdrawFromRaceUseCase: WithdrawFromRaceUseCase;
|
||||
public readonly getLeagueStandingsUseCase: GetLeagueStandingsUseCase;
|
||||
|
||||
public readonly walletRepository: InMemoryWalletRepository;
|
||||
public readonly transactionRepository: InMemoryTransactionRepository;
|
||||
|
||||
public readonly getLeagueWalletUseCase: GetLeagueWalletUseCase;
|
||||
public readonly withdrawFromLeagueWalletUseCase: WithdrawFromLeagueWalletUseCase;
|
||||
|
||||
constructor() {
|
||||
this.leagueRepository = new InMemoryLeagueRepository();
|
||||
this.driverRepository = new InMemoryDriverRepository();
|
||||
@@ -44,12 +100,114 @@ export class LeaguesTestContext {
|
||||
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);
|
||||
|
||||
this.logger = {
|
||||
info: () => {},
|
||||
debug: () => {},
|
||||
warn: () => {},
|
||||
error: () => {},
|
||||
} as unknown as Logger;
|
||||
|
||||
this.racingLeagueRepository = new InMemoryRacingLeagueRepository(this.logger);
|
||||
this.seasonRepository = new InMemorySeasonRepository(this.logger);
|
||||
this.seasonSponsorshipRepository = new InMemorySeasonSponsorshipRepository(this.logger);
|
||||
this.raceRepository = new InMemoryRaceRepository(this.logger);
|
||||
this.resultRepository = new InMemoryResultRepository(this.logger, this.raceRepository);
|
||||
this.standingRepository = new InMemoryStandingRepository(
|
||||
this.logger,
|
||||
getPointsSystems(),
|
||||
this.resultRepository,
|
||||
this.raceRepository,
|
||||
this.racingLeagueRepository,
|
||||
);
|
||||
this.racingDriverRepository = new InMemoryRacingDriverRepository(this.logger);
|
||||
this.raceRegistrationRepository = new InMemoryRaceRegistrationRepository(this.logger);
|
||||
this.leagueMembershipRepository = new InMemoryLeagueMembershipRepository(this.logger);
|
||||
this.penaltyRepository = new InMemoryPenaltyRepository(this.logger);
|
||||
this.protestRepository = new InMemoryProtestRepository(this.logger);
|
||||
|
||||
this.getLeagueScheduleUseCase = new GetLeagueScheduleUseCase(
|
||||
this.racingLeagueRepository,
|
||||
this.seasonRepository,
|
||||
this.raceRepository,
|
||||
this.logger,
|
||||
);
|
||||
|
||||
let raceIdSequence = 0;
|
||||
this.createLeagueSeasonScheduleRaceUseCase = new CreateLeagueSeasonScheduleRaceUseCase(
|
||||
this.seasonRepository,
|
||||
this.raceRepository,
|
||||
this.logger,
|
||||
{
|
||||
generateRaceId: () => `race-${++raceIdSequence}`,
|
||||
},
|
||||
);
|
||||
|
||||
this.updateLeagueSeasonScheduleRaceUseCase = new UpdateLeagueSeasonScheduleRaceUseCase(
|
||||
this.seasonRepository,
|
||||
this.raceRepository,
|
||||
this.logger,
|
||||
);
|
||||
|
||||
this.deleteLeagueSeasonScheduleRaceUseCase = new DeleteLeagueSeasonScheduleRaceUseCase(
|
||||
this.seasonRepository,
|
||||
this.raceRepository,
|
||||
this.logger,
|
||||
);
|
||||
|
||||
this.publishLeagueSeasonScheduleUseCase = new PublishLeagueSeasonScheduleUseCase(this.seasonRepository, this.logger);
|
||||
this.unpublishLeagueSeasonScheduleUseCase = new UnpublishLeagueSeasonScheduleUseCase(this.seasonRepository, this.logger);
|
||||
|
||||
this.registerForRaceUseCase = new RegisterForRaceUseCase(
|
||||
this.raceRegistrationRepository,
|
||||
this.leagueMembershipRepository,
|
||||
this.logger,
|
||||
);
|
||||
|
||||
this.withdrawFromRaceUseCase = new WithdrawFromRaceUseCase(
|
||||
this.raceRepository,
|
||||
this.raceRegistrationRepository,
|
||||
this.logger,
|
||||
);
|
||||
|
||||
this.getLeagueStandingsUseCase = new GetLeagueStandingsUseCase(
|
||||
this.standingRepository,
|
||||
this.racingDriverRepository,
|
||||
);
|
||||
|
||||
this.walletRepository = new InMemoryWalletRepository(this.logger);
|
||||
this.transactionRepository = new InMemoryTransactionRepository(this.logger);
|
||||
|
||||
this.getLeagueWalletUseCase = new GetLeagueWalletUseCase(
|
||||
this.racingLeagueRepository,
|
||||
this.walletRepository,
|
||||
this.transactionRepository,
|
||||
);
|
||||
|
||||
this.withdrawFromLeagueWalletUseCase = new WithdrawFromLeagueWalletUseCase(
|
||||
this.racingLeagueRepository,
|
||||
this.walletRepository,
|
||||
this.transactionRepository,
|
||||
this.logger,
|
||||
);
|
||||
}
|
||||
|
||||
public clear(): void {
|
||||
this.leagueRepository.clear();
|
||||
this.driverRepository.clear();
|
||||
this.eventPublisher.clear();
|
||||
|
||||
this.racingLeagueRepository.clear();
|
||||
this.seasonRepository.clear();
|
||||
this.seasonSponsorshipRepository.clear();
|
||||
this.raceRepository.clear();
|
||||
this.leagueMembershipRepository.clear();
|
||||
|
||||
(this.raceRegistrationRepository as unknown as { registrations: Map<string, unknown> }).registrations?.clear?.();
|
||||
(this.resultRepository as unknown as { results: Map<string, unknown> }).results?.clear?.();
|
||||
(this.standingRepository as unknown as { standings: Map<string, unknown> }).standings?.clear?.();
|
||||
(this.racingDriverRepository as unknown as { drivers: Map<string, unknown> }).drivers?.clear?.();
|
||||
(this.racingDriverRepository as unknown as { iracingIdIndex: Map<string, unknown> }).iracingIdIndex?.clear?.();
|
||||
}
|
||||
|
||||
public async createLeague(command: Partial<LeagueCreateCommand> = {}) {
|
||||
|
||||
Reference in New Issue
Block a user